Пример #1
0
    def setUp(self):
        super().setUp()
        name = "git-source"  # must match what the tests expect

        def _add_and_commit_file(path, filename, contents=None, message=None):
            if not contents:
                contents = filename
            if not message:
                message = filename

            with open(os.path.join(path, filename), "w") as fp:
                fp.write(contents)

            call(["git", "-C", name, "add", filename])
            call(["git", "-C", name, "commit", "-am", message])

        os.makedirs(name)
        call(["git", "-C", name, "init"])
        call(["git", "-C", name, "config", "user.name", "Test User"])
        call(["git", "-C", name, "config", "user.email", "*****@*****.**"])

        _add_and_commit_file(name, "testing")
        call(["git", "-C", name, "branch", "test-branch"])

        _add_and_commit_file(name, "testing-2")
        call(["git", "-C", name, "tag", "feature-tag"])

        _add_and_commit_file(name, "testing-3")

        self.commit = call_with_output(["git", "-C", name, "rev-parse", "HEAD"])
Пример #2
0
        def _add_and_commit_file(path, filename, contents=None, message=None):
            if not contents:
                contents = filename
            if not message:
                message = filename

            with open(os.path.join(path, filename), "w") as fp:
                fp.write(contents)

            call(["git", "-C", name, "add", filename])
            call(["git", "-C", name, "commit", "-am", message])
Пример #3
0
    def setUp(self):
        super().setUp()

        with return_to_cwd():
            os.makedirs(self.name)
            os.chdir(self.name)
            call(["hg", "init"])
            with open("testing", "w") as fp:
                fp.write("testing")

            call(["hg", "add", "testing"])
            call(
                [
                    "hg",
                    "commit",
                    "-m",
                    "testing",
                    "-u",
                    "Test User <*****@*****.**>",
                ]
            )
            call(
                ["hg", "tag", "feature-tag", "-u", "Test User <*****@*****.**>"]
            )
            revno = call_with_output(["hg", "id"]).split()[0]

            self.commit = revno
Пример #4
0
    def setUp(self):
        super().setUp()
        self.repo_tree = "svn-repo"
        self.working_tree = "svn-test"
        self.source_dir = "svn-checkout"
        self.clean_dir(self.repo_tree)
        self.clean_dir(self.working_tree)
        call(["svnadmin", "create", self.repo_tree])
        self.clone_repo(self.repo_tree, self.working_tree)
        os.chdir(self.working_tree)
        self.add_file("testing", "test body", "test message")
        self.expected_commit = "1"

        os.chdir("..")

        self.svn = sources.Subversion(self.repo_tree, self.source_dir, silent=True)
        self.svn.pull()

        self.source_details = self.svn._get_source_details()
Пример #5
0
    def setUp(self):
        super().setUp()

        working_tree = 'svn-repo'
        call(['svnadmin', 'create', self.name])
        call(['svn', 'checkout',
              'file://{}'.format(os.path.join(os.getcwd(), self.name)),
              working_tree])

        with return_to_cwd():
            os.chdir(working_tree)
            with open('testing', 'w') as fp:
                fp.write('testing')

            call(['svn', 'add', 'testing'])
            call(['svn', 'commit', '-m', 'svn testing'])
            revno = '1'

            self.commit = revno
Пример #6
0
    def setUp(self):
        super().setUp()

        bzr_home = self.useFixture(fixtures.TempDir()).path
        self.useFixture(fixtures.EnvironmentVariable('BZR_HOME', bzr_home))
        self.useFixture(fixtures.EnvironmentVariable(
            'BZR_EMAIL',  'Test User <*****@*****.**>'))

        with return_to_cwd():
            os.makedirs(self.name)
            os.chdir(self.name)
            call(['bzr', 'init'])
            with open('testing', 'w') as fp:
                fp.write('testing')

            call(['bzr', 'add', 'testing'])
            call(['bzr', 'commit', '-m', 'testing'])
            call(['bzr', 'tag', 'feature-tag'])
            revno = call_with_output(['bzr', 'revno'])

            self.commit = revno
