Skip to content
Snippets Groups Projects
Commit b1e51c76 authored by LINJIAO email's avatar LINJIAO email
Browse files

Refs #17237. use cmake macro for git_rev and detect no-change

parent 249f6f10
No related branches found
No related tags found
No related merge requests found
# -*- Python -*- # -*- Python -*-
version = "@VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@" version = "@VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@"
git_rev = "@MtdVersion_WC_LAST_CHANGED_SHA_LONG@"
import subprocess as sp, shlex, os import subprocess as sp, shlex, os
git_rev = sp.check_output("git rev-parse HEAD".split(),
cwd="@CMAKE_SOURCE_DIR@").strip()
# checkout recipe def main():
if not os.path.exists('conda-recipes'): # checkout recipe
cmd = 'git clone git@github.com:mantidproject/conda-recipes' if not os.path.exists('conda-recipes'):
sp.check_call(cmd.split()) cmd = 'git clone git@github.com:mantidproject/conda-recipes'
else: sp.check_call(cmd.split())
cmd = 'git pull' else:
sp.check_call(cmd.split(), cwd='conda-recipes') cmd = 'git pull'
sp.check_call(cmd.split(), cwd='conda-recipes')
# change framework meta.yaml # change framework meta.yaml
path = 'conda-recipes/framework/meta.yaml' path = 'conda-recipes/framework/meta.yaml'
header = [] header = []
header.append('{% set version = "' + '%s' % version + '" %}') header.append('{% set version = "' + '%s' % version + '" %}')
header.append('{% set git_rev = "' + '%s' % git_rev + '" %}') header.append('{% set git_rev = "' + '%s' % git_rev + '" %}')
body = open(path, 'rt').read().split('\n') content = open(path, 'rt').read().split('\n')
body = body[2:] old_header = content[:2]
open(path, 'wt').write('\n'.join(header+body)) body = content[2:]
# if nothing changed just exit
if header == old_header:
print "Nothing changed. Skipping."
return
open(path, 'wt').write('\n'.join(header+body))
# commit # commit
cmd = 'git commit -m "update version and git_rev" framework/meta.yaml' cmd = 'git commit -m "update version and git_rev" framework/meta.yaml'
sp.check_call(shlex.split(cmd), cwd="conda-recipes") sp.check_call(shlex.split(cmd), cwd="conda-recipes")
# push # push
cmd = 'git push' cmd = 'git push'
sp.check_call(cmd.split(), cwd="conda-recipes") sp.check_call(cmd.split(), cwd="conda-recipes")
return
if __name__ == '__main__': main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment