gurney_client 0.1.3 → 0.2.1
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/Gemfile +1 -0
- data/Gemfile.lock +10 -6
- data/README.md +2 -0
- data/lib/gurney.rb +1 -0
- data/lib/gurney/cli.rb +16 -8
- data/lib/gurney/cli/option_parser.rb +6 -1
- data/lib/gurney/source/ruby_version.rb +27 -0
- data/lib/gurney/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3a6cb4778c8a278c1d91a6eb42c2757b841f830742f760e289d140ca0a8fa67a
|
4
|
+
data.tar.gz: 995c92b582f0b49baa15042fadbc0bec9a3b3c2013ec0610a7f268785de60655
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5dd8b763b8ba1e0a79edaad6bca1ab43b40dc54cfbb1a16648dc020d5ffd2067d529fef5903144c54c12d3ca7018cf540b58ea34ea86e5d9c4a201fd8ee35db6
|
7
|
+
data.tar.gz: 3c910d5fb6ce83e570bd267bcb4a31399c18096f0839090b611f5d3bb8049a58fb29930cd8319acc8e07a837d7355dedac248fa3f8f09cea785d8288734ffed7
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
gurney_client (0.1
|
4
|
+
gurney_client (0.2.1)
|
5
5
|
bundler (< 3)
|
6
6
|
colorize (~> 0.8)
|
7
7
|
git (~> 1.5)
|
@@ -13,14 +13,17 @@ GEM
|
|
13
13
|
byebug (11.0.1)
|
14
14
|
colorize (0.8.1)
|
15
15
|
diff-lcs (1.3)
|
16
|
-
git (1.
|
17
|
-
|
16
|
+
git (1.7.0)
|
17
|
+
rchardet (~> 1.8)
|
18
|
+
httparty (0.17.3)
|
18
19
|
mime-types (~> 3.0)
|
19
20
|
multi_xml (>= 0.5.2)
|
20
|
-
mime-types (3.3)
|
21
|
+
mime-types (3.3.1)
|
21
22
|
mime-types-data (~> 3.2015)
|
22
|
-
mime-types-data (3.
|
23
|
+
mime-types-data (3.2020.0512)
|
23
24
|
multi_xml (0.6.0)
|
25
|
+
rake (13.0.1)
|
26
|
+
rchardet (1.8.0)
|
24
27
|
rspec (3.9.0)
|
25
28
|
rspec-core (~> 3.9.0)
|
26
29
|
rspec-expectations (~> 3.9.0)
|
@@ -41,7 +44,8 @@ PLATFORMS
|
|
41
44
|
DEPENDENCIES
|
42
45
|
byebug
|
43
46
|
gurney_client!
|
47
|
+
rake
|
44
48
|
rspec
|
45
49
|
|
46
50
|
BUNDLED WITH
|
47
|
-
1.
|
51
|
+
2.1.4
|
data/README.md
CHANGED
@@ -17,6 +17,8 @@ Usage: gurney [options]
|
|
17
17
|
Token to be send to the api in the X-AuthToken header
|
18
18
|
-c, --config [CONFIG FILE] Config file to use
|
19
19
|
-h, --hook Run as a git post-receive hook
|
20
|
+
--client-hook
|
21
|
+
Run as a git pre-push hook
|
20
22
|
-p, --project-id [PROJECT ID] Specify project id for api
|
21
23
|
--help
|
22
24
|
Prints this help
|
data/lib/gurney.rb
CHANGED
@@ -4,6 +4,7 @@ require_relative 'gurney/dependency'
|
|
4
4
|
require_relative 'gurney/source/base'
|
5
5
|
require_relative 'gurney/source/yarn'
|
6
6
|
require_relative 'gurney/source/bundler'
|
7
|
+
require_relative 'gurney/source/ruby_version'
|
7
8
|
require_relative 'gurney/api'
|
8
9
|
require_relative 'gurney/cli/option_parser'
|
9
10
|
require_relative 'gurney/cli'
|
data/lib/gurney/cli.rb
CHANGED
@@ -9,13 +9,14 @@ module Gurney
|
|
9
9
|
class CLI
|
10
10
|
|
11
11
|
HOOK_STDIN_REGEX = /(?<old>[0-9a-f]{40}) (?<new>[0-9a-f]{40}) refs\/heads\/(?<ref>\w+)/m
|
12
|
+
CLIENT_HOOK_STDIN_REGEX = /refs\/heads\/(?<ref>\w+) (?<new>[0-9a-f]{40}) refs\/heads\/(?<remote_ref>\w+) (?<remote_sha>[0-9a-f]{40})/m
|
12
13
|
|
13
14
|
def self.run(cmd_parameter=[])
|
14
15
|
options = Gurney::CLI::OptionParser.parse(cmd_parameter)
|
15
16
|
|
16
17
|
begin
|
17
18
|
if options.hook
|
18
|
-
g = Git.bare(ENV['GIT_DIR'])
|
19
|
+
g = Git.bare(ENV['GIT_DIR'] || Dir.pwd)
|
19
20
|
else
|
20
21
|
unless Dir.exists? './.git'
|
21
22
|
raise Gurney::Error.new('Must be run within a git repository')
|
@@ -30,6 +31,7 @@ module Gurney
|
|
30
31
|
config_file ||= '---'
|
31
32
|
config = Gurney::Config.from_yaml(config_file)
|
32
33
|
|
34
|
+
options.branches ||= config&.branches
|
33
35
|
options.branches ||= config&.branches
|
34
36
|
options.api_token ||= config&.api_token
|
35
37
|
options.api_url ||= config&.api_url
|
@@ -40,11 +42,12 @@ module Gurney
|
|
40
42
|
end
|
41
43
|
|
42
44
|
branches = []
|
43
|
-
if options.hook
|
45
|
+
if options.hook || options.client_hook
|
44
46
|
# we get passed changed branches and refs via stdin
|
45
47
|
$stdin.each_line do |line|
|
46
|
-
|
47
|
-
|
48
|
+
regex = options.client_hook ? CLIENT_HOOK_STDIN_REGEX : HOOK_STDIN_REGEX
|
49
|
+
matches = line.match(regex)
|
50
|
+
if matches && matches[:new] != '0' * 40
|
48
51
|
if options.branches.include? matches[:ref]
|
49
52
|
branches << matches[:ref]
|
50
53
|
end
|
@@ -62,12 +65,15 @@ module Gurney
|
|
62
65
|
branches.each do |branch|
|
63
66
|
dependencies = []
|
64
67
|
|
65
|
-
yarn_source = Gurney::Source::Yarn.new(yarn_lock: read_file(g, options.hook, branch, 'yarn.lock'))
|
68
|
+
yarn_source = Gurney::Source::Yarn.new(yarn_lock: read_file(g, options.hook || options.client_hook, branch, 'yarn.lock'))
|
66
69
|
dependencies.concat yarn_source.dependencies || []
|
67
70
|
|
68
|
-
bundler_source = Gurney::Source::Bundler.new(gemfile_lock: read_file(g, options.hook, branch, 'Gemfile.lock'))
|
71
|
+
bundler_source = Gurney::Source::Bundler.new(gemfile_lock: read_file(g, options.hook || options.client_hook, branch, 'Gemfile.lock'))
|
69
72
|
dependencies.concat bundler_source.dependencies || []
|
70
73
|
|
74
|
+
ruby_version_source = Gurney::Source::RubyVersion.new(ruby_version: read_file(g, options.hook || options.client_hook, branch, '.ruby-version'))
|
75
|
+
dependencies.concat ruby_version_source.dependencies || []
|
76
|
+
|
71
77
|
dependencies.compact!
|
72
78
|
|
73
79
|
api = Gurney::Api.new(base_url: options.api_url, token: options.api_token)
|
@@ -94,8 +100,10 @@ module Gurney
|
|
94
100
|
|
95
101
|
def self.read_file(git, from_git, branch, filename)
|
96
102
|
if from_git
|
97
|
-
|
98
|
-
|
103
|
+
begin
|
104
|
+
git.show("#{branch}:#{filename}")
|
105
|
+
rescue Git::GitExecuteError
|
106
|
+
# happens if branch does not exist
|
99
107
|
end
|
100
108
|
else
|
101
109
|
if File.exists? filename
|
@@ -8,6 +8,7 @@ module Gurney
|
|
8
8
|
def self.parse(args)
|
9
9
|
options = OpenStruct.new
|
10
10
|
options.hook = false
|
11
|
+
options.client_hook = false
|
11
12
|
options.config_file = 'gurney.yml'
|
12
13
|
|
13
14
|
option_parser = ::OptionParser.new do |opts|
|
@@ -20,7 +21,7 @@ module Gurney
|
|
20
21
|
options.api_url = api_url
|
21
22
|
end
|
22
23
|
|
23
|
-
opts.on('', '--api-token [API TOKEN]', 'Token to be send to api in the X-AuthToken header') do |api_token|
|
24
|
+
opts.on('', '--api-token [API TOKEN]', 'Token to be send to the api in the X-AuthToken header') do |api_token|
|
24
25
|
options.api_token = api_token
|
25
26
|
end
|
26
27
|
|
@@ -32,6 +33,10 @@ module Gurney
|
|
32
33
|
options.hook = hook
|
33
34
|
end
|
34
35
|
|
36
|
+
opts.on('', '--client-hook', 'Run as a git pre-push hook') do |client_hook|
|
37
|
+
options.client_hook = client_hook
|
38
|
+
end
|
39
|
+
|
35
40
|
opts.on('-p', '--project-id [PROJECT ID]', 'Specify project id for api') do |project_id|
|
36
41
|
options.project_id = project_id
|
37
42
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
|
3
|
+
module Gurney
|
4
|
+
module Source
|
5
|
+
class RubyVersion < Base
|
6
|
+
|
7
|
+
def initialize(ruby_version:)
|
8
|
+
@ruby_version = ruby_version&.strip
|
9
|
+
end
|
10
|
+
|
11
|
+
def present?
|
12
|
+
@ruby_version && @ruby_version.size > 0
|
13
|
+
end
|
14
|
+
|
15
|
+
def dependencies
|
16
|
+
if present?
|
17
|
+
[Dependency.new(ecosystem: 'ruby', name: 'ruby', version: @ruby_version)]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
attr_reader :gemfile_lock
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/gurney/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gurney_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Schaflitzl
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-06-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|
@@ -94,6 +94,7 @@ files:
|
|
94
94
|
- lib/gurney/dependency.rb
|
95
95
|
- lib/gurney/source/base.rb
|
96
96
|
- lib/gurney/source/bundler.rb
|
97
|
+
- lib/gurney/source/ruby_version.rb
|
97
98
|
- lib/gurney/source/yarn.rb
|
98
99
|
- lib/gurney/version.rb
|
99
100
|
homepage: https://github.com/makandra/gurney
|
@@ -115,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
115
116
|
- !ruby/object:Gem::Version
|
116
117
|
version: '0'
|
117
118
|
requirements: []
|
118
|
-
rubygems_version: 3.0.
|
119
|
+
rubygems_version: 3.0.3
|
119
120
|
signing_key:
|
120
121
|
specification_version: 4
|
121
122
|
summary: Gurney is a small tool to extract yarn and RubyGems dependencies from project
|