From 98a776333f07021c6e31993a24d5a78ce38e36ea Mon Sep 17 00:00:00 2001 From: Mathias Klette Date: Fri, 16 Sep 2011 19:40:18 +0200 Subject: [PATCH] fix: upstream branch must be treeish --- debian_build.py | 4 ++++ lib/git_helper.py | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/debian_build.py b/debian_build.py index 6feafd7..1ca7070 100755 --- a/debian_build.py +++ b/debian_build.py @@ -276,6 +276,10 @@ if __name__ == '__main__': logger.error('Could not determine GIT_UPSTREAM_BRANCH') exit_error() + # git-buildpackage uses only treeish object in v0.5.10, + # let's fetch it correctly: + GIT_UPSTREAM_BRANCH = git_helper.git_get_treeish(GIT_UPSTREAM_BRANCH) + repo = git.repo.Repo() if GIT_DEBIAN_BRANCH != 'master': diff --git a/lib/git_helper.py b/lib/git_helper.py index 1ece9f8..9312a4c 100644 --- a/lib/git_helper.py +++ b/lib/git_helper.py @@ -244,4 +244,46 @@ def git_commit(message, paths=("-a",)): logger.debug('changes for %s commited' %(' '.join(paths))) return True +def git_get_treeish(refname): + """ + Return treeish reference as a string for any valid refspec. + """ + cmd = [ + GIT, + 'show --oneline', + '%s' % refname, + '|awk \'{print $1\}\'' + ] + cmdobj = subprocess.Popen( + cmd, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + shell=False, + env={'':''}, + cwd=os.getcwd(), + close_fds=True + ) + + logger.debug( + 'calling "%s" ' %(' '.join(cmd)) + ) + ret = cmdobj.wait() + if ret: + error_str = cmdobj.stderr.read() + if not error_str: + error_str = cmdobj.stdout.read() + if not error_str: + error_str = 'No Error Msg found' + logger.error( + '%s returned with %s. Output was: %s' + %(' '.join(cmd), ret, error_str) + ) + return None + else: + stdout_str = cmdobj.stdout.read() + logger.debug( + 'found treeish "%s" for refspec "%s"' % (refname, stdout_str) + ) + return stdout_str + # vim: autoindent smartindent tabstop=4 expandtab shiftwidth=4 softtabstop=4 nu enc=utf-8 cinwords=if,elif,else,for,while,try,except,finally,def,class -- 2.39.5