Skip to content

Commit f4aaa32

Browse files
author
Tom Blauwendraat
committed
[FIX] pre-commit, tests
1 parent 03f7a19 commit f4aaa32

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

git_aggregator/repo.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,13 @@ def query_remote(self, remote, refs=None):
155155
for ref in refs:
156156
yield None, ref, ref
157157
return
158-
for sha, fullref in (l.split() for l in out.splitlines()):
158+
for sha, fullref in (line.split() for line in out.splitlines()):
159159
if fullref.startswith('refs/heads/'):
160-
yield 'branch', fullref, sha
160+
ref = fullref.split("/")[-1]
161+
yield 'branch', ref, sha
161162
elif fullref.startswith('refs/tags/'):
162-
yield 'tag', fullref, sha
163+
ref = fullref.split("/")[-1]
164+
yield 'tag', ref, sha
163165
elif fullref == 'HEAD':
164166
yield 'HEAD', fullref, sha
165167
else:
@@ -255,7 +257,7 @@ def init_repository(self, target_dir):
255257
# repository
256258
cmd += ('--filter=blob:none',)
257259
# Try to clone target branch, if it exists
258-
rtype, _sha = self.query_remote_ref(repository, branch)
260+
rtype, _ref, _sha = list(self.query_remote(repository, branch))[0]
259261
if rtype in {'branch', 'tag'}:
260262
cmd += ('-b', branch)
261263
# Emtpy fetch options to use global default for 1st clone
@@ -342,7 +344,10 @@ def push(self):
342344
"Cannot push %s, no target remote configured" % branch
343345
)
344346
logger.info("Push %s to %s", branch, remote)
345-
self.log_call(['git', 'push', '-f', remote, "HEAD:%s" % branch], cwd=self.cwd)
347+
self.log_call(
348+
['git', 'push', '-f', remote, "HEAD:%s" % branch],
349+
cwd=self.cwd
350+
)
346351

347352
def _check_status(self):
348353
"""Check repo status and except if dirty."""
@@ -392,8 +397,7 @@ def _execute_shell_command_after(self):
392397
self.log_call(cmd, shell=True, cwd=self.cwd)
393398

394399
def _merge(self, merge):
395-
logger.info("Merge %s, %s", merge["remote"], merge["ref"])
396-
cmd = ("git", "merge")
400+
cmd = ("git", "merge", "--ff")
397401
if self.git_version >= (1, 7, 10):
398402
# --edit and --no-edit appear with Git 1.7.10
399403
# see Documentation/RelNotes/1.7.10.txt of Git

tests/test_repo.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ def setUp(self):
9595
subprocess.check_call(['git', 'tag', 'tag1'], cwd=self.remote1)
9696
self.commit_2_sha = git_write_commit(
9797
self.remote1, 'tracked', "last", msg="last commit")
98-
subprocess.check_call(['git', 'tag', '-am', 'foo', 'tag2'], cwd=self.remote1)
98+
subprocess.check_call(['git', 'tag', '-am', 'foo', 'tag2'],
99+
cwd=self.remote1)
99100
self.commit_3_sha = git_write_commit(
100101
self.remote2, 'tracked2', "remote2", msg="new commit")
101102
subprocess.check_call(['git', 'checkout', '-b', 'b2'],
@@ -171,7 +172,7 @@ def test_simple_merge(self):
171172
self.assertTrue(sha)
172173

173174
def test_simple_merge_2(self):
174-
## Launched from an existing git repository
175+
# Launched from an existing git repository
175176
remotes = [{
176177
'name': 'r1',
177178
'url': self.url_remote1

0 commit comments

Comments
 (0)