murmurs 0.0.6 → 0.0.7
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.
- data/README.md +3 -6
- data/bin/murmurs +20 -2
- data/lib/murmurs/git.rb +70 -0
- data/lib/murmurs.rb +4 -29
- metadata +11 -6
- data/bin/murmurs-git +0 -56
data/README.md
CHANGED
@@ -11,7 +11,7 @@ Installation
|
|
11
11
|
|
12
12
|
gem install murmurs
|
13
13
|
|
14
|
-
A command 'murmurs' will be installed.
|
14
|
+
A command 'murmurs' will be installed. (In some OS, the script name maybe changed to murmurs1.9 for ruby 1.9)
|
15
15
|
|
16
16
|
Usage
|
17
17
|
----------------
|
@@ -49,17 +49,14 @@ On your Git server:
|
|
49
49
|
install rubygems if there was no one installed with ruby
|
50
50
|
gem install murmurs
|
51
51
|
|
52
|
-
murmurs gem should install a new command 'murmurs
|
52
|
+
murmurs gem should install a new command 'murmurs'
|
53
53
|
|
54
54
|
Install the git hook for post-receive:
|
55
55
|
|
56
|
-
murmurs-
|
56
|
+
murmurs -a <git repository path>
|
57
57
|
|
58
58
|
Then, in the git repository, setup the following configs:
|
59
59
|
|
60
60
|
git config hooks.minglemurmursurl "https://your-site.mingle-api.thoughtworks.com/api/v2/projects/your_project/murmurs.xml"
|
61
61
|
git config hooks.mingleaccesskeyid <Mingle user access key id>
|
62
62
|
git config hooks.mingleaccesssecretkey <Mingle user access secret key>
|
63
|
-
|
64
|
-
Note, if murmurs-git script got renamed to murmurs-git1.9 on your OS, another command "murmurs" probably will also be renamed to "murmurs1.9".
|
65
|
-
The git post-receive hook installed in your <git repository path>/hooks (or <git repository path>/.git/hooks) directory is calling "murmurs" command to post murmur to Mingle, so you need change command "murmurs" in the post-recieve hook to be "murmurs1.9"
|
data/bin/murmurs
CHANGED
@@ -27,6 +27,9 @@ http://www.thoughtworks.com/products/docs/mingle/current/help/configuring_hmac_a
|
|
27
27
|
opts = OptionParser.new do |opts|
|
28
28
|
opts.banner = "Usage: murmurs [options] MESSAGE"
|
29
29
|
|
30
|
+
opts.on("-a", "--install_git_hook GIT_REPOSITORY_PATH", "install git hook post-receive to the given git repository") do |v|
|
31
|
+
options[:install_git_hook] = v
|
32
|
+
end
|
30
33
|
opts.on("-m", "--murmurs_url MINGLE_MURMURS_URL", "Mingle project murmurs url") do |v|
|
31
34
|
options[:murmurs_url] = v
|
32
35
|
end
|
@@ -66,5 +69,20 @@ end.parse!
|
|
66
69
|
|
67
70
|
include Murmurs
|
68
71
|
|
69
|
-
|
70
|
-
|
72
|
+
if git_repo_path = options[:install_git_hook]
|
73
|
+
hook = install_git_hook(git_repo_path, __FILE__)
|
74
|
+
puts "Installed #{hook}"
|
75
|
+
puts "Please setup the following git config:"
|
76
|
+
puts %Q{
|
77
|
+
git config hooks.minglemurmursurl "https://<your_site>.mingle.thoughtworks.com/api/v2/pro
|
78
|
+
git config hooks.mingleaccesskeyid "MINGLE ACCESS KEY ID"
|
79
|
+
git config hooks.mingleaccesssecretkey "MINGLE ACCESS SECRET KEY"
|
80
|
+
|
81
|
+
For further information about MINGLE ACCESS KEY ID and MINGLE ACCESS SECRET KEY, please read:
|
82
|
+
http://www.thoughtworks.com/products/docs/mingle/current/help/configuring_hmac_authentication.html
|
83
|
+
}
|
84
|
+
|
85
|
+
else
|
86
|
+
msg = ARGV[0] || (STDIN.tty? ? nil : STDIN.read)
|
87
|
+
murmur(options.delete(:murmurs_url), msg, options)
|
88
|
+
end
|
data/lib/murmurs/git.rb
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
module Murmurs
|
4
|
+
module Git
|
5
|
+
def git_hooks_dir(git_repo_dir)
|
6
|
+
hooks = File.join(git_repo_dir, 'hooks')
|
7
|
+
if File.exists?(hooks)
|
8
|
+
hooks
|
9
|
+
else
|
10
|
+
hooks = File.join(git_repo_dir, '.git', 'hooks')
|
11
|
+
if File.exists?(hooks)
|
12
|
+
hooks
|
13
|
+
else
|
14
|
+
raise "Could not find \"hooks\" dir or \".git/hooks\" dir in #{git_repo_dir}"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def install_git_hook(git_dir, script)
|
20
|
+
hooks = git_hooks_dir(git_dir)
|
21
|
+
hook = File.join(hooks, 'post-receive')
|
22
|
+
if File.exists?(hook)
|
23
|
+
raise HookExistsError, "There is #{hook} file existing, please backup / remove it."
|
24
|
+
end
|
25
|
+
|
26
|
+
File.open(hook, 'w') do |f|
|
27
|
+
f.write <<-BASH
|
28
|
+
#!/usr/bin/env bash
|
29
|
+
|
30
|
+
mingle_murmurs_url=$(git config hooks.minglemurmursurl)
|
31
|
+
mingle_access_key_id=$(git config hooks.mingleaccesskeyid)
|
32
|
+
mingle_access_secret_key=$(git config hooks.mingleaccesssecretkey)
|
33
|
+
|
34
|
+
echo "$(cat)" | #{script} -g -b master -m "$mingle_murmurs_url" -k "$mingle_access_key_id" -s "$mingle_access_secret_key"
|
35
|
+
BASH
|
36
|
+
end
|
37
|
+
FileUtils.chmod('+x', hook)
|
38
|
+
hook
|
39
|
+
end
|
40
|
+
|
41
|
+
# input: git post receive stdin string
|
42
|
+
# branch: git branch
|
43
|
+
def git_commits(input, branch)
|
44
|
+
data = input.split("\n").map do |l|
|
45
|
+
l.split
|
46
|
+
end.find do |l|
|
47
|
+
l[2] =~ /\Arefs\/heads\/#{branch}\z/
|
48
|
+
end
|
49
|
+
|
50
|
+
return if data.nil?
|
51
|
+
|
52
|
+
null_rev = '0' * 40
|
53
|
+
from_rev, to_rev, _ = data
|
54
|
+
if to_rev == null_rev # delete branch
|
55
|
+
"Someone deleted branch #{branch}."
|
56
|
+
else
|
57
|
+
revs = if from_rev == null_rev # new branch
|
58
|
+
to_rev
|
59
|
+
else
|
60
|
+
"#{from_rev}..#{to_rev}"
|
61
|
+
end
|
62
|
+
`git rev-list #{revs}`.split("\n").map do |rev|
|
63
|
+
`git log -n 1 #{rev}`
|
64
|
+
end.reverse.map do |msg|
|
65
|
+
"Repository: #{File.basename(Dir.getwd)}\n#{msg}"
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
data/lib/murmurs.rb
CHANGED
@@ -3,10 +3,14 @@ require 'net/https'
|
|
3
3
|
require 'time'
|
4
4
|
require 'api-auth'
|
5
5
|
require 'json'
|
6
|
+
require 'murmurs/git'
|
6
7
|
|
7
8
|
module Murmurs
|
8
9
|
class InvalidMurmursURLError < StandardError; end
|
9
10
|
class UnexpectedResponseError < StandardError; end
|
11
|
+
class HookExistsError < StandardError; end
|
12
|
+
|
13
|
+
include Git
|
10
14
|
|
11
15
|
def murmur(url, msg, options={})
|
12
16
|
if msg.nil? || msg.empty?
|
@@ -49,35 +53,6 @@ module Murmurs
|
|
49
53
|
end
|
50
54
|
end
|
51
55
|
|
52
|
-
# input: git post receive stdin string
|
53
|
-
# branch: git branch
|
54
|
-
def git_commits(input, branch)
|
55
|
-
data = input.split("\n").map do |l|
|
56
|
-
l.split
|
57
|
-
end.find do |l|
|
58
|
-
l[2] =~ /\Arefs\/heads\/#{branch}\z/
|
59
|
-
end
|
60
|
-
|
61
|
-
return if data.nil?
|
62
|
-
|
63
|
-
null_rev = '0' * 40
|
64
|
-
from_rev, to_rev, _ = data
|
65
|
-
if to_rev == null_rev # delete branch
|
66
|
-
"Someone deleted branch #{branch}."
|
67
|
-
else
|
68
|
-
revs = if from_rev == null_rev # new branch
|
69
|
-
to_rev
|
70
|
-
else
|
71
|
-
"#{from_rev}..#{to_rev}"
|
72
|
-
end
|
73
|
-
`git rev-list #{revs}`.split("\n").map do |rev|
|
74
|
-
`git log -n 1 #{rev}`
|
75
|
-
end.reverse.map do |msg|
|
76
|
-
"Repository: #{File.basename(Dir.getwd)}\n#{msg}"
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
56
|
def http_post(url, params, options={})
|
82
57
|
uri = URI.parse(url)
|
83
58
|
http = Net::HTTP.new(uri.host, uri.port)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: murmurs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-05-
|
12
|
+
date: 2014-05-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: api-auth
|
@@ -18,7 +18,7 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 1.
|
21
|
+
version: 1.0.3
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 1.
|
29
|
+
version: 1.0.3
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: json
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,13 +52,12 @@ email:
|
|
52
52
|
- mingle-dev@thoughtworks.com
|
53
53
|
executables:
|
54
54
|
- murmurs
|
55
|
-
- murmurs-git
|
56
55
|
extensions: []
|
57
56
|
extra_rdoc_files: []
|
58
57
|
files:
|
59
58
|
- README.md
|
60
59
|
- bin/murmurs
|
61
|
-
-
|
60
|
+
- lib/murmurs/git.rb
|
62
61
|
- lib/murmurs.rb
|
63
62
|
homepage: https://github.com/ThoughtWorksStudios/murmurs
|
64
63
|
licenses:
|
@@ -73,12 +72,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
73
72
|
- - ! '>='
|
74
73
|
- !ruby/object:Gem::Version
|
75
74
|
version: '0'
|
75
|
+
segments:
|
76
|
+
- 0
|
77
|
+
hash: 4595464421835208926
|
76
78
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
79
|
none: false
|
78
80
|
requirements:
|
79
81
|
- - ! '>='
|
80
82
|
- !ruby/object:Gem::Version
|
81
83
|
version: '0'
|
84
|
+
segments:
|
85
|
+
- 0
|
86
|
+
hash: 4595464421835208926
|
82
87
|
requirements: []
|
83
88
|
rubyforge_project:
|
84
89
|
rubygems_version: 1.8.23
|
data/bin/murmurs-git
DELETED
@@ -1,56 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
if ARGV[0] == '-h' || ARGV[0] == '--help'
|
4
|
-
puts "Usage murmurs-git GIT_REPOSITORY_PATH"
|
5
|
-
puts ""
|
6
|
-
puts "Install a git post-receive hook in hooks directory inside given git repository path"
|
7
|
-
|
8
|
-
exit(0)
|
9
|
-
end
|
10
|
-
|
11
|
-
def git_hooks_dir(git_repo_dir)
|
12
|
-
hooks = File.join(git_repo_dir, 'hooks')
|
13
|
-
if File.exists?(hooks)
|
14
|
-
hooks
|
15
|
-
else
|
16
|
-
hooks = File.join(git_repo_dir, '.git', 'hooks')
|
17
|
-
if File.exists?(hooks)
|
18
|
-
hooks
|
19
|
-
else
|
20
|
-
raise "Could not find hooks dir or .git/hooks dir in #{git_repo_dir}"
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
require 'fileutils'
|
26
|
-
|
27
|
-
hooks = git_hooks_dir(ARGV[0])
|
28
|
-
hook = File.join(hooks, 'post-receive')
|
29
|
-
|
30
|
-
if File.exists?(hook)
|
31
|
-
puts "There is #{hook} file existing, please backup / remove it."
|
32
|
-
exit
|
33
|
-
end
|
34
|
-
|
35
|
-
File.open(hook, 'w') do |f|
|
36
|
-
f.write <<-BASH
|
37
|
-
#!/usr/bin/env bash
|
38
|
-
|
39
|
-
mingle_murmurs_url=$(git config hooks.minglemurmursurl)
|
40
|
-
mingle_access_key_id=$(git config hooks.mingleaccesskeyid)
|
41
|
-
mingle_access_secret_key=$(git config hooks.mingleaccesssecretkey)
|
42
|
-
|
43
|
-
echo "$(cat)" | murmurs -g -b master -m "$mingle_murmurs_url" -k "$mingle_access_key_id" -s "$mingle_access_secret_key"
|
44
|
-
BASH
|
45
|
-
end
|
46
|
-
FileUtils.chmod('+x', hook)
|
47
|
-
puts "Installed #{hook}"
|
48
|
-
puts "Please setup the following git config:"
|
49
|
-
puts %Q{
|
50
|
-
git config hooks.minglemurmursurl "https://<your_site>.mingle.thoughtworks.com/api/v2/projects/<your_project>/murmurs.xml"
|
51
|
-
git config hooks.mingleaccesskeyid "MINGLE ACCESS KEY ID"
|
52
|
-
git config hooks.mingleaccesssecretkey "MINGLE ACCESS SECRET KEY"
|
53
|
-
|
54
|
-
For further information, please read this:
|
55
|
-
http://www.thoughtworks.com/products/docs/mingle/current/help/configuring_hmac_authentication.html
|
56
|
-
}
|