Пример #7
0
    def setUp(self):
        super().setUp()

        with return_to_cwd():
            os.makedirs(self.name)
            os.chdir(self.name)
            call(['hg', 'init'])
            with open('testing', 'w') as fp:
                fp.write('testing')

            call(['hg', 'add', 'testing'])
            call([
                'hg', 'commit', '-m', 'testing', '-u',
                'Test User <*****@*****.**>'
            ])
            call([
                'hg', 'tag', 'feature-tag', '-u',
                'Test User <*****@*****.**>'
            ])
            revno = call_with_output(['hg', 'id']).split()[0]

            self.commit = revno
Пример #8
0
    def setUp(self):
        super().setUp()

        bzr_home = self.useFixture(fixtures.TempDir()).path
        self.useFixture(fixtures.EnvironmentVariable("BZR_HOME", bzr_home))
        self.useFixture(
            fixtures.EnvironmentVariable("BZR_EMAIL",
                                         "Test User <*****@*****.**>"))

        with return_to_cwd():
            os.makedirs(self.name)
            os.chdir(self.name)
            call(["bzr", "init"])
            with open("testing", "w") as fp:
                fp.write("testing")

            call(["bzr", "add", "testing"])
            call(["bzr", "commit", "-m", "testing"])
            call(["bzr", "tag", "feature-tag"])
            revno = call_with_output(["bzr", "revno"])

            self.commit = revno
Пример #9
0
    def setUp(self):
        super().setUp()

        working_tree = "svn-repo"
        call(["svnadmin", "create", self.name])
        call([
            "svn",
            "checkout",
            "file://{}".format(os.path.join(os.getcwd(), self.name)),
            working_tree,
        ])

        with return_to_cwd():
            os.chdir(working_tree)
            with open("testing", "w") as fp:
                fp.write("testing")

            call(["svn", "add", "testing"])
            call(["svn", "commit", "-m", "svn testing"])
            revno = "1"

            self.commit = revno
Пример #10
0
    def setUp(self):
        super().setUp()
        self.working_tree = "hg-test"
        self.source_dir = "hg-checkout"
        self.clean_dir(self.working_tree)
        self.clean_dir(self.source_dir)
        os.chdir(self.working_tree)
        call(["hg", "init"])
        with open("testing", "w") as fp:
            fp.write("testing")
        call(["hg", "add", "testing"])
        call(["hg", "commit", "-m", "testing", "-u", "Test User <*****@*****.**>"])
        call(["hg", "tag", "-u", "test", "test-tag"])
        self.expected_commit = call_with_output(["hg", "id"]).split()[0]
        self.expected_branch = call_with_output(["hg", "branch"])
        self.expected_tag = "test-tag"

        os.chdir("..")

        self.hg = sources.Mercurial(self.working_tree, self.source_dir, silent=True)
        self.hg.pull()

        self.source_details = self.hg._get_source_details()
Пример #11
0
    def setUp(self):
        super().setUp()

        working_tree = "svn-repo"
        call(["svnadmin", "create", self.name])
        call(
            [
                "svn",
                "checkout",
                "file://{}".format(os.path.join(os.getcwd(), self.name)),
                working_tree,
            ]
        )

        with return_to_cwd():
            os.chdir(working_tree)
            with open("testing", "w") as fp:
                fp.write("testing")

            call(["svn", "add", "testing"])
            call(["svn", "commit", "-m", "svn testing"])
            revno = "1"

            self.commit = revno
Пример #12
0
    def setUp(self):
        super().setUp()

        bzr_home = self.useFixture(fixtures.TempDir()).path
        self.useFixture(fixtures.EnvironmentVariable("BZR_HOME", bzr_home))
        self.useFixture(
            fixtures.EnvironmentVariable(
                "BZR_EMAIL", "Test User <*****@*****.**>"
            )
        )

        with return_to_cwd():
            os.makedirs(self.name)
            os.chdir(self.name)
            call(["bzr", "init"])
            with open("testing", "w") as fp:
                fp.write("testing")

            call(["bzr", "add", "testing"])
            call(["bzr", "commit", "-m", "testing"])
            call(["bzr", "tag", "feature-tag"])
            revno = call_with_output(["bzr", "revno"])

            self.commit = revno
