git-meta
A less than freeform way of storing some metadata in git commit objects.
What is this?
It's a way to store data along with a git commit object that is less freeform than something like "Close gh-11" but more freeform than having to add extra data structures to the git commit object.
It is also completely compatible for people wanting to read this metadata directly from an interface like git-log or github.
Syntax
In your git commit, you just need a few yaml-like structures like the following:
foo: bar
Signed-Off-By: Me!
Currently the only way of setting this metadata is writing the YAML by hand in the commit message. The Regex that i use (no longer a YAML parser for simplification) will catch all non-whitespace before each colon and the rest of the line afterwards.
The change where I have removed YAML means that we can no longer have hierarchal data structures, which both makes it easier to use with small amounts of data but harder to use with larger amounts of data.
If you want to re-implement this in another language, I ask that you please use the following regular expression to parse the git messages (we make a call to the git-cat-file
utility to get the messages):
/(\S+):\s*(.+)$/
Usage
Getting
You can use git-meta get [ sha | ref ]
to return all keys and values. [ sha | ref ]
can be anything that git-cat-file
will understand.
You can also use git-meta get [ sha | ref ] --get foo
to return "bar" from the earlier example. Will return an empty string if nothing is returned for that piece of metadata.
I am aware that this is open to shenanigans including something like git-meta get 'HEAD && echo "foo: baz"'
but really, I don't care. I don't foresee this being used anywhere that would be a problem - ie i guess it will mostly be used by a person wanting the data, or a computer processing the data with other values like commit shas or refs that it has deduced itself.
Setting
I have not yet got this sorted. A solution will be forthcoming in a compatible release, but at the moment i have not yet thought enough about how it's going to be implemented.
Installation
As easy as gem install git-meta
(as long as you have gemcutter as a source)
Requirements
Only shoulda
and mocra
for testing. I have tried to keep this as lean as possible.
Copyright
Copyright (c) 2009 Sam Elliott. See LICENSE for details. (MIT Licence)