Beispiel #1
0
 def test_tracked_branch_other(self):
     """Test tracked_branch('other')."""
     context = self.context
     self.assertEqual(gitcmds.tracked_branch(context, 'other'), None)
     self.run_git('config', 'branch.other.remote', 'test')
     self.run_git('config', 'branch.other.merge', 'refs/heads/other/branch')
     self.cfg.reset()
     self.assertEqual(gitcmds.tracked_branch(context, 'other'), 'test/other/branch')
Beispiel #2
0
 def test_tracked_branch(self):
     """Test tracked_branch()."""
     self.assertEqual(gitcmds.tracked_branch(config=self.config), None)
     self.git('config', 'branch.master.remote', 'test')
     self.git('config', 'branch.master.merge', 'refs/heads/master')
     self.config.reset()
     self.assertEqual(gitcmds.tracked_branch(config=self.config),
                      'test/master')
Beispiel #3
0
 def test_tracked_branch(self):
     """Test tracked_branch()."""
     self.assertEqual(gitcmds.tracked_branch(config=self.config), None)
     self.git('config', 'branch.master.remote', 'test')
     self.git('config', 'branch.master.merge', 'refs/heads/master')
     self.config.reset()
     self.assertEqual(gitcmds.tracked_branch(config=self.config),
                      'test/master')
 def test_tracked_branch_other(self):
     """Test tracked_branch('other')."""
     self.assertEqual(gitcmds.tracked_branch('other'), None)
     self.shell("""
         git config branch.other.remote test &&
         git config branch.other.merge refs/heads/other/branch
     """)
     self.assertEqual(gitcmds.tracked_branch('other'), 'test/other/branch')
 def test_tracked_branch(self):
     """Test tracked_branch()."""
     self.assertEqual(gitcmds.tracked_branch(), None)
     self.shell("""
         git config branch.master.remote test &&
         git config branch.master.merge refs/heads/master
     """)
     self.assertEqual(gitcmds.tracked_branch(), 'test/master')
Beispiel #6
0
 def test_tracked_branch(self):
     """Test tracked_branch()."""
     context = self.context
     self.assertEqual(gitcmds.tracked_branch(context), None)
     self.run_git('config', 'branch.main.remote', 'test')
     self.run_git('config', 'branch.main.merge', 'refs/heads/main')
     self.cfg.reset()
     self.assertEqual(gitcmds.tracked_branch(context), 'test/main')
Beispiel #7
0
 def test_tracked_branch_other(self):
     """Test tracked_branch('other')."""
     context = self.context
     self.assertEqual(gitcmds.tracked_branch(context, 'other'), None)
     self.run_git('config', 'branch.other.remote', 'test')
     self.run_git('config', 'branch.other.merge', 'refs/heads/other/branch')
     self.cfg.reset()
     self.assertEqual(gitcmds.tracked_branch(context, 'other'),
                      'test/other/branch')
Beispiel #8
0
 def test_tracked_branch_other(self):
     """Test tracked_branch('other')."""
     self.assertEqual(gitcmds.tracked_branch('other', config=self.config),
                      None)
     self.git('config', 'branch.other.remote', 'test')
     self.git('config', 'branch.other.merge', 'refs/heads/other/branch')
     self.config.reset()
     self.assertEqual(gitcmds.tracked_branch('other', config=self.config),
                      'test/other/branch')
Beispiel #9
0
 def test_tracked_branch_other(self):
     """Test tracked_branch('other')."""
     self.assertEqual(gitcmds.tracked_branch('other', config=self.config),
                      None)
     self.git('config', 'branch.other.remote', 'test')
     self.git('config', 'branch.other.merge', 'refs/heads/other/branch')
     self.config.reset()
     self.assertEqual(gitcmds.tracked_branch('other', config=self.config),
                      'test/other/branch')
Beispiel #10
0
 def test_tracked_branch(self):
     """Test tracked_branch()."""
     self.assertEqual(gitcmds.tracked_branch(config=self.config), None)
     self.shell("""
         git config branch.master.remote test &&
         git config branch.master.merge refs/heads/master
     """)
     self.config.reset()
     self.assertEqual(gitcmds.tracked_branch(config=self.config),
                      'test/master')
Beispiel #11
0
 def test_tracked_branch_other(self):
     """Test tracked_branch('other')."""
     self.assertEqual(gitcmds.tracked_branch('other', config=self.config),
                      None)
     self.shell("""
         git config branch.other.remote test &&
         git config branch.other.merge refs/heads/other/branch
     """)
     self.config.reset()
     self.assertEqual(gitcmds.tracked_branch('other', config=self.config),
                      'test/other/branch')
