Rather than parsing the log output, just ask git to give us the information we want. ---
This mimics the current behavior, but it could be argued that the committer date, rather than the author date would be a better fit here. If that's desired, it's trivial to change %ad to %cd in the format string.
setup.py | 12 +++--------- 1 files changed, 3 insertions(+), 9 deletions(-)
diff --git a/setup.py b/setup.py index 88b2bc8..720224f 100644 --- a/setup.py +++ b/setup.py @@ -38,16 +38,10 @@ def gen_build_version(): builddate = time.asctime() if os.path.exists(".git"): # for builds coming from git, include the date of the last commit - cmd = subprocess.Popen(["/usr/bin/git","log","-1"],stdout=subprocess.PIPE) + cmd = subprocess.Popen(["/usr/bin/git","log","--format=%H%n%ad","-1"],stdout=subprocess.PIPE) data = cmd.communicate()[0].strip() - for line in data.split("\n"): - if line.startswith("commit"): - tokens = line.split(" ",1) - gitstamp = tokens[1].strip() - if line.startswith("Date:"): - tokens = line.split(":",1) - gitdate = tokens[1].strip() - break + if cmd.returncode == 0: + gitstamp, gitdate = data.split("\n") data = { "gitdate" : gitdate, "gitstamp" : gitstamp,
I wrote:
This mimics the current behavior, but it could be argued that the committer date, rather than the author date would be a better fit here. If that's desired, it's trivial to change %ad to %cd in the format string.
I also meant to suggest that an abbreviated hash might be nicer here, rather than the full 40-character sha1. Using %h in place of %H will achieve that.
On Sun, 20 Mar 2011 17:36:10 -0400, Todd Zullinger tmz@pobox.com wrote:
Rather than parsing the log output, just ask git to give us the information we want.
Manually applied because the email got garbled (by mailman I think).
Scott Henson wrote:
Manually applied because the email got garbled (by mailman I think).
Thanks. Though the patch came through fine for me. I just applied it with git am to test. So we can't pin this one on mailman. ;)
On Mon, 21 Mar 2011 17:06:19 -0400, Todd Zullinger tmz@pobox.com wrote:
Scott Henson wrote:
Manually applied because the email got garbled (by mailman I think).
Thanks. Though the patch came through fine for me. I just applied it with git am to test. So we can't pin this one on mailman. ;)
Then I'll have to have a look at notmuch/emacs. Doesn't really surprise me, I've been having that issue a lot as of late.
cobbler-devel@lists.fedorahosted.org