Skip to content

Commit

Permalink
fixup! Support specifying a pin for merges
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaspaulb committed Jul 18, 2023
1 parent bd3e574 commit d33c396
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions git_aggregator/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def __init__(self, cwd, remotes, merges, target,
:param remotes: list of remote linked to the repository. A remote is
a dict {'name': '', 'url': ''}
:param: merges list of merge to apply to build the aggregated
repository. A merge is a dict {'remote': '', 'ref': ''}
repository. A merge is a dict {'remote': '', 'ref': '', 'pin': ''}
:param target:
:param shell_command_after: an optional list of shell command to
execute after the aggregation
Expand Down Expand Up @@ -242,17 +242,15 @@ def fetch(self):
basecmd = ("git", "fetch")
logger.info("Fetching required remotes")
for merge in self.merges:
pin = remote.get("pin")
cmd = basecmd + self._fetch_options(merge) + (merge["remote"],)
if merge["remote"] not in self.fetch_all:
if pin:
if merge.get("pin"):
# Probably solvable, but a little too tricky for me to
# figure out right now
raise GitAggregatorException(
"Cannot use fetch_all with pin"
)
cmd += (merge["ref"],)
merge["pin"] = pin
self.log_call(cmd, cwd=self.cwd)

def rev_parse(self, ref):
Expand Down Expand Up @@ -311,8 +309,6 @@ def _switch_to_branch(self, branch_name):
# check if the branch already exists
logger.info("Switch to branch %s", branch_name)
cmd = ['git', 'checkout', '-B', branch_name]
if ref is not None:
cmd.append(self.rev_parse(ref))
self.log_call(cmd, cwd=self.cwd)

def _execute_shell_command_after(self):
Expand All @@ -322,7 +318,12 @@ def _execute_shell_command_after(self):

def _merge(self, merge):
pin = merge.get("pin")
logger.info("Pull %s, %s, %s", merge["remote"], merge["ref"], pin or "no pin")
logger.info(
"Pull %s, %s, %s",
merge["remote"],
merge["ref"],
pin or "no pin"
)
cmd = ("git", "pull", "--ff", "--no-rebase")
if self.git_version >= (1, 7, 10):
# --edit and --no-edit appear with Git 1.7.10
Expand Down

0 comments on commit d33c396

Please sign in to comment.