Exemple #1
0
def create_new_branch(revision=''):
    """Launches a dialog for creating a new branch"""
    model = MainModel()
    model.update_status()
    view = CreateBranchDialog(model, qtutils.active_window())
    if revision:
        view.set_revision(revision)
    view.show()
    return view
Exemple #2
0
def create_new_branch(revision=''):
    """Launches a dialog for creating a new branch"""
    model = MainModel()
    model.update_status()
    view = CreateBranchDialog(model, qtutils.active_window())
    if revision:
        view.set_revision(revision)
    view.show()
    return view
Exemple #3
0
def create_new_branch(revision=''):
    """Launches a dialog for creating a new branch"""
    model = MainModel()
    model.update_status()

    model.revision = revision
    model.local_branch = ''

    view = createbranch.CreateBranchView(qtutils.active_window())
    ctl = CreateBranchController(model, view)
    model.set_revision(revision)
    view.show()
    return ctl
class ClassicModelTestCase(helper.GitRepositoryTestCase):
    """Tests interfaces used by the classic view."""

    def setUp(self):
        helper.GitRepositoryTestCase.setUp(self, commit=False)
        self.model = MainModel(cwd=os.getcwd())

    def test_everything(self):
        """Test the MainModel.everything() method."""
        self.shell("touch other-file")
        everything = self.model.everything()

        self.assertTrue("A" in everything)
        self.assertTrue("B" in everything)
        self.assertTrue("other-file" in everything)

    def test_stage_paths_untracked(self):
        """Test stage_paths() with an untracked file."""
        self.shell(
            """
            mkdir -p foo/bar &&
            touch foo/bar/baz
        """
        )
        self.model.stage_paths(["foo"])

        self.assertTrue("foo/bar/baz" in self.model.staged)
        self.assertTrue("foo/bar/baz" not in self.model.modified)
        self.assertTrue("foo/bar/baz" not in self.model.untracked)

    def test_unstage_paths(self):
        """Test a simple usage of unstage_paths()."""
        self.shell(
            """
            git commit -m'initial commit' > /dev/null
            echo change > A &&
            git add A
        """
        )
        gitcmds.unstage_paths(["A"])
        self.model.update_status()

        self.assertTrue("A" not in self.model.staged)
        self.assertTrue("A" in self.model.modified)

    def test_unstage_paths_init(self):
        """Test unstage_paths() on the root commit."""
        gitcmds.unstage_paths(["A"])
        self.model.update_status()

        self.assertTrue("A" not in self.model.staged)
        self.assertTrue("A" in self.model.untracked)

    def test_unstage_paths_subdir(self):
        """Test unstage_paths() in a subdirectory."""
        self.shell("git commit -m'initial commit' > /dev/null")
        self.shell(
            """
            mkdir -p foo/bar &&
            touch foo/bar/baz &&
            git add foo/bar/baz
        """
        )
        gitcmds.unstage_paths(["foo"])
        self.model.update_status()

        self.assertTrue("foo/bar/baz" in self.model.untracked)
        self.assertTrue("foo/bar/baz" not in self.model.staged)
class ClassicModelTestCase(helper.GitRepositoryTestCase):
    """Tests interfaces used by the classic view."""
    def setUp(self):
        helper.GitRepositoryTestCase.setUp(self, commit=False)
        self.model = MainModel(cwd=os.getcwd())

    def test_everything(self):
        """Test the MainModel.everything() method."""
        self.shell('touch other-file')
        everything = self.model.everything()

        self.assertTrue('A' in everything)
        self.assertTrue('B' in everything)
        self.assertTrue('other-file' in everything)

    def test_stage_paths_untracked(self):
        """Test stage_paths() with an untracked file."""
        self.shell("""
            mkdir -p foo/bar &&
            touch foo/bar/baz
        """)
        self.model.stage_paths(['foo'])

        self.assertTrue('foo/bar/baz' in self.model.staged)
        self.assertTrue('foo/bar/baz' not in self.model.modified)
        self.assertTrue('foo/bar/baz' not in self.model.untracked)

    def test_unstage_paths(self):
        """Test a simple usage of unstage_paths()."""
        self.shell("""
            git commit -m'initial commit' > /dev/null
            echo change > A &&
            git add A
        """)
        gitcmds.unstage_paths(['A'])
        self.model.update_status()

        self.assertTrue('A' not in self.model.staged)
        self.assertTrue('A' in self.model.modified)

    def test_unstage_paths_init(self):
        """Test unstage_paths() on the root commit."""
        gitcmds.unstage_paths(['A'])
        self.model.update_status()

        self.assertTrue('A' not in self.model.staged)
        self.assertTrue('A' in self.model.untracked)

    def test_unstage_paths_subdir(self):
        """Test unstage_paths() in a subdirectory."""
        self.shell("git commit -m'initial commit' > /dev/null")
        self.shell("""
            mkdir -p foo/bar &&
            touch foo/bar/baz &&
            git add foo/bar/baz
        """)
        gitcmds.unstage_paths(['foo'])
        self.model.update_status()

        self.assertTrue('foo/bar/baz' in self.model.untracked)
        self.assertTrue('foo/bar/baz' not in self.model.staged)
