Mgrover has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/59138


Change subject: Created python script to git logs
......................................................................

Created python script to git logs

Change-Id: I3c29ac28960c9196a0f7b0c1c634344ca961cb49
---
A python-git-logs/README
A python-git-logs/log_updates.py
2 files changed, 59 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/tools/release 
refs/changes/38/59138/1

diff --git a/python-git-logs/README b/python-git-logs/README
new file mode 100644
index 0000000..95aac36
--- /dev/null
+++ b/python-git-logs/README
@@ -0,0 +1,9 @@
+This is a script to pull the git logs from for a branch.  
+It's really just a fancier way of running 
+'git log --no-merges commitId..> ChangeLogsYYYY-MM-DD'.  
+You can enter a commit Id or press <ENTER> to retrieve the latest stored 
commit Id.
+
+
+Usage:
+  ./log_updates.py
+
diff --git a/python-git-logs/log_updates.py b/python-git-logs/log_updates.py
new file mode 100755
index 0000000..56c804f
--- /dev/null
+++ b/python-git-logs/log_updates.py
@@ -0,0 +1,50 @@
+#!/usr/bin/python
+
+from subprocess import check_output
+from datetime import date
+import re
+
+def info(str):
+   print "[INFO] %s" % str
+
+def get_initial_commit(repodir):
+    the_commit = raw_input('Please enter commit number or <ENTER> for 
last-update: ')
+    if len(the_commit) == 0:
+       the_commit = latest_commit(repodir)
+    else:
+       info('Using %s as the initial commit.' % the_commit)
+    return the_commit
+
+def latest_commit(repodir):
+    info("Aquiring latest commit number...")
+    cmd = ['git','log', '--max-count=1']
+    last_log_output = check_output(cmd)
+    m = re.search('commit\s+([a-z0-9]+).*', last_log_output)
+    last_commit = m.group(1)
+    info('Using the last commit [%s] as the initial commit.' % last_commit)
+    return last_commit
+
+def get_log_since(last_updated, repodir):
+    info("Getting latest delta logs ...")
+    cmd = ['git','log', '--no-merges',"%s.." % last_updated]
+    log = check_output(cmd)
+    return log
+
+def output_change_log(f_name, change_log):
+     info("Writing %s ..." % f_name)
+     hLog = open(f_name, 'w')
+     hLog.write(change_log)
+     hLog.close()
+     info("Done.")
+
+def generate_change_log(repodir):
+    last_updated = get_initial_commit(repodir)
+    change_log = get_log_since(last_updated,repodir)
+
+    f_name = 'ChangeLogs_%s.txt' % date.today().isoformat()
+    output_change_log(f_name, change_log)
+
+
+
+if __name__ == '__main__':
+  generate_change_log('.')

-- 
To view, visit https://gerrit.wikimedia.org/r/59138
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3c29ac28960c9196a0f7b0c1c634344ca961cb49
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/tools/release
Gerrit-Branch: master
Gerrit-Owner: Mgrover <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to