Skip to content

Commit

Permalink
[Fix] branch relative regex
Browse files Browse the repository at this point in the history
and limit the history search for current branch
  • Loading branch information
randy3k committed Feb 17, 2018
1 parent f7de5a8 commit 730fce2
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions core/git_mixins/rebase.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from ..exceptions import GitSavvyError
from ...common import util

NEAREST_NODE_PATTERN = re.compile(r'.*\*.*\[(.*?)(?:(?:[\^\~]+[\d]*){1})\]') # http://regexr.com/3gm03
NEAREST_NODE_PATTERN = re.compile(r'.*\*.*\[(.*?)(?:[\^\~]+[\d]*)+\]') # https://regexr.com/3kuv3


class NearestBranchMixin(object):
Expand All @@ -21,7 +21,7 @@ def branch_relatives(self, branch):
match = re.search(NEAREST_NODE_PATTERN, rel)
if not match:
continue
branch_name = match.groups()[0]
branch_name = match.group(1)
if branch_name != branch and branch_name not in relatives:
relatives.append(branch_name)
return relatives
Expand All @@ -32,8 +32,9 @@ def _nearest_from_relatives(self, relatives, branch):
"""
util.debug.add_to_log('nearest_branch: filtering branches that share branch-out nodes')
diff = difflib.Differ()
branch_commits = self.git("rev-list", "--first-parent", branch).splitlines()
max_revisions = 100
branch_commits = self.git(
"rev-list", "-{}".format(max_revisions), "--first-parent", branch).splitlines()
for relative in relatives:
util.debug.add_to_log('nearest_branch: Getting common commits with {}'.format(relative))
relative_commits = self.git("rev-list", "-{}".format(max_revisions),
Expand Down

0 comments on commit 730fce2

Please sign in to comment.