jekyll-git_metadata 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +2 -0
- data/README.md +2 -0
- data/lib/jekyll/git_metadata/generator.rb +4 -6
- data/lib/jekyll/git_metadata/version.rb +1 -1
- data/test/test_git_metadata.rb +29 -28
- data/test/test_repo/_posts/2014-07-14-welcome-to-jekyll.markdown +2 -0
- data/test/test_repo/about.md +2 -0
- data/test/test_repo/dot_git/COMMIT_EDITMSG +14 -1
- data/test/test_repo/dot_git/index +0 -0
- data/test/test_repo/dot_git/logs/HEAD +1 -0
- data/test/test_repo/dot_git/logs/refs/heads/master +1 -0
- data/test/test_repo/dot_git/refs/heads/master +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f3014ab1dbe6939519a268f017994fc5402dcf78
|
4
|
+
data.tar.gz: 8ac69a4517a11d9376d208a432c49779dec58415
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aedc7a9c9eb90b13a2f40376f6ff75cb7fef94f1589a0eba33b505fcd2e0774838aae9ddc8f24d9aac9118ad652253b5be59ecd6d1a208d86ffae25dc34939a5
|
7
|
+
data.tar.gz: a48999e28a7a543206258ea9f87b441640ca49be840927c60ee97d7e0fd17edd8cf0f8ea21a22e60da1df42ee51cde28f0b69e4476275302642e778e905a5b3c
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
[](https://travis-ci.org/ivantsepp/jekyll-git_metadata)
|
2
|
+
|
1
3
|
# Jekyll::GitMetadata
|
2
4
|
|
3
5
|
Expose Git metadata to Jekyll. Just like how Github exposes [repository metadata](https://help.github.com/articles/repository-metadata-on-github-pages), this plugin will expose information about your git repository for your templates. For example:
|
@@ -73,11 +73,8 @@ module Jekyll
|
|
73
73
|
end
|
74
74
|
|
75
75
|
def commit(sha)
|
76
|
-
result = %x{ git show --format=fuller -
|
77
|
-
long_sha, author_name, author_email, author_date, commit_name, commit_email, commit_date, message = result
|
78
|
-
.scan(/commit (.*)\nAuthor:(.*)<(.*)>\nAuthorDate:(.*)\nCommit:(.*)<(.*)>\nCommitDate:(.*)\n\n(.*)/)
|
79
|
-
.first
|
80
|
-
.map(&:strip)
|
76
|
+
result = %x{ git show --format=fuller --name-only #{sha} }
|
77
|
+
long_sha, author_name, author_email, author_date, commit_name, commit_email, commit_date, message, changed_files = result.scan(/commit (.*)\nAuthor:(.*)<(.*)>\nAuthorDate:(.*)\nCommit:(.*)<(.*)>\nCommitDate:(.*)\n\n((?:\s\s\s\s[^\r\n]*\n)*)\n(.*)/m).first.map(&:strip)
|
81
78
|
{
|
82
79
|
'short_sha' => sha,
|
83
80
|
'long_sha' => long_sha,
|
@@ -87,7 +84,8 @@ module Jekyll
|
|
87
84
|
'commit_name' => commit_name,
|
88
85
|
'commit_email' => commit_email,
|
89
86
|
'commit_date' => commit_date,
|
90
|
-
'message' => message
|
87
|
+
'message' => message.gsub(/ /, ''),
|
88
|
+
'changed_files' => changed_files.split("\n")
|
91
89
|
}
|
92
90
|
end
|
93
91
|
|
data/test/test_git_metadata.rb
CHANGED
@@ -33,14 +33,14 @@ class Jekyll::GitMetadataTest < Minitest::Test
|
|
33
33
|
end
|
34
34
|
|
35
35
|
should 'have correct totals count' do
|
36
|
-
assert_equal
|
37
|
-
assert_equal
|
36
|
+
assert_equal 6, @site_data['total_commits']
|
37
|
+
assert_equal 674, @site_data['total_additions']
|
38
38
|
assert_equal 11, @site_data['total_subtractions']
|
39
39
|
end
|
40
40
|
|
41
41
|
should 'have correct authors data' do
|
42
42
|
assert_equal 2, @site_data['authors'].count
|
43
|
-
assert @site_data['authors'].include?({"commits"=>
|
43
|
+
assert @site_data['authors'].include?({"commits"=>5, "name"=>"Ivan Tse", "email"=>"ivan.tse1@gmail.com"})
|
44
44
|
assert @site_data['authors'].include?({"commits"=>1, "name"=>"LeBron James", "email"=>"lbj@example.com"})
|
45
45
|
end
|
46
46
|
|
@@ -57,15 +57,16 @@ class Jekyll::GitMetadataTest < Minitest::Test
|
|
57
57
|
end
|
58
58
|
|
59
59
|
should 'have correct last commit data' do
|
60
|
-
assert_equal '
|
61
|
-
assert_equal '
|
62
|
-
assert_equal '
|
63
|
-
assert_equal '
|
64
|
-
assert_equal '
|
60
|
+
assert_equal '2410dac', @site_data['last_commit']['short_sha']
|
61
|
+
assert_equal '2410dac67d5dc5f47a6d790edfed4f65acd9477b', @site_data['last_commit']['long_sha']
|
62
|
+
assert_equal 'Ivan Tse', @site_data['last_commit']['author_name']
|
63
|
+
assert_equal 'ivan.tse1@gmail.com', @site_data['last_commit']['author_email']
|
64
|
+
assert_equal 'Sun Feb 12 01:00:51 2017 -0500', @site_data['last_commit']['author_date']
|
65
65
|
assert_equal 'Ivan Tse', @site_data['last_commit']['commit_name']
|
66
66
|
assert_equal 'ivan.tse1@gmail.com', @site_data['last_commit']['commit_email']
|
67
|
-
assert_equal '
|
68
|
-
assert_equal
|
67
|
+
assert_equal 'Sun Feb 12 01:00:51 2017 -0500', @site_data['last_commit']['commit_date']
|
68
|
+
assert_equal "This is a long commit message\n\nAs you can tell this commit message will span several lines long because\nI need to test long comit messages too!", @site_data['last_commit']['message']
|
69
|
+
assert_equal ["_posts/2014-07-14-welcome-to-jekyll.markdown", "about.md"], @site_data['last_commit']['changed_files']
|
69
70
|
end
|
70
71
|
end
|
71
72
|
|
@@ -76,14 +77,14 @@ class Jekyll::GitMetadataTest < Minitest::Test
|
|
76
77
|
end
|
77
78
|
|
78
79
|
should 'have correct totals count' do
|
79
|
-
assert_equal
|
80
|
-
assert_equal
|
80
|
+
assert_equal 4, @page_data['total_commits']
|
81
|
+
assert_equal 16, @page_data['total_additions']
|
81
82
|
assert_equal 5, @page_data['total_subtractions']
|
82
83
|
end
|
83
84
|
|
84
85
|
should 'have correct authors data' do
|
85
86
|
assert_equal 2, @page_data['authors'].count
|
86
|
-
assert @page_data['authors'].include?({"commits"=>
|
87
|
+
assert @page_data['authors'].include?({"commits"=>3, "name"=>"Ivan Tse", "email"=>"ivan.tse1@gmail.com"})
|
87
88
|
assert @page_data['authors'].include?({"commits"=>1, "name"=>"LeBron James", "email"=>"lbj@example.com"})
|
88
89
|
end
|
89
90
|
|
@@ -100,15 +101,15 @@ class Jekyll::GitMetadataTest < Minitest::Test
|
|
100
101
|
end
|
101
102
|
|
102
103
|
should 'have correct last commit data' do
|
103
|
-
assert_equal '
|
104
|
-
assert_equal '
|
105
|
-
assert_equal '
|
106
|
-
assert_equal '
|
107
|
-
assert_equal '
|
104
|
+
assert_equal '2410dac', @page_data['last_commit']['short_sha']
|
105
|
+
assert_equal '2410dac67d5dc5f47a6d790edfed4f65acd9477b', @page_data['last_commit']['long_sha']
|
106
|
+
assert_equal 'Ivan Tse', @page_data['last_commit']['author_name']
|
107
|
+
assert_equal 'ivan.tse1@gmail.com', @page_data['last_commit']['author_email']
|
108
|
+
assert_equal 'Sun Feb 12 01:00:51 2017 -0500', @page_data['last_commit']['author_date']
|
108
109
|
assert_equal 'Ivan Tse', @page_data['last_commit']['commit_name']
|
109
110
|
assert_equal 'ivan.tse1@gmail.com', @page_data['last_commit']['commit_email']
|
110
|
-
assert_equal '
|
111
|
-
assert_equal
|
111
|
+
assert_equal 'Sun Feb 12 01:00:51 2017 -0500', @page_data['last_commit']['commit_date']
|
112
|
+
assert_equal "This is a long commit message\n\nAs you can tell this commit message will span several lines long because\nI need to test long comit messages too!", @page_data['last_commit']['message']
|
112
113
|
end
|
113
114
|
end
|
114
115
|
|
@@ -119,14 +120,14 @@ class Jekyll::GitMetadataTest < Minitest::Test
|
|
119
120
|
end
|
120
121
|
|
121
122
|
should 'have correct totals count' do
|
122
|
-
assert_equal
|
123
|
-
assert_equal
|
123
|
+
assert_equal 3, @page_data['total_commits']
|
124
|
+
assert_equal 30, @page_data['total_additions']
|
124
125
|
assert_equal 0, @page_data['total_subtractions']
|
125
126
|
end
|
126
127
|
|
127
128
|
should 'have correct authors data' do
|
128
129
|
assert_equal 1, @page_data['authors'].count
|
129
|
-
assert @page_data['authors'].include?({"commits"=>
|
130
|
+
assert @page_data['authors'].include?({"commits"=>3, "name"=>"Ivan Tse", "email"=>"ivan.tse1@gmail.com"})
|
130
131
|
end
|
131
132
|
|
132
133
|
should 'have correct first commit data' do
|
@@ -142,15 +143,15 @@ class Jekyll::GitMetadataTest < Minitest::Test
|
|
142
143
|
end
|
143
144
|
|
144
145
|
should 'have correct last commit data' do
|
145
|
-
assert_equal '
|
146
|
-
assert_equal '
|
146
|
+
assert_equal '2410dac', @page_data['last_commit']['short_sha']
|
147
|
+
assert_equal '2410dac67d5dc5f47a6d790edfed4f65acd9477b', @page_data['last_commit']['long_sha']
|
147
148
|
assert_equal 'Ivan Tse', @page_data['last_commit']['author_name']
|
148
149
|
assert_equal 'ivan.tse1@gmail.com', @page_data['last_commit']['author_email']
|
149
|
-
assert_equal '
|
150
|
+
assert_equal 'Sun Feb 12 01:00:51 2017 -0500', @page_data['last_commit']['author_date']
|
150
151
|
assert_equal 'Ivan Tse', @page_data['last_commit']['commit_name']
|
151
152
|
assert_equal 'ivan.tse1@gmail.com', @page_data['last_commit']['commit_email']
|
152
|
-
assert_equal '
|
153
|
-
assert_equal
|
153
|
+
assert_equal 'Sun Feb 12 01:00:51 2017 -0500', @page_data['last_commit']['commit_date']
|
154
|
+
assert_equal "This is a long commit message\n\nAs you can tell this commit message will span several lines long because\nI need to test long comit messages too!", @page_data['last_commit']['message']
|
154
155
|
end
|
155
156
|
end
|
156
157
|
|
@@ -20,6 +20,8 @@ print_hi('Tom')
|
|
20
20
|
|
21
21
|
Check out the [Jekyll docs][jekyll] for more info on how to get the most out of Jekyll. File all bugs/feature requests at [Jekyll's GitHub repo][jekyll-gh].
|
22
22
|
|
23
|
+
Appending to a post.
|
24
|
+
|
23
25
|
---
|
24
26
|
|
25
27
|
I hope Jekyll::GitMetadata will be a useful plugin!
|
data/test/test_repo/about.md
CHANGED
@@ -1 +1,14 @@
|
|
1
|
-
|
1
|
+
This is a long commit message
|
2
|
+
|
3
|
+
As you can tell this commit message will span several lines long because
|
4
|
+
I need to test long comit messages too!
|
5
|
+
# Please enter the commit message for your changes. Lines starting
|
6
|
+
# with '#' will be ignored, and an empty message aborts the commit.
|
7
|
+
# On branch master
|
8
|
+
# Changes to be committed:
|
9
|
+
# modified: _posts/2014-07-14-welcome-to-jekyll.markdown
|
10
|
+
# modified: about.md
|
11
|
+
#
|
12
|
+
# Untracked files:
|
13
|
+
# dot_git/
|
14
|
+
#
|
Binary file
|
@@ -3,3 +3,4 @@
|
|
3
3
|
da077394cb4d5bf7ffac527dbfc652ec0592b423 9e00340e45d33e52bb16100f1b613a36f82f9c57 Ivan Tse <ivan.tse1@gmail.com> 1405318112 -0400 commit: Change about page text
|
4
4
|
9e00340e45d33e52bb16100f1b613a36f82f9c57 8365a44c640d5c7cafc8788607a274dfd91b89bb Ivan Tse <ivan.tse1@gmail.com> 1405318203 -0400 commit: Edit first post
|
5
5
|
8365a44c640d5c7cafc8788607a274dfd91b89bb 25d62f6feeb7190483f81564f4a76c1ec33d5118 Ivan Tse <ivan.tse1@gmail.com> 1405318351 -0400 commit: Be more friendly
|
6
|
+
25d62f6feeb7190483f81564f4a76c1ec33d5118 2410dac67d5dc5f47a6d790edfed4f65acd9477b Ivan Tse <ivan.tse1@gmail.com> 1486879251 -0500 commit: This is a long commit message
|
@@ -3,3 +3,4 @@
|
|
3
3
|
da077394cb4d5bf7ffac527dbfc652ec0592b423 9e00340e45d33e52bb16100f1b613a36f82f9c57 Ivan Tse <ivan.tse1@gmail.com> 1405318112 -0400 commit: Change about page text
|
4
4
|
9e00340e45d33e52bb16100f1b613a36f82f9c57 8365a44c640d5c7cafc8788607a274dfd91b89bb Ivan Tse <ivan.tse1@gmail.com> 1405318203 -0400 commit: Edit first post
|
5
5
|
8365a44c640d5c7cafc8788607a274dfd91b89bb 25d62f6feeb7190483f81564f4a76c1ec33d5118 Ivan Tse <ivan.tse1@gmail.com> 1405318351 -0400 commit: Be more friendly
|
6
|
+
25d62f6feeb7190483f81564f4a76c1ec33d5118 2410dac67d5dc5f47a6d790edfed4f65acd9477b Ivan Tse <ivan.tse1@gmail.com> 1486879251 -0500 commit: This is a long commit message
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
2410dac67d5dc5f47a6d790edfed4f65acd9477b
|