From: Eric S. Raymond Date: Wed, 25 Sep 2013 11:27:55 +0000 (-0400) Subject: A useful default for the -b option. X-Git-Tag: 1.10~1 X-Git-Url: http://thyrsus.com/gitweb/?a=commitdiff_plain;h=e5eb84362c5ec39c448502d7449b69a3c6daceb1;p=coverity-submit.git A useful default for the -b option. --- diff --git a/NEWS b/NEWS index 030b73a..0675c0b 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,7 @@ 1.10 @ The -t option dow defaults to a build timestamp. + In a git repo, the -b option now defaults to `git describe HEAD`. 1.9 @ 2013-05-23 The -v option now preserves the build log for diagnostic purposes. diff --git a/coverity-submit b/coverity-submit index b6e1ed2..b8597f4 100755 --- a/coverity-submit +++ b/coverity-submit @@ -4,10 +4,18 @@ # # By Eric S. Raymond, May 2012. BSD terms apply. # -import os, sys, ConfigParser, getopt, tempfile, shutil, datetime +import os, sys, ConfigParser, getopt, tempfile, shutil, datetime, commands version = "1.9" +def commit_id(): + "If we're in a repository directory, try to extract a commit description." + if os.path.exists(".git"): + (status, output) = commands.getstatusoutput("git describe HEAD") + if status == 0: + return output + return None + if __name__ == '__main__': name = email = project = token = url = None @@ -37,7 +45,7 @@ if __name__ == '__main__': # Deduce what project and directory to operate on (and go there). noexec = False verbose = False - build_version = None + build_version = commit_id() description = datetime.datetime.now().isoformat() (opts, args) = getopt.getopt(sys.argv[1:], "b:nt:v") for (opt, arg) in opts: diff --git a/coverity-submit.xml b/coverity-submit.xml index e83e368..6ede095 100644 --- a/coverity-submit.xml +++ b/coverity-submit.xml @@ -120,7 +120,10 @@ build-log.txt from the run to your working directory. The option specifies an arbitrary build version to associate with the submission. A repository commit level -would be a good thing to use for this. +would be a good thing to use for this. If coverity-submit is run +at the top level of a version-control repository, the build version may +default to a description of the head commit; presently this feature +is supported for git only. The option specifies an arbitrary project tag or description to associate with the submission. This text is