Skip to content

Commit d33c396

Browse files
author
Tom Blauwendraat
committed
fixup! Support specifying a pin for merges
1 parent bd3e574 commit d33c396

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

git_aggregator/repo.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def __init__(self, cwd, remotes, merges, target,
4545
:param remotes: list of remote linked to the repository. A remote is
4646
a dict {'name': '', 'url': ''}
4747
:param: merges list of merge to apply to build the aggregated
48-
repository. A merge is a dict {'remote': '', 'ref': ''}
48+
repository. A merge is a dict {'remote': '', 'ref': '', 'pin': ''}
4949
:param target:
5050
:param shell_command_after: an optional list of shell command to
5151
execute after the aggregation
@@ -242,17 +242,15 @@ def fetch(self):
242242
basecmd = ("git", "fetch")
243243
logger.info("Fetching required remotes")
244244
for merge in self.merges:
245-
pin = remote.get("pin")
246245
cmd = basecmd + self._fetch_options(merge) + (merge["remote"],)
247246
if merge["remote"] not in self.fetch_all:
248-
if pin:
247+
if merge.get("pin"):
249248
# Probably solvable, but a little too tricky for me to
250249
# figure out right now
251250
raise GitAggregatorException(
252251
"Cannot use fetch_all with pin"
253252
)
254253
cmd += (merge["ref"],)
255-
merge["pin"] = pin
256254
self.log_call(cmd, cwd=self.cwd)
257255

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

318314
def _execute_shell_command_after(self):
@@ -322,7 +318,12 @@ def _execute_shell_command_after(self):
322318

323319
def _merge(self, merge):
324320
pin = merge.get("pin")
325-
logger.info("Pull %s, %s, %s", merge["remote"], merge["ref"], pin or "no pin")
321+
logger.info(
322+
"Pull %s, %s, %s",
323+
merge["remote"],
324+
merge["ref"],
325+
pin or "no pin"
326+
)
326327
cmd = ("git", "pull", "--ff", "--no-rebase")
327328
if self.git_version >= (1, 7, 10):
328329
# --edit and --no-edit appear with Git 1.7.10

0 commit comments

Comments
 (0)