Exemplo n.º 1
0
 def _raw_git_clone(self, base_dir, url, branch, dest):
     clone_dir = _os.path.join(base_dir, dest)
     self._set_tear_down_cb(self._clone_tear_down_cb, clone_dir)
     ShellHelper.exec_command(
         _shlex.split('git clone -b %s %s %s' % (branch, url, dest)),
         base_dir)
     return
Exemplo n.º 2
0
 def _raw_git_clone(self, base_dir, url, branch, dest):
     clone_dir = _os.path.join(base_dir, dest)
     self._set_tear_down_cb(self._clone_tear_down_cb, clone_dir)
     ShellHelper.exec_command(
         _shlex.split('git clone -b %s %s %s' % (branch, url, dest)),
         base_dir)
     return
Exemplo n.º 3
0
    def test_current_tag_lightweight_tag(self):
        self._raw_git_clone(
            type(self)._repos_dir,
            type(self)._origin_repo, 'master', 'test-clone')
        base_dir = _os.path.join(type(self)._repos_dir, 'test-clone')
        ShellHelper.exec_command(_shlex.split('git tag tag-v1'), base_dir)

        git = GitWrapper(base_dir)
        self.assertEqual(git.get_current_tag(), 'tag-v1')
        return
Exemplo n.º 4
0
    def test_current_branch_detached_head(self):
        self._raw_git_clone(
            type(self)._repos_dir,
            type(self)._origin_repo, 'master', 'test-clone')
        base_dir = _os.path.join(type(self)._repos_dir, 'test-clone')
        ShellHelper.exec_command(_shlex.split('git checkout HEAD^'), base_dir)

        git = GitWrapper(base_dir)
        self.assertIsNone(git.get_current_branch())
        return
Exemplo n.º 5
0
    def test_current_tag_lightweight_tag(self):
        self._raw_git_clone(
            type(self)._repos_dir,
            type(self)._origin_repo,
            'master',
            'test-clone')
        base_dir = _os.path.join(type(self)._repos_dir, 'test-clone')
        ShellHelper.exec_command(_shlex.split('git tag tag-v1'), base_dir)

        git = GitWrapper(base_dir)
        self.assertEqual(git.get_current_tag(), 'tag-v1')
        return
Exemplo n.º 6
0
    def test_current_branch_detached_head(self):
        self._raw_git_clone(
            type(self)._repos_dir,
            type(self)._origin_repo,
            'master',
            'test-clone')
        base_dir = _os.path.join(type(self)._repos_dir, 'test-clone')
        ShellHelper.exec_command(_shlex.split('git checkout HEAD^'), base_dir)

        git = GitWrapper(base_dir)
        self.assertIsNone(git.get_current_branch())
        return
Exemplo n.º 7
0
    def test_uncommitted_with_changes(self):
        self._raw_git_clone(
            type(self)._repos_dir,
            type(self)._origin_repo, 'master', 'test-clone')
        base_dir = _os.path.join(type(self)._repos_dir, 'test-clone')
        ShellHelper.append_text_to_file('Modifying existing file...', 'README',
                                        base_dir)
        ShellHelper.remove_file(_os.path.join(base_dir, 'dummy'))
        ShellHelper.exec_command(_shlex.split('git add README'), base_dir)
        ShellHelper.exec_command(_shlex.split('git rm dummy'), base_dir)

        git = GitWrapper(base_dir)
        self.assertItemsEqual(git.get_uncommitted_staged_files(),
                              ['M\tREADME', 'D\tdummy'])
        return
Exemplo n.º 8
0
    def test_uncommitted_with_changes(self):
        self._raw_git_clone(
            type(self)._repos_dir,
            type(self)._origin_repo,
            'master',
            'test-clone')
        base_dir = _os.path.join(type(self)._repos_dir, 'test-clone')
        ShellHelper.append_text_to_file(
            'Modifying existing file...',
            'README',
            base_dir)
        ShellHelper.remove_file(_os.path.join(base_dir, 'dummy'))
        ShellHelper.exec_command(_shlex.split('git add README'), base_dir)
        ShellHelper.exec_command(_shlex.split('git rm dummy'), base_dir)

        git = GitWrapper(base_dir)
        self.assertItemsEqual(git.get_uncommitted_staged_files(),
                              ['M\tREADME', 'D\tdummy'])
        return