ruby_git_hooks 0.0.44 → 0.0.45
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/ruby_git_hooks/git_ops.rb +10 -1
- data/lib/ruby_git_hooks/jira_add_comment.rb +1 -2
- data/lib/ruby_git_hooks/version.rb +1 -1
- data/test/jira_add_comment_test.rb +37 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
OWU2N2FmNTkyNGM1NzcwYWZkNmM4NmNmZWY0NGMyM2NkNjEyMDVmMg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NjM5YTJiNTRjZmFlY2U4Y2MxNGU0ZTkzYjZmMTc5MmU2MGU4ZjNiOQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
N2VjNWMzODQyMzJlMzU0YWQ4MjIzZjRiYzNjNzhhOWY0MmNkZjNkNmFmYTU0
|
10
|
+
ZWM4MzU4MWJjN2FmZWQ0M2Q0MDBlYmE0MjRjMDNkMTE2NDkxY2IxZDMwMzc5
|
11
|
+
OGI2MzJkNTgwMDRkMDZhMTRiNGI0OTQzOTE2MjliZGY4NmRjNDk=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ODcyNzMzMTljOTgyZThkYTk0OTMxODZkYjBhY2RiNGE2ZWQyMzdmYmJmNzUx
|
14
|
+
YmQ1MmViZGZkY2ZlZmE2Y2IxOWVlNDg5Mjg2NjI0Zjc2MmNjZWE5ZmY5MWFj
|
15
|
+
Y2YwYTMzMzIxZjJhNWFmY2FlYzE2NTFkYTg5ZDkzYjUzNzMxMDY=
|
@@ -58,6 +58,16 @@ module RubyGitHooks::GitOps
|
|
58
58
|
@single_file_counter += 1
|
59
59
|
end
|
60
60
|
|
61
|
+
def new_multi_file_commit(num_files = 3, repo_name = "child_repo", commit_message = "multi-file commit", base_filename = "test", contents="Contents")
|
62
|
+
(1..num_files).each do |num|
|
63
|
+
File.open(File.join(repo_name, base_filename + num.to_s), "w") do |f|
|
64
|
+
f.write(contents)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
Hook.shell! "cd #{repo_name} && git add . && git commit -m \"#{commit_message}\""
|
68
|
+
|
69
|
+
end
|
70
|
+
|
61
71
|
def git_delete(repo_name="child_repo", filename="file_to_delete")
|
62
72
|
# filename is a file that has already been added and commited to the repo
|
63
73
|
Hook.shell! "cd #{repo_name} && git rm #{filename}"
|
@@ -68,7 +78,6 @@ module RubyGitHooks::GitOps
|
|
68
78
|
Hook.shell! "cd #{repo_name} && git mv #{filename} #{new_filename}"
|
69
79
|
end
|
70
80
|
|
71
|
-
|
72
81
|
def last_commit_sha(repo_name = "child_repo")
|
73
82
|
Hook.shell!("cd #{repo_name} && git log -n 1 --format=%H").chomp
|
74
83
|
end
|
@@ -121,9 +121,8 @@ class JiraCommentAddHook < RubyGitHooks::Hook
|
|
121
121
|
# This is the initial commit so all files were added, but have to add the A ourselves
|
122
122
|
files_with_status = Hook.shell!("git ls-tree --name-status -r #{commit}").split("\n")
|
123
123
|
# put the A at the front
|
124
|
-
files_with_status.map
|
124
|
+
files_with_status = files_with_status.map{|filename| "A\t" + filename}.join("\n")
|
125
125
|
else
|
126
|
-
|
127
126
|
files_with_status = Hook.shell!("git diff --name-status #{base}..#{current}")
|
128
127
|
end
|
129
128
|
files_with_status
|
@@ -159,7 +159,6 @@ JSON
|
|
159
159
|
{ "fields": { "status": { "name": "Open" } } }
|
160
160
|
JSON
|
161
161
|
# look at output to see what gets generated for message
|
162
|
-
puts "***** STARTING MERGE REF CHECK *****"
|
163
162
|
fake_hook_check("Message with GOOD-234 reference to Jira" , true)
|
164
163
|
end
|
165
164
|
|
@@ -223,6 +222,43 @@ JSON
|
|
223
222
|
end
|
224
223
|
|
225
224
|
|
225
|
+
def test_first_commit
|
226
|
+
# if we had a way to check the actual message generated for the content, which we don't right now
|
227
|
+
# we should check that the first commit shows the changes with "A" in front of them and with the correct
|
228
|
+
# formatting (we missed a bug where it leaves them in an array instead of a list). BUT we can at least
|
229
|
+
# do a new commit with multiple files and then look at the output to be sure it's right.
|
230
|
+
|
231
|
+
puts "TEST FIRST COMMIT"
|
232
|
+
mock(RestClient).get("https://user:password@jira.example.com/rest/api/latest/issue/GOOD-234") { <<JSON }
|
233
|
+
{ "fields": { "status": { "name": "Open" } } }
|
234
|
+
JSON
|
235
|
+
|
236
|
+
mock(RestClient).post.with_any_args {<<JSON } # more complicated to check the args, just be sure it's called.
|
237
|
+
{ "fields": { "status": { "name": "Open" } } }
|
238
|
+
JSON
|
239
|
+
git_tag("child_repo", "0.1")
|
240
|
+
|
241
|
+
# we want to test the very first commit, pushed with multiple files,
|
242
|
+
# so have to do it specifically instead of what's already set up
|
243
|
+
# (can still use @hook)
|
244
|
+
|
245
|
+
new_bare_repo("parent_repo2.git")
|
246
|
+
clone_repo("parent_repo2.git", "child_repo2")
|
247
|
+
new_multi_file_commit(3, "child_repo2", "Message with GOOD-234 reference to Jira" )
|
248
|
+
stub(@hook).commit_message { msg }
|
249
|
+
sha = last_commit_sha("child_repo2") # one commit sha, multiple files changed
|
250
|
+
hook_refs = {sha => ["refs/heads/master"]} # it's always the master branch
|
251
|
+
stub(@hook).commit_ref_map{ hook_refs }
|
252
|
+
stub(@hook).commits{hook_refs.keys}
|
253
|
+
Dir.chdir("child_repo2") do
|
254
|
+
@hook.check
|
255
|
+
end
|
256
|
+
|
257
|
+
# and look and see if it looks right...
|
258
|
+
|
259
|
+
end
|
260
|
+
|
261
|
+
|
226
262
|
|
227
263
|
|
228
264
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_git_hooks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.45
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Noah Gibbs
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2014-
|
13
|
+
date: 2014-06-06 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: pony
|