Skip to content

Instantly share code, notes, and snippets.

@robintw
Created September 9, 2016 20:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robintw/885b8a9a6638170cd880cc69a12bd340 to your computer and use it in GitHub Desktop.
Save robintw/885b8a9a6638170cd880cc69a12bd340 to your computer and use it in GitHub Desktop.
Example `reproduce` command for recipy
import sys
from tinydb import where
from recipyCommon.utils import open_or_create_db
id_string = sys.argv[1]
db = open_or_create_db()
results = db.search(where('unique_id').matches('%s.*' % id_string))[0]
# Deal with the fact that the repo is cloned to a different place
# so we need to change the path to the script that we call
results['scriptname'] = results['script'].replace(results['gitrepo'], '')
if results['scriptname'].startswith('/'):
results['scriptname'] = results['scriptname'][1:]
script = """mkdir reproduction1
cd reproduction1
git clone {gitorigin} .
git checkout {gitcommit}
git apply << EOF
{diff}
EOF
{command} {scriptname} {command_args}
""".format(**results)
print(script)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment