Fix rbtools git client when local clone has no "origin" remote.

Review Request #10340 — Created Nov. 29, 2018 and submitted

david
RBTools
release-1.0.x
81c9b4f...
rbtools

In the case where the local clone has remotes, but none of them are
named "origin", rbtools was failing to correctly determine the most
recent upstream commit. This was the case even when a tracking branch or
parent branch associated with a remote was configured. The cause here
was a couple places where we were hardcoding "origin" instead of
attempting to detect the remote.

This change fixes that by introducing a new mechanism to try to guess
the remote. If a remote tracking branch is specified, we'll prefer that,
failing back to the remote configured for the current branch. If no
direct association can be found, we'll return either "origin" or fall
back on the first remote found, emitting a warning.

  • Ran unit tests.
  • Set up a clone with multiple remotes, none of which were named
    "origin". Saw that I could correctly post changes when branch remotes
    and/or TRACKING_BRANCH were set correctly.
  • 0
  • 0
  • 5
  • 0
  • 5
Description From Last Updated
chipx86
  1. 
      
  2. rbtools/clients/git.py (Diff revision 1)
     
     

    These private methods are before some public methods. They should be moved further down the class.

  3. rbtools/clients/git.py (Diff revision 1)
     
     
     

    Must be the full path to the exception.

    Also, the description needs to be indented one more level.

  4. rbtools/clients/git.py (Diff revision 1)
     
     
     
     

    This is kind of weirdly formatted. Should be the standard:

    all_remote_branches = [
        branch.strip()
        for branch in self._execute(['git', 'branch', '--remotes'],
                                    split_lines=True)
    ]
    
  5. rbtools/clients/git.py (Diff revision 1)
     
     
     
     
     

    Let's specifically say "in .reviewboardrc".

  6. rbtools/clients/git.py (Diff revision 1)
     
     

    Missing period.

  7. 
      
david
chipx86
  1. Ship It!
  2. 
      
david
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-1.0.x (9f011e6)
Loading...