gitarro 0.1.56 → 0.1.70
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/gitarro/backend.rb +18 -5
- data/lib/gitarro/git_op.rb +33 -0
- data/lib/gitarro/opt_parser.rb +19 -11
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a2a34d84599e596da7d621b259fc5d28e0595d1
|
4
|
+
data.tar.gz: d625f03c948ff34129250332dffbc0fdb930f7bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f6dedf76a39c784378cf4430f53f65d328269f3b8774e6d614f45cbfe03e4d0e92cee3566fef946a071d26515cc861ec167a3a02d2748c6916d1c335c9d2c3c
|
7
|
+
data.tar.gz: 660e5aecfd92a15f21407b494da427241d03b7c493883b9cbe3be203802e7280d9a598b743bd688fb2da9677db1e170923484ce4d5640065a3cf3440ebba424c
|
data/lib/gitarro/backend.rb
CHANGED
@@ -84,15 +84,11 @@ class TestExecutor
|
|
84
84
|
|
85
85
|
# this will clone the repo and execute the tests
|
86
86
|
def pr_test(pr)
|
87
|
-
|
88
|
-
# merge PR-branch to upstream branch
|
89
|
-
git.merge_pr_totarget(pr.base.ref, pr.head.ref)
|
87
|
+
clone_repo(@noshallow)
|
90
88
|
# export variables
|
91
89
|
export_pr_variables(pr)
|
92
90
|
# do valid tests and store the result
|
93
91
|
test_status = run_script
|
94
|
-
# del branch
|
95
|
-
git.del_pr_branch(pr.base.ref, pr.head.ref)
|
96
92
|
test_status
|
97
93
|
end
|
98
94
|
|
@@ -105,6 +101,23 @@ class TestExecutor
|
|
105
101
|
|
106
102
|
private
|
107
103
|
|
104
|
+
def clone_repo(noshallow)
|
105
|
+
shallow = GitShallowClone.new(@git_dir, pr, @options)
|
106
|
+
# by default we use always shallow clone
|
107
|
+
unless noshallow
|
108
|
+
shallow.clone
|
109
|
+
return
|
110
|
+
end
|
111
|
+
# this is for using the merging to ref
|
112
|
+
full_clone
|
113
|
+
end
|
114
|
+
|
115
|
+
def full_clone
|
116
|
+
git = GitOp.new(@git_dir, pr, @options)
|
117
|
+
git.merge_pr_totarget(pr.base.ref, pr.head.ref)
|
118
|
+
git.del_pr_branch(pr.base.ref, pr.head.ref)
|
119
|
+
end
|
120
|
+
|
108
121
|
def export_pr_variables(pr)
|
109
122
|
ENV['GITARRO_PR_AUTHOR'] = pr.head.user.login.to_s
|
110
123
|
ENV['GITARRO_PR_TITLE'] = pr.title.to_s
|
data/lib/gitarro/git_op.rb
CHANGED
@@ -3,6 +3,39 @@
|
|
3
3
|
require 'English'
|
4
4
|
require 'fileutils'
|
5
5
|
require 'timeout'
|
6
|
+
require 'tmpdir'
|
7
|
+
|
8
|
+
# handle shallow clone
|
9
|
+
class GitShallowClone
|
10
|
+
attr_reader :git_dir, :pr, :options, :repo_protocol
|
11
|
+
def initialize(git_dir, pr, options)
|
12
|
+
@git_dir = git_dir
|
13
|
+
# pr object for extract all relev. data.
|
14
|
+
@pr = pr
|
15
|
+
# All gitarro options
|
16
|
+
@options = options
|
17
|
+
gh = 'https://github.com/'
|
18
|
+
gg = 'git@github.com:'
|
19
|
+
@repo_protocol = @options[:https] ? gh : gg
|
20
|
+
@repo_url = @options[:https] ? pr.head.repo.html_url : pr.head.repo.ssh_url
|
21
|
+
end
|
22
|
+
|
23
|
+
# shallow clone
|
24
|
+
def clone
|
25
|
+
tmp_dir = create_tmp_dir!
|
26
|
+
git_local = "#{git_dir}/#{tmp_dir}"
|
27
|
+
puts `git clone --depth 1 #{@repo_url} -b #{pr.head.ref} #{git_local}`
|
28
|
+
exit 1 if $CHILD_STATUS.exitstatus.nonzero?
|
29
|
+
Dir.chdir git_local
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def create_tmp_dir!
|
35
|
+
repo = options[:repo].split('/')[1]
|
36
|
+
"#{repo}#{Time.now.to_i}_#{rand(100)}"
|
37
|
+
end
|
38
|
+
end
|
6
39
|
|
7
40
|
# This class is used by lib/backend.rb
|
8
41
|
# git operation for gitarro
|
data/lib/gitarro/opt_parser.rb
CHANGED
@@ -22,21 +22,11 @@ module MandatoryOptions
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
def git_opt(opt)
|
26
|
-
desc = 'Specify a location where gitarro will clone the GitHub project. '\
|
27
|
-
'If the dir does not exists, gitarro will create one. '\
|
28
|
-
'For example: /tmp/'
|
29
|
-
opt.on('-g', "--git_dir 'GIT_LOCAL_DIR'", desc) do |git_dir|
|
30
|
-
@options[:git_dir] = git_dir
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
25
|
def mandatory_options(opt)
|
35
26
|
opt.separator 'Mandatory options:'
|
36
27
|
repo_opt(opt)
|
37
28
|
context_opt(opt)
|
38
29
|
test_opt(opt)
|
39
|
-
git_opt(opt)
|
40
30
|
end
|
41
31
|
end
|
42
32
|
|
@@ -47,12 +37,26 @@ module OptionalOptions
|
|
47
37
|
opt.on('-C', '--check', desc) { |check| @options[:check] = check }
|
48
38
|
end
|
49
39
|
|
40
|
+
def no_shallow(opt)
|
41
|
+
desc = 'If enabled, gitarro will not use git shallow clone'
|
42
|
+
opt.on('--noshallow', desc) { |noshallow| @options[:noshallow] = noshallow }
|
43
|
+
end
|
44
|
+
|
50
45
|
def desc_opt(opt)
|
51
46
|
opt.on('-d', "--description 'DESCRIPTION'", 'Test decription') do |d|
|
52
47
|
@options[:description] = d
|
53
48
|
end
|
54
49
|
end
|
55
50
|
|
51
|
+
def git_opt(opt)
|
52
|
+
desc = 'Specify a location where gitarro will clone the GitHub project. '\
|
53
|
+
'If the dir does not exists, gitarro will create one. '\
|
54
|
+
'by default is the /tmp'
|
55
|
+
opt.on('-g', "--git_dir 'GIT_LOCAL_DIR'", desc) do |git_dir|
|
56
|
+
@options[:git_dir] = git_dir
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
56
60
|
def url_opt(opt)
|
57
61
|
desc = 'Specify the URL to append to add to the GitHub review. ' \
|
58
62
|
'Usually you will use an URL to the Jenkins build log.'
|
@@ -95,11 +99,13 @@ module OptionalOptions
|
|
95
99
|
opt.separator "\n Optional options:"
|
96
100
|
desc_opt(opt)
|
97
101
|
check_opt(opt)
|
102
|
+
no_shallow(opt)
|
98
103
|
file_opt(opt)
|
99
104
|
url_opt(opt)
|
100
105
|
pr_number(opt)
|
101
106
|
https_opt(opt)
|
102
107
|
changed_since(opt)
|
108
|
+
git_opt(opt)
|
103
109
|
end
|
104
110
|
end
|
105
111
|
|
@@ -127,7 +133,7 @@ class OptParserInternal
|
|
127
133
|
|
128
134
|
def parse(opt_parser)
|
129
135
|
parse_options(opt_parser)
|
130
|
-
mandatory_options = %w[repo context test_file
|
136
|
+
mandatory_options = %w[repo context test_file]
|
131
137
|
mandatory_options.each { |opt| ck_mandatory_option(opt) }
|
132
138
|
defaults_false
|
133
139
|
defaults_to_text
|
@@ -159,6 +165,7 @@ class OptParserInternal
|
|
159
165
|
@options[:check] = false if @options[:check].nil?
|
160
166
|
@options[:target_url] = '' if @options[:target_url].nil?
|
161
167
|
@options[:https] = false if @options[:https].nil?
|
168
|
+
@options[:noshallow] = false if @options[:noshallow].nil?
|
162
169
|
@options[:changed_since] = -1 if @options[:changed_since].nil?
|
163
170
|
end
|
164
171
|
|
@@ -166,6 +173,7 @@ class OptParserInternal
|
|
166
173
|
desc = 'use option -d to set a custom test description.'
|
167
174
|
@options[:description] = desc if @options[:description].nil?
|
168
175
|
@options[:file_type] = 'notype' if @options[:file_type].nil?
|
176
|
+
@options[:git_dir] = '/tmp' if @options[:git_dir].nil?
|
169
177
|
end
|
170
178
|
end
|
171
179
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitarro
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.70
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dario Maiocchi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: english
|
@@ -168,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
168
168
|
version: '0'
|
169
169
|
requirements: []
|
170
170
|
rubyforge_project:
|
171
|
-
rubygems_version: 2.5.
|
171
|
+
rubygems_version: 2.5.1
|
172
172
|
signing_key:
|
173
173
|
specification_version: 4
|
174
174
|
summary: gitarro gem
|