Beispiel #12
0
def diff_expression():
    """Diff using an arbitrary expression."""
    tracked = gitcmds.tracked_branch()
    current = gitcmds.current_branch()
    if tracked and current:
        ref = tracked + '..' + current
    else:
        ref = 'origin/master..'
    difftool.diff_expression(qtutils.active_window(), ref)
Beispiel #13
0
def diff_expression():
    """Diff using an arbitrary expression."""
    tracked = gitcmds.tracked_branch()
    current = gitcmds.current_branch()
    if tracked and current:
        default = tracked + '..' + current
    else:
        default = 'origin/master..'
    ref = choose_ref('Enter Diff Expression', 'Diff', default=default)
    if not ref:
        return
    difftool.diff_expression(qtutils.active_window(), ref)
Beispiel #14
0
def diff_expression():
    """Diff using an arbitrary expression."""
    tracked = gitcmds.tracked_branch()
    current = gitcmds.current_branch()
    if tracked and current:
        default = tracked + '..' + current
    else:
        default = 'origin/master..'
    ref = choose_ref('Enter Diff Expression', 'Diff',
                     default=default)
    if not ref:
        return
    difftool.diff_expression(qtutils.active_window(), ref)
Beispiel #15
0
    def remote_ref(self, branch):
        """Returns the remote ref for 'git diff [local] [remote]'
        """
        if branch == self.BRANCH_POINT:
            # Compare against the branch point so find the merge-base
            branch = gitcmds.current_branch()
            tracked_branch = gitcmds.tracked_branch()
            if tracked_branch:
                return gitcmds.merge_base(branch, tracked_branch)
            else:
                remote_branches = gitcmds.branch_list(remote=True)
                remote_branch = 'origin/%s' % branch
                if remote_branch in remote_branches:
                    return gitcmds.merge_base(branch, remote_branch)

                elif 'origin/master' in remote_branches:
                    return gitcmds.merge_base(branch, 'origin/master')
                else:
                    return 'HEAD'
        else:
            # Compare against the remote branch
            return branch
Beispiel #16
0
    def update_status(self):
        # Give observers a chance to respond
        self.notify_message_observers(self.message_about_to_update)
        # This allows us to defer notification until the
        # we finish processing data
        staged_only = self.read_only()
        head = self.head
        notify_enabled = self.notification_enabled
        self.notification_enabled = False

        # Set these early since they are used to calculate 'upstream_changed'.
        self.set_trackedbranch(gitcmds.tracked_branch())
        self.set_currentbranch(gitcmds.current_branch())

        (self.staged,
         self.modified,
         self.unmerged,
         self.untracked,
         self.upstream_changed) = gitcmds.worktree_state(head=head,
                                                staged_only=staged_only)
        # NOTE: the model's unstaged list holds an aggregate of the
        # the modified, unmerged, and untracked file lists.
        self.set_unstaged(self.modified + self.unmerged + self.untracked)
        self.set_remotes(self.git.remote().splitlines())

        local_branches, remote_branches, tags = gitcmds.all_refs(split=True)
        self.set_local_branches(local_branches)
        self.set_remote_branches(remote_branches)
        self.set_tags(tags)

        self.set_revision('')
        self.set_local_branch('')
        self.set_remote_branch('')
        # Re-enable notifications and emit changes
        self.notification_enabled = notify_enabled

        self.read_font_sizes()
        self.notify_observers('staged', 'unstaged')
        self.notify_message_observers(self.message_updated)
Beispiel #17
0
    def remote_ref(self, branch):
        """Returns the remote ref for 'git diff [local] [remote]'
        """
        if branch == self.BRANCH_POINT:
            # Compare against the branch point so find the merge-base
            branch = gitcmds.current_branch()
            tracked_branch = gitcmds.tracked_branch()
            if tracked_branch:
                return gitcmds.merge_base(branch, tracked_branch)
            else:
                remote_branches = gitcmds.branch_list(remote=True)
                remote_branch = 'origin/%s' % branch
                if remote_branch in remote_branches:
                    return gitcmds.merge_base(branch, remote_branch)

                elif 'origin/master' in remote_branches:
                    return gitcmds.merge_base(branch, 'origin/master')
                else:
                    return 'HEAD'
        else:
            # Compare against the remote branch
            return branch
Beispiel #18
0
 def _update_branch_heads(self):
     # Set these early since they are used to calculate 'upstream_changed'.
     self.set_trackedbranch(gitcmds.tracked_branch())
     self.set_currentbranch(gitcmds.current_branch())