Пример #13
0
    def test_git_conflicts(self):

        repo = '/tmp/conflict-test.git'
        working_tree = '/tmp/git-conflict-test'
        conflicting_tree = '{}-conflict'.format(working_tree)
        git = sources.Git(repo, working_tree, silent=True)

        self.clean_dir(repo)
        self.clean_dir(working_tree)
        self.clean_dir(conflicting_tree)

        os.chdir(repo)
        call(['git', 'init', '--bare'])

        self.clone_repo(repo, working_tree)

        # check out the original repo
        self.clone_repo(repo, conflicting_tree)

        # add a file to the repo
        os.chdir(working_tree)
        self.add_file('fake', 'fake 1', 'fake 1')
        call(['git', 'push', repo])

        git.pull()

        os.chdir(conflicting_tree)
        self.add_file('fake', 'fake 2', 'fake 2')
        call(['git', 'push', '-f', repo])

        os.chdir(working_tree)
        git.pull()

        body = None
        with open(os.path.join(working_tree, 'fake')) as fp:
            body = fp.read()

        self.assertThat(body, Equals('fake 2'))
Пример #14
0
    def test_git_conflicts(self):

        repo = "/tmp/conflict-test.git"
        working_tree = "/tmp/git-conflict-test"
        conflicting_tree = "{}-conflict".format(working_tree)
        git = sources.Git(repo, working_tree, silent=True)

        self.clean_dir(repo)
        self.clean_dir(working_tree)
        self.clean_dir(conflicting_tree)

        os.chdir(repo)
        call(["git", "init", "--bare"])

        self.clone_repo(repo, working_tree)

        # check out the original repo
        self.clone_repo(repo, conflicting_tree)

        # add a file to the repo
        os.chdir(working_tree)
        self.add_file("fake", "fake 1", "fake 1")
        call(["git", "push", repo])

        git.pull()

        os.chdir(conflicting_tree)
        self.add_file("fake", "fake 2", "fake 2")
        call(["git", "push", "-f", repo])

        os.chdir(working_tree)
        git.pull()

        body = None
        with open(os.path.join(working_tree, "fake")) as fp:
            body = fp.read()

        self.assertThat(body, Equals("fake 2"))
Пример #15
0
    def add_file(self, filename, body, message):
        with open(filename, "w") as fp:
            fp.write(body)

        call(["svn", "add", filename])
        call(["svn", "commit", "-m", message])
Пример #16
0
    def test_git_submodules(self):
        """Test that updates to submodules are pulled"""
        repo = '/tmp/submodules.git'
        sub_repo = '/tmp/subrepo'
        working_tree = '/tmp/git-submodules'
        working_tree_two = '{}-two'.format(working_tree)
        sub_working_tree = '/tmp/git-submodules-sub'
        git = sources.Git(repo, working_tree, silent=True)

        self.clean_dir(repo)
        self.clean_dir(sub_repo)
        self.clean_dir(working_tree)
        self.clean_dir(working_tree_two)
        self.clean_dir(sub_working_tree)

        os.chdir(sub_repo)
        call(['git', 'init', '--bare'])

        self.clone_repo(sub_repo, sub_working_tree)
        self.add_file('sub-file', 'sub-file', 'sub-file')
        call(['git', 'push', sub_repo])

        os.chdir(repo)
        call(['git', 'init', '--bare'])

        self.clone_repo(repo, working_tree)
        call(['git', 'submodule', 'add', sub_repo])
        call(['git', 'commit', '-am', 'added submodule'])
        call(['git', 'push', repo])

        git.pull()

        self.check_file_contents(os.path.join(working_tree,
                                              'subrepo', 'sub-file'),
                                 'sub-file')

        # add a file to the repo
        os.chdir(sub_working_tree)
        self.add_file('fake', 'fake 1', 'fake 1')
        call(['git', 'push', sub_repo])

        os.chdir(working_tree)
        git.pull()

        # this shouldn't cause any change
        self.check_file_contents(os.path.join(working_tree,
                                              'subrepo', 'sub-file'),
                                 'sub-file')
        self.assertFalse(os.path.exists(os.path.join(working_tree,
                                                     'subrepo', 'fake')))

        # update the submodule
        self.clone_repo(repo, working_tree_two)
        call(['git', 'submodule', 'update', '--init', '--recursive',
              '--remote'])
        call(['git', 'add', 'subrepo'])
        call(['git', 'commit', '-am', 'updated submodule'])
        call(['git', 'push'])

        os.chdir(working_tree)
        git.pull()

        # new file should be there now
        self.check_file_contents(os.path.join(working_tree,
                                              'subrepo', 'sub-file'),
                                 'sub-file')
        self.check_file_contents(os.path.join(working_tree,
                                              'subrepo', 'fake'),
                                 'fake 1')
