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,
--
1.7.4.1
--
Todd OpenPGP -> KeyID: 0xBEAF0CE3 | URL: www.pobox.com/~tmz/pgp
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When a man says he approves of something in principle, it means he
hasn't the slightest intention of carrying it out in practice.
-- Prince Otto
_______________________________________________
cobbler-devel mailing list
[email protected]
https://fedorahosted.org/mailman/listinfo/cobbler-devel