Skip to content

Commit

Permalink
[FIX] pre-commit, tests
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaspaulb committed Jul 18, 2023
1 parent 03f7a19 commit f4aaa32
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
18 changes: 11 additions & 7 deletions git_aggregator/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,13 @@ def query_remote(self, remote, refs=None):
for ref in refs:
yield None, ref, ref
return
for sha, fullref in (l.split() for l in out.splitlines()):
for sha, fullref in (line.split() for line in out.splitlines()):
if fullref.startswith('refs/heads/'):
yield 'branch', fullref, sha
ref = fullref.split("/")[-1]
yield 'branch', ref, sha
elif fullref.startswith('refs/tags/'):
yield 'tag', fullref, sha
ref = fullref.split("/")[-1]
yield 'tag', ref, sha
elif fullref == 'HEAD':
yield 'HEAD', fullref, sha
else:
Expand Down Expand Up @@ -255,7 +257,7 @@ def init_repository(self, target_dir):
# repository
cmd += ('--filter=blob:none',)
# Try to clone target branch, if it exists
rtype, _sha = self.query_remote_ref(repository, branch)
rtype, _ref, _sha = list(self.query_remote(repository, branch))[0]
if rtype in {'branch', 'tag'}:
cmd += ('-b', branch)
# Emtpy fetch options to use global default for 1st clone
Expand Down Expand Up @@ -342,7 +344,10 @@ def push(self):
"Cannot push %s, no target remote configured" % branch
)
logger.info("Push %s to %s", branch, remote)
self.log_call(['git', 'push', '-f', remote, "HEAD:%s" % branch], cwd=self.cwd)
self.log_call(
['git', 'push', '-f', remote, "HEAD:%s" % branch],
cwd=self.cwd
)

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

def _merge(self, merge):
logger.info("Merge %s, %s", merge["remote"], merge["ref"])
cmd = ("git", "merge")
cmd = ("git", "merge", "--ff")
if self.git_version >= (1, 7, 10):
# --edit and --no-edit appear with Git 1.7.10
# see Documentation/RelNotes/1.7.10.txt of Git
Expand Down
5 changes: 3 additions & 2 deletions tests/test_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ def setUp(self):
subprocess.check_call(['git', 'tag', 'tag1'], cwd=self.remote1)
self.commit_2_sha = git_write_commit(
self.remote1, 'tracked', "last", msg="last commit")
subprocess.check_call(['git', 'tag', '-am', 'foo', 'tag2'], cwd=self.remote1)
subprocess.check_call(['git', 'tag', '-am', 'foo', 'tag2'],
cwd=self.remote1)
self.commit_3_sha = git_write_commit(
self.remote2, 'tracked2', "remote2", msg="new commit")
subprocess.check_call(['git', 'checkout', '-b', 'b2'],
Expand Down Expand Up @@ -171,7 +172,7 @@ def test_simple_merge(self):
self.assertTrue(sha)

def test_simple_merge_2(self):
## Launched from an existing git repository
# Launched from an existing git repository
remotes = [{
'name': 'r1',
'url': self.url_remote1
Expand Down

0 comments on commit f4aaa32

Please sign in to comment.