]> Frank Brehm's Git Trees - profitbricks/jenkins-build-scripts.git/commitdiff
fix: upstream branch must be treeish
authorMathias Klette <mathias.klette@profitbricks.com>
Fri, 16 Sep 2011 17:40:18 +0000 (19:40 +0200)
committerMathias Klette <mathias.klette@profitbricks.com>
Fri, 16 Sep 2011 17:40:18 +0000 (19:40 +0200)
debian_build.py
lib/git_helper.py

index 6feafd76756d70a42b170727550f9fbb57cfe2cc..1ca707089e9ff82e9cb0158c1ef94e88f3f5f6cd 100755 (executable)
@@ -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':
index 1ece9f86ae9c4e8ea5e3f4d705c93d67de89acfa..9312a4cac8f248f971b5fbc1c361c866bdba673a 100644 (file)
@@ -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