From 3b1e225f73971a95a3da47f7d1b3dfc7b5765176 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Thu, 3 May 2018 10:39:51 +0200 Subject: [PATCH] Add missing get_default_branch --- roles/git/hooks/files/post-receive-alternativearch | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/roles/git/hooks/files/post-receive-alternativearch b/roles/git/hooks/files/post-receive-alternativearch index 7bc4a9a6a0..403ce815eb 100755 --- a/roles/git/hooks/files/post-receive-alternativearch +++ b/roles/git/hooks/files/post-receive-alternativearch @@ -100,6 +100,15 @@ def get_revs_between(oldrev, newrev, abspath, refname): return read_git_lines(cmd, abspath) +def get_default_branch(abspath): + """ Return the default branch of a repo. """ + cmd = ['rev-parse', '--abbrev-ref', 'HEAD'] + out = read_git_lines(cmd, abspath) + if out: + return out[0] + else: + return 'master' + def send_email(text, subject, to_mail): # pragma: no cover ''' Send an email with the specified information.