# HG changeset patch # User Mads Kiilerich # Date 1533687791 -7200 # Node ID a19f1649c8d44ffe7d1d9d8ed8ac8f25bd5ae439 # Parent 2b07e757a85f27663004db5a01708c7c45534e9a hooks: slight cleanup of handling of scm_repo.run_git_command return values It would still be nice to have better error handling, but this makes it slightly more clear what is going on and what error handling we don't have.. diff -r 2b07e757a85f -r a19f1649c8d4 kallithea/lib/hooks.py --- a/kallithea/lib/hooks.py Wed Aug 08 02:23:11 2018 +0200 +++ b/kallithea/lib/hooks.py Wed Aug 08 02:23:11 2018 +0200 @@ -443,14 +443,17 @@ scm_repo._repo.refs.set_symbolic_ref('HEAD', 'refs/heads/%s' % push_ref['name']) + # build exclude list without the ref cmd = ['for-each-ref', '--format=%(refname)', 'refs/heads/*'] - heads = scm_repo.run_git_command(cmd)[0] - cmd = ['log', push_ref['new_rev'], - '--reverse', '--pretty=format:%H', '--not'] - heads = heads.replace(push_ref['ref'], '') - for l in heads.splitlines(): - cmd.append(l.strip()) - git_revs += scm_repo.run_git_command(cmd)[0].splitlines() + stdout, stderr = scm_repo.run_git_command(cmd) + ref = push_ref['ref'] + heads = [head if head != ref else '' for head in stdout.splitlines()] + # now list the git revs while excluding from the list + cmd = ['log', push_ref['new_rev'], '--reverse', '--pretty=format:%H'] + cmd.append('--not') + cmd.extend(heads) + stdout, stderr = scm_repo.run_git_command(cmd) + git_revs += stdout.splitlines() elif push_ref['new_rev'] == EmptyChangeset().raw_id: # delete branch case @@ -458,7 +461,8 @@ else: cmd = ['log', '%(old_rev)s..%(new_rev)s' % push_ref, '--reverse', '--pretty=format:%H'] - git_revs += scm_repo.run_git_command(cmd)[0].splitlines() + stdout, stderr = scm_repo.run_git_command(cmd) + git_revs += stdout.splitlines() elif _type == 'tags': git_revs += ['tag=>%s' % push_ref['name']]