Allows user to specify commit/tag in source block header. If :dir is specified, ob-with-commit.el
will try to checkout a commit in the specified directory. If not, it will test current directory for a git repo.
The objective is to make it easier to use org src blocks for reproducible research, where the version of the script can be easily specified.
Example:
/path/to/code/script
This is a series of hacks, relying heavily on shell-command-to-string, put together very quickly. This is meant to be a proof of concept, and it works for the cases that I tested. Feedback welcome!
- [ ] handle “remote” vc commands gracefully
- [ ] Automagically detect vc, abstract away checkout commands
- [ ] Make dir accept remote paths
(load-file "ob-with-commit.el")
Create a test folder with two commits.
rm -rf versioned/ > /dev/null
mkdir -p versioned/
touch ./versioned/versioned.py
cd ./versioned/
echo "print('This is version 1')" > versioned.py
git init
git add versioned.py
git commit -m "version 1"
git tag -a v0.1 -m "first tag"
echo "print('This is version 2')" > versioned.py
git add versioned.py
git commit -m "version 2"
git tag -a v0.2 -m "first tag"
The test folder is ./versioned/, with two tags. It is currently on master.
git tag
v0.1 v0.2
Running the python script ./versioned/versioned.py
python versioned.py
Now set it to an older version
python versioned.py
… and back to the the latest version
python versioned.py