git-meta 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +21 -0
- data/LICENSE +20 -0
- data/README.md +45 -0
- data/Rakefile +21 -0
- data/VERSION +1 -0
- data/bin/git-meta +51 -0
- metadata +66 -0
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Sam Elliott
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
git-meta
|
2
|
+
========
|
3
|
+
A less than freeform way of storing some metadata in git commit objects.
|
4
|
+
|
5
|
+
What is this?
|
6
|
+
-------------
|
7
|
+
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.
|
8
|
+
|
9
|
+
It is also completely compatible for people wanting to read this metadata directly from an interface like git-log or github.
|
10
|
+
|
11
|
+
Syntax
|
12
|
+
------
|
13
|
+
|
14
|
+
In your git commit, you just need a section that looks something like the following:
|
15
|
+
|
16
|
+
---git-meta---
|
17
|
+
foo:
|
18
|
+
bar: "baz"
|
19
|
+
---git-meta---
|
20
|
+
|
21
|
+
This is a YAML formatted block. Currently the only way of setting this metadata is writing the YAML by hand in the commit message.
|
22
|
+
|
23
|
+
Usage
|
24
|
+
=====
|
25
|
+
|
26
|
+
Querying
|
27
|
+
--------
|
28
|
+
|
29
|
+
You can use `git-meta [sha|ref] --get-all` to return just the YAML-block.
|
30
|
+
|
31
|
+
You can also use `git-meta [sha|ref] --get foo.bar` to return "baz" from the earlier example. Will return an empty string if nothing is returned for that piece of metadata.
|
32
|
+
|
33
|
+
If you were to specify just `--get foo` then the underlying YAML would be returned (in this case `bar: "baz"`).
|
34
|
+
|
35
|
+
Storing
|
36
|
+
-------
|
37
|
+
|
38
|
+
I have not yet got this sorted. I need to think a bit more about this.
|
39
|
+
|
40
|
+
I originally thought i could use `./.git/COMMIT\_EDIT\_MSG` but it turns out that is overwritten just before every commit. Whack me an email or a github message if you want to help with this feature, or have an idea for implementation.
|
41
|
+
|
42
|
+
Copyright
|
43
|
+
---------
|
44
|
+
|
45
|
+
Copyright (c) 2009 Sam Elliott. See LICENSE for details. (MIT Licence)
|
data/Rakefile
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "git-meta"
|
8
|
+
gem.summary = %Q{A less than freeform way of storing some metadata in git commit objects.}
|
9
|
+
gem.description = %Q{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.
|
10
|
+
|
11
|
+
It is also completely compatible for people wanting to read this metadata directly from an interface like git-log or github.
|
12
|
+
|
13
|
+
This gem allows reading this data.}
|
14
|
+
gem.email = "sam@lenary.co.uk"
|
15
|
+
gem.homepage = "http://github.com/lenary/git-meta"
|
16
|
+
gem.authors = ["Sam Elliott"]
|
17
|
+
end
|
18
|
+
Jeweler::GemcutterTasks.new
|
19
|
+
rescue LoadError
|
20
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
21
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.0.0
|
data/bin/git-meta
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'optparse'
|
4
|
+
|
5
|
+
options = {:all => false, :sha => ARGV.shift}
|
6
|
+
|
7
|
+
optparser = OptionParser.new do |parser|
|
8
|
+
parser.banner = "Usage: git-meta [sha|ref] [ --get | --get-all ]"
|
9
|
+
|
10
|
+
parser.on('-a', '--get-all',
|
11
|
+
"Retrieves all the keys as YAML data.") do |all|
|
12
|
+
options[:all] = all
|
13
|
+
end
|
14
|
+
|
15
|
+
parser.on('-g', '--get KEY',
|
16
|
+
"Retrives a certain KEY from the git commit object") do |key|
|
17
|
+
options[:keys] = key.split(".")
|
18
|
+
end
|
19
|
+
|
20
|
+
parser.on('-h', '--help',
|
21
|
+
"Returns Usage Notes") do
|
22
|
+
puts parser
|
23
|
+
exit
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
if !options[:sha]
|
29
|
+
puts optparser
|
30
|
+
exit
|
31
|
+
end
|
32
|
+
|
33
|
+
optparser.parse(ARGV)
|
34
|
+
|
35
|
+
git_commit_info, data, output = nil, nil, nil
|
36
|
+
|
37
|
+
IO.popen("git-cat-file -p #{options[:sha]}", 'r') do |git_cat_file|
|
38
|
+
git_commit_info = git_cat_file.read
|
39
|
+
end
|
40
|
+
|
41
|
+
if git_commit_info =~ /^(---git-meta---\s*\n)(.*\n)(^---git-meta---.*\n)/m
|
42
|
+
if options[:keys]
|
43
|
+
data = YAML.load($2)
|
44
|
+
options[:keys].each do |key|
|
45
|
+
data = data.fetch(key, Hash.new(""))
|
46
|
+
end
|
47
|
+
puts data.to_yaml.gsub(/^--- \n?/, '')
|
48
|
+
elsif options[:all]
|
49
|
+
puts $2
|
50
|
+
end
|
51
|
+
end
|
metadata
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: git-meta
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sam Elliott
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-12-15 00:00:00 +01:00
|
13
|
+
default_executable: git-meta
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: |-
|
17
|
+
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.
|
18
|
+
|
19
|
+
It is also completely compatible for people wanting to read this metadata directly from an interface like git-log or github.
|
20
|
+
|
21
|
+
This gem allows reading this data.
|
22
|
+
email: sam@lenary.co.uk
|
23
|
+
executables:
|
24
|
+
- git-meta
|
25
|
+
extensions: []
|
26
|
+
|
27
|
+
extra_rdoc_files:
|
28
|
+
- LICENSE
|
29
|
+
- README.md
|
30
|
+
files:
|
31
|
+
- .gitignore
|
32
|
+
- LICENSE
|
33
|
+
- README.md
|
34
|
+
- Rakefile
|
35
|
+
- VERSION
|
36
|
+
- bin/git-meta
|
37
|
+
has_rdoc: true
|
38
|
+
homepage: http://github.com/lenary/git-meta
|
39
|
+
licenses: []
|
40
|
+
|
41
|
+
post_install_message:
|
42
|
+
rdoc_options:
|
43
|
+
- --charset=UTF-8
|
44
|
+
require_paths:
|
45
|
+
- lib
|
46
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
47
|
+
requirements:
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: "0"
|
51
|
+
version:
|
52
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: "0"
|
57
|
+
version:
|
58
|
+
requirements: []
|
59
|
+
|
60
|
+
rubyforge_project:
|
61
|
+
rubygems_version: 1.3.5
|
62
|
+
signing_key:
|
63
|
+
specification_version: 3
|
64
|
+
summary: A less than freeform way of storing some metadata in git commit objects.
|
65
|
+
test_files: []
|
66
|
+
|