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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7d6bcbff1553989dabdcd512299a3d738385d5c0
4
- data.tar.gz: 3d645efbd21725d8272fac3c0cb9e2cf15d838bc
3
+ metadata.gz: 4fbc8451311989faccddc58850b4f8edc1143045
4
+ data.tar.gz: 652161bc24bc64e0986c6df9ac5eb855660fe5de
5
5
  SHA512:
6
- metadata.gz: e52b5307e78133422952d34eb10d1f867b485db9bc541611f00c1304bedf56748a926542d8b515aa645c03f95227547602e10594bdd655b066cdc581bfc2ce05
7
- data.tar.gz: 6479aee36c5f631f81a61902765aff643062a1eec6eece6f4a169df6a49d5cc137f1a861726a80a6adc7a7bc571ff2ec739dc356bc110013107fe5c55544b090
6
+ metadata.gz: b3981208addd2070fa523a24d0dbdbde7eb9a30397402e8d6e68bdf953d0da8c7a656101bdc917efd610189378cf738ea1b56b01404b3102b06eee7b4ef44526
7
+ data.tar.gz: 952697a83c17ecb1d1080abab1a7ee3005037d54e40479e4c6dedec003e8d110d3c679c79d89f4874754b5054f69dadffeda1206a1159b1d10fb28831396e71b
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Rack::GitRevision
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
- ## Customize Url
24
+
25
25
 
26
26
  ### Change Url path
27
27
  ```
28
28
  use Rack::GitRevision, path: '/git_revision'
29
29
  ```
30
30
 
31
- ### Change how to get revision
31
+
32
+ ### for capistrano3 (working on Rails)
32
33
 
33
34
  ```
34
- use Rack::GitRevision, { revision: lambda { File.read('./REVISION').strip } }
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
- revision: lambda { `git log -1 --pretty="format:%H"` },
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
 
@@ -6,7 +6,14 @@ module Rack
6
6
  @app = app
7
7
  @options = {
8
8
  path: '/dev/revision',
9
- revision: lambda { `git log -1 --pretty="format:%H"` },
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
- revision = @options[:revision].call rescue nil
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)
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  class GitRevision
3
- VERSION = '1.0.1'
3
+ VERSION = '1.0.2'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-git-revision
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - kotohata