rack-git-revision 1.0.1 → 1.0.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/README.md +11 -7
- data/lib/rack-git-revision.rb +10 -2
- data/lib/rack-git-revision/version.rb +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: 4fbc8451311989faccddc58850b4f8edc1143045
|
4
|
+
data.tar.gz: 652161bc24bc64e0986c6df9ac5eb855660fe5de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3981208addd2070fa523a24d0dbdbde7eb9a30397402e8d6e68bdf953d0da8c7a656101bdc917efd610189378cf738ea1b56b01404b3102b06eee7b4ef44526
|
7
|
+
data.tar.gz: 952697a83c17ecb1d1080abab1a7ee3005037d54e40479e4c6dedec003e8d110d3c679c79d89f4874754b5054f69dadffeda1206a1159b1d10fb28831396e71b
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Rack::
|
1
|
+
# Rack::Git::Revision
|
2
2
|
|
3
3
|
Rack::GitRevision is a git revision http interface for rack applications.
|
4
4
|
|
@@ -21,17 +21,21 @@ $ curl localhost:3000/dev/revision
|
|
21
21
|
=> 7424ba3207725cd1321f06949330b5f531f9af72
|
22
22
|
```
|
23
23
|
|
24
|
-
|
24
|
+
|
25
25
|
|
26
26
|
### Change Url path
|
27
27
|
```
|
28
28
|
use Rack::GitRevision, path: '/git_revision'
|
29
29
|
```
|
30
30
|
|
31
|
-
|
31
|
+
|
32
|
+
### for capistrano3 (working on Rails)
|
32
33
|
|
33
34
|
```
|
34
|
-
use Rack::GitRevision, {
|
35
|
+
use Rack::GitRevision, {
|
36
|
+
git_path: Rails.env.production? ? File.expand_path('../../repo/.git', __FILE__) : nil
|
37
|
+
}
|
38
|
+
run Rails.application
|
35
39
|
```
|
36
40
|
|
37
41
|
|
@@ -39,14 +43,14 @@ use Rack::GitRevision, { revision: lambda { File.read('./REVISION').strip } }
|
|
39
43
|
|
40
44
|
#### Defaults
|
41
45
|
```
|
42
|
-
options = {
|
46
|
+
@options = {
|
43
47
|
path: '/dev/revision',
|
44
|
-
|
48
|
+
git_path: './.git',
|
49
|
+
revision: lambda { |git_path| `git log -1 --pretty="format:%H"` },
|
45
50
|
body: lambda { |revision| revision },
|
46
51
|
status: lambda { |revision| revision ? 200 : 404 },
|
47
52
|
headers: lambda { |revision| { 'Content-Type' => 'text/plain' }
|
48
53
|
}
|
49
|
-
|
50
54
|
```
|
51
55
|
|
52
56
|
|
data/lib/rack-git-revision.rb
CHANGED
@@ -6,7 +6,14 @@ module Rack
|
|
6
6
|
@app = app
|
7
7
|
@options = {
|
8
8
|
path: '/dev/revision',
|
9
|
-
|
9
|
+
git_path: './.git',
|
10
|
+
revision: lambda { |git_path|
|
11
|
+
if git_path
|
12
|
+
`git --git-dir #{git_path} log -1 --pretty="format:%H"`
|
13
|
+
else
|
14
|
+
`git log -1 --pretty="format:%H"`
|
15
|
+
end
|
16
|
+
},
|
10
17
|
body: lambda { |revision| revision },
|
11
18
|
status: lambda { |revision| revision ? 200 : 404 },
|
12
19
|
headers: lambda { |revision| { 'Content-Type' => 'text/plain' } },
|
@@ -15,7 +22,8 @@ module Rack
|
|
15
22
|
|
16
23
|
def call(env)
|
17
24
|
if env['PATH_INFO'] == @options[:path]
|
18
|
-
|
25
|
+
git_path = @options[:git_path]
|
26
|
+
revision = @options[:revision].call(git_path) rescue nil
|
19
27
|
body = [@options[:body].call(revision) || 'not found']
|
20
28
|
status = @options[:status].call(revision)
|
21
29
|
headers = @options[:headers].call(revision)
|