jenkins-bot has submitted this change and it was merged.

Change subject: Generate a gitinfo.json to be included in tarballs
......................................................................


Generate a gitinfo.json to be included in tarballs

Bug: T122769
Change-Id: I4573f6c9ce3f0e95bfe447c6396d0aa59a0d3ee3
---
M nightly.py
1 file changed, 20 insertions(+), 0 deletions(-)

Approvals:
  Legoktm: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/nightly.py b/nightly.py
index 072b16e..84b128f 100644
--- a/nightly.py
+++ b/nightly.py
@@ -183,6 +183,26 @@
                 except subprocess.CalledProcessError:
                     logging.error(traceback.format_exc())
                     logging.error('composer install failed')
+            # Create gitinfo.json to be read/displayed by Special:Version
+            git_info = {}
+            with open('.git/HEAD') as f_head:
+                head = f_head.read()
+            if head.startswith('ref:'):
+                head = head[5:]  # Strip 'ref :'
+            git_info['head'] = head
+            # Get the SHA-1
+            git_info['headSHA1'] = self.shell_exec(['git', 'rev-parse', 
'HEAD'])
+            git_info['headCommitDate'] = self.shell_exec(['git', 'show', '-s', 
'--format=format:%ct', 'HEAD'])
+            if head.startswith('refs/heads'):
+                branch = head.split('/')[-1]
+            else:
+                branch = head
+            git_info['branch'] = branch
+            git_info['remoteURL'] = self.GIT_URL % ext
+            with open('gitinfo.json', 'w') as f:
+                json.dump(git_info, f)
+
+            # TODO: Stop writing this file now that we have gitinfo.json
             # Create a 'version' file with basic info about the tarball
             with open('version', 'w') as f:
                 f.write('%s: %s\n' % (ext, branch))

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I4573f6c9ce3f0e95bfe447c6396d0aa59a0d3ee3
Gerrit-PatchSet: 2
Gerrit-Project: labs/tools/extdist
Gerrit-Branch: master
Gerrit-Owner: Legoktm <legoktm.wikipe...@gmail.com>
Gerrit-Reviewer: Legoktm <legoktm.wikipe...@gmail.com>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to