Пример #17
0
 def clone_repo(self, repo, tree):
     self.clean_dir(tree)
     call([
         "svn", "checkout", "file://{}/{}".format(os.getcwd(), repo), tree
     ])
Пример #18
0
 def clone_repo(self, repo, tree):
     self.clean_dir(tree)
     call(['hg', 'clone', repo, tree])
     os.chdir(tree)
Пример #19
0
 def clone_repo(self, repo, tree):
     self.clean_dir(tree)
     call([
         'svn', 'checkout', 'file://{}/{}'.format(os.getcwd(), repo), tree
     ])
Пример #20
0
 def clone_repo(self, repo, tree):
     self.clean_dir(tree)
     call(["svn", "checkout", "file://{}/{}".format(os.getcwd(), repo), tree])
Пример #21
0
    def add_file(self, filename, body, message):
        with open(filename, "w") as fp:
            fp.write(body)

        call(["svn", "add", filename])
        call(["svn", "commit", "-m", message])
Пример #22
0
 def clone_repo(self, repo, tree):
     self.clean_dir(tree)
     call(["hg", "clone", repo, tree])
     os.chdir(tree)
Пример #23
0
    def add_file(self, filename, body, message):
        with open(filename, 'w') as fp:
            fp.write(body)

        call(['hg', 'add', filename])
        call(['hg', 'commit', '-am', message])
Пример #24
0
 def clone_repo(self, repo, tree):
     self.clean_dir(tree)
     call(["hg", "clone", repo, tree])
     os.chdir(tree)
Пример #25
0
 def clone_repo(self, repo, tree):
     self.clean_dir(tree)
     call(["git", "clone", repo, tree])
     os.chdir(tree)
     call(["git", "config", "--local", "user.name", '"Example Dev"'])
     call(["git", "config", "--local", "user.email", "*****@*****.**"])
Пример #26
0
    def test_git_submodules(self):
        """Test that updates to submodules are pulled"""
        repo = "/tmp/submodules.git"
        sub_repo = "/tmp/subrepo"
        working_tree = "/tmp/git-submodules"
        working_tree_two = "{}-two".format(working_tree)
        sub_working_tree = "/tmp/git-submodules-sub"
        git = sources.Git(repo, working_tree, silent=True)

        self.clean_dir(repo)
        self.clean_dir(sub_repo)
        self.clean_dir(working_tree)
        self.clean_dir(working_tree_two)
        self.clean_dir(sub_working_tree)

        os.chdir(sub_repo)
        call(["git", "init", "--bare"])

        self.clone_repo(sub_repo, sub_working_tree)
        self.add_file("sub-file", "sub-file", "sub-file")
        call(["git", "push", sub_repo])

        os.chdir(repo)
        call(["git", "init", "--bare"])

        self.clone_repo(repo, working_tree)
        call(["git", "submodule", "add", sub_repo])
        call(["git", "commit", "-am", "added submodule"])
        call(["git", "push", repo])

        git.pull()

        self.check_file_contents(
            os.path.join(working_tree, "subrepo", "sub-file"), "sub-file")

        # add a file to the repo
        os.chdir(sub_working_tree)
        self.add_file("fake", "fake 1", "fake 1")
        call(["git", "push", sub_repo])

        os.chdir(working_tree)
        git.pull()

        # this shouldn't cause any change
        self.check_file_contents(
            os.path.join(working_tree, "subrepo", "sub-file"), "sub-file")
        self.assertFalse(
            os.path.exists(os.path.join(working_tree, "subrepo", "fake")))

        # update the submodule
        self.clone_repo(repo, working_tree_two)
        call([
            "git", "submodule", "update", "--init", "--recursive", "--remote"
        ])
        call(["git", "add", "subrepo"])
        call(["git", "commit", "-am", "updated submodule"])
        call(["git", "push"])

        os.chdir(working_tree)
        git.pull()

        # new file should be there now
        self.check_file_contents(
            os.path.join(working_tree, "subrepo", "sub-file"), "sub-file")
        self.check_file_contents(os.path.join(working_tree, "subrepo", "fake"),
                                 "fake 1")