class MainModelTestCase(helper.GitRepositoryTestCase):
    """Tests the MainModel class."""
    def setUp(self):
        helper.GitRepositoryTestCase.setUp(self)
        self.model = MainModel(cwd=os.getcwd())

    def test_project(self):
        """Test the 'project' attribute."""
        project = os.path.basename(self.test_path())
        self.assertEqual(self.model.project, project)

    def test_local_branches(self):
        """Test the 'local_branches' attribute."""
        self.model.update_status()
        self.assertEqual(self.model.local_branches, ['master'])

    def test_remote_branches(self):
        """Test the 'remote_branches' attribute."""
        self.model.update_status()
        self.assertEqual(self.model.remote_branches, [])

        self.shell("""
                git remote add origin .
                git fetch origin > /dev/null 2>&1
        """)
        self.model.update_status()
        self.assertEqual(self.model.remote_branches, ['origin/master'])

    def test_modified(self):
        """Test the 'modified' attribute."""
        self.shell('echo change > A')
        self.model.update_status()
        self.assertEqual(self.model.modified, ['A'])

    def test_unstaged(self):
        """Test the 'unstaged' attribute."""
        self.shell('echo change > A')
        self.shell('echo C > C')
        self.model.update_status()
        self.assertEqual(self.model.unstaged, ['A', 'C'])

    def test_untracked(self):
        """Test the 'untracked' attribute."""
        self.shell('echo C > C')
        self.model.update_status()
        self.assertEqual(self.model.untracked, ['C'])

    def test_remotes(self):
        """Test the 'remote' attribute."""
        self.shell('git remote add origin .')
        self.model.update_status()
        self.assertEqual(self.model.remotes, ['origin'])

    def test_currentbranch(self):
        """Test the 'currentbranch' attribute."""
        self.shell('git checkout -b test > /dev/null 2>&1')
        self.model.update_status()
        self.assertEqual(self.model.currentbranch, 'test')

    def test_tags(self):
        """Test the 'tags' attribute."""
        self.shell('git tag test')
        self.model.update_status()
        self.assertEqual(self.model.tags, ['test'])
class MainModelTestCase(helper.GitRepositoryTestCase):
    """Tests the MainModel class."""

    def setUp(self):
        helper.GitRepositoryTestCase.setUp(self)
        self.model = MainModel(cwd=os.getcwd())

    def test_project(self):
        """Test the 'project' attribute."""
        project = os.path.basename(self.test_path())
        self.assertEqual(self.model.project, project)

    def test_local_branches(self):
        """Test the 'local_branches' attribute."""
        self.model.update_status()
        self.assertEqual(self.model.local_branches, ['master'])

    def test_remote_branches(self):
        """Test the 'remote_branches' attribute."""
        self.model.update_status()
        self.assertEqual(self.model.remote_branches, [])

        self.shell("""
                git remote add origin .
                git fetch origin > /dev/null 2>&1
        """)
        self.model.update_status()
        self.assertEqual(self.model.remote_branches, ['origin/master'])

    def test_modified(self):
        """Test the 'modified' attribute."""
        self.shell('echo change > A')
        self.model.update_status()
        self.assertEqual(self.model.modified, ['A'])

    def test_unstaged(self):
        """Test the 'unstaged' attribute."""
        self.shell('echo change > A')
        self.shell('echo C > C')
        self.model.update_status()
        self.assertEqual(self.model.unstaged, ['A', 'C'])

    def test_untracked(self):
        """Test the 'untracked' attribute."""
        self.shell('echo C > C')
        self.model.update_status()
        self.assertEqual(self.model.untracked, ['C'])

    def test_remotes(self):
        """Test the 'remote' attribute."""
        self.shell('git remote add origin .')
        self.model.update_status()
        self.assertEqual(self.model.remotes, ['origin'])

    def test_currentbranch(self):
        """Test the 'currentbranch' attribute."""
        self.shell('git checkout -b test > /dev/null 2>&1')
        self.model.update_status()
        self.assertEqual(self.model.currentbranch, 'test')

    def test_tags(self):
        """Test the 'tags' attribute."""
        self.shell('git tag test')
        self.model.update_status()
        self.assertEqual(self.model.tags, ['test'])