github-commit-mailer 0.0.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.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +30 -0
- data/Rakefile +1 -0
- data/example/emailChanges.rb +12 -0
- data/example/git-commit-notifier.yml +31 -0
- data/git-commit-notifier.yml-sample +31 -0
- data/github-commit-mailer.gemspec +21 -0
- data/lib/github-commit-mailer/version.rb +7 -0
- data/lib/github-commit-mailer.rb +85 -0
- metadata +72 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Tacit Knowledge
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# Github::Commit::Mailer
|
2
|
+
|
3
|
+
gem for pulling changes from a github repository and send mail with differences
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'github-commit-mailer'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install github-commit-mailer
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
An working example can be found in directory 'example'
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
30
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'github-commit-mailer'
|
5
|
+
|
6
|
+
repo_dir = "/home/mtricolici/Projects/Converse/confoo"
|
7
|
+
yml_cfg = "/home/mtricolici/Projects/Deploy/github-commit-mailer/example/git-commit-notifier.yml"
|
8
|
+
last_commit_file = "/tmp/confoo-last_commit_rev"
|
9
|
+
|
10
|
+
mailer = Github::Commit::Mailer::GithubCommitMailer.new(repo_dir, yml_cfg, last_commit_file)
|
11
|
+
mailer.run
|
12
|
+
|
@@ -0,0 +1,31 @@
|
|
1
|
+
delivery_method: sendmail # smtp or sendmail
|
2
|
+
|
3
|
+
# The recipient for the commit:
|
4
|
+
mailinglist: mtricolici@tacitknowledge.com
|
5
|
+
|
6
|
+
# set to true if you want to ignore empty merge messages
|
7
|
+
ignore_merge: true
|
8
|
+
|
9
|
+
# Optional parameter for the subject-line of the mail
|
10
|
+
emailprefix: [confoo]
|
11
|
+
|
12
|
+
# Decorate files with link to a webview. Possible values: none or gitweb
|
13
|
+
link_files: gitweb
|
14
|
+
|
15
|
+
gitweb:
|
16
|
+
path: https://git.tacitknowledge.com/git
|
17
|
+
project: hale%2Fhale.git
|
18
|
+
|
19
|
+
#Limit lines
|
20
|
+
lines_per_diff: 1000
|
21
|
+
|
22
|
+
smtp_server:
|
23
|
+
address: localhost
|
24
|
+
port: 25
|
25
|
+
domain: tacitknowledge.com
|
26
|
+
|
27
|
+
sendmail_options:
|
28
|
+
location: /usr/sbin/sendmail
|
29
|
+
arguments: -i -t
|
30
|
+
|
31
|
+
|
@@ -0,0 +1,31 @@
|
|
1
|
+
delivery_method: sendmail # smtp or sendmail
|
2
|
+
|
3
|
+
# The recipient for the commit:
|
4
|
+
mailinglist: confoo-scm@tacitknowledge.com
|
5
|
+
|
6
|
+
# set to true if you want to ignore empty merge messages
|
7
|
+
ignore_merge: true
|
8
|
+
|
9
|
+
# Optional parameter for the subject-line of the mail
|
10
|
+
emailprefix: [confoo]
|
11
|
+
|
12
|
+
# Decorate files with link to a webview. Possible values: none or gitweb
|
13
|
+
link_files: gitweb
|
14
|
+
|
15
|
+
gitweb:
|
16
|
+
path: https://git.tacitknowledge.com/git
|
17
|
+
project: hale%2Fhale.git
|
18
|
+
|
19
|
+
#Limit lines
|
20
|
+
lines_per_diff: 1000
|
21
|
+
|
22
|
+
smtp_server:
|
23
|
+
address: localhost
|
24
|
+
port: 25
|
25
|
+
domain: tacitknowledge.com
|
26
|
+
|
27
|
+
sendmail_options:
|
28
|
+
location: /usr/sbin/sendmail
|
29
|
+
arguments: -i -t
|
30
|
+
|
31
|
+
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'github-commit-mailer/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "github-commit-mailer"
|
8
|
+
gem.version = Github::Commit::Mailer::VERSION
|
9
|
+
gem.authors = ["Marcel Tricolici"]
|
10
|
+
gem.email = ["mtricolici@tacitknowledge.com"]
|
11
|
+
gem.description = %q{gem for pulling changes from a github repository and send mail with differences}
|
12
|
+
gem.summary = %q{gem for pulling changes from a github repository and send mail with differences}
|
13
|
+
gem.homepage = ""
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.add_runtime_dependency 'git-commit-notifier', '0.11.6'
|
21
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
require "github-commit-mailer/version"
|
2
|
+
|
3
|
+
module Github
|
4
|
+
module Commit
|
5
|
+
module Mailer
|
6
|
+
class ConfigException < Exception
|
7
|
+
end
|
8
|
+
|
9
|
+
class GithubCommitMailer
|
10
|
+
def initialize(repo_dir, yml_cfg, last_commit_file)
|
11
|
+
@repo_dir = repo_dir
|
12
|
+
@yml_cfg = yml_cfg
|
13
|
+
@last_commit_file = last_commit_file
|
14
|
+
|
15
|
+
validate
|
16
|
+
end
|
17
|
+
|
18
|
+
def run
|
19
|
+
last_rev = get_last_emailed_commit
|
20
|
+
git_pull
|
21
|
+
revs = get_new_commits(last_rev)
|
22
|
+
|
23
|
+
if revs.length < 2 then
|
24
|
+
puts "No new commits. Exiting."
|
25
|
+
return
|
26
|
+
end
|
27
|
+
|
28
|
+
puts "Emailing the following commits:"
|
29
|
+
revs.each { |r|
|
30
|
+
puts "commit: '#{r}'"
|
31
|
+
}
|
32
|
+
|
33
|
+
rev_from = revs[revs.length - 1]
|
34
|
+
rev_to = revs[0]
|
35
|
+
|
36
|
+
cmd = "cd #{@repo_dir} && echo '#{rev_from} #{rev_to} refs/heads/master'|git-commit-notifier #{@yml_cfg}; cd -"
|
37
|
+
puts "#{cmd}"
|
38
|
+
raise "Error executing git-commit-notifier" if !system(cmd)
|
39
|
+
|
40
|
+
puts "Saving '#{rev_to}' to '#{@last_commit_file}' ..."
|
41
|
+
File.open(@last_commit_file, 'w') do |f|
|
42
|
+
f.puts "#{rev_to}"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
def validate
|
48
|
+
raise ConfigException, "Git repository directory doesn't exist" if Dir[@repo_dir] == nil
|
49
|
+
raise ConfigException, "Yaml config file doesn't exist" if !File.exists?(@yml_cfg)
|
50
|
+
end
|
51
|
+
|
52
|
+
def get_last_emailed_commit
|
53
|
+
last_rev = nil
|
54
|
+
|
55
|
+
if File.exists? @last_commit_file then
|
56
|
+
last_rev = File.readlines(@last_commit_file)[0].strip
|
57
|
+
puts "Last emailed revision '#{last_rev}'"
|
58
|
+
end
|
59
|
+
|
60
|
+
last_rev
|
61
|
+
end
|
62
|
+
|
63
|
+
def git_pull
|
64
|
+
res = system("cd #{@repo_dir} && git pull --rebase ; cd -")
|
65
|
+
raise "Error executing git_pull" if !res
|
66
|
+
end
|
67
|
+
|
68
|
+
def get_new_commits(last_rev)
|
69
|
+
revs = []
|
70
|
+
|
71
|
+
IO.popen "git --git-dir #{@repo_dir}/.git log -200|grep -e '^commit '|awk '{print $2}'" do |io|
|
72
|
+
io.each do |line|
|
73
|
+
if last_rev.nil? or ! revs.include? last_rev then
|
74
|
+
revs << line.strip
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
revs
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
metadata
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: github-commit-mailer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Marcel Tricolici
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-01-28 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: git-commit-notifier
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - '='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.11.6
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - '='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.11.6
|
30
|
+
description: gem for pulling changes from a github repository and send mail with differences
|
31
|
+
email:
|
32
|
+
- mtricolici@tacitknowledge.com
|
33
|
+
executables: []
|
34
|
+
extensions: []
|
35
|
+
extra_rdoc_files: []
|
36
|
+
files:
|
37
|
+
- .gitignore
|
38
|
+
- Gemfile
|
39
|
+
- LICENSE.txt
|
40
|
+
- README.md
|
41
|
+
- Rakefile
|
42
|
+
- example/emailChanges.rb
|
43
|
+
- example/git-commit-notifier.yml
|
44
|
+
- git-commit-notifier.yml-sample
|
45
|
+
- github-commit-mailer.gemspec
|
46
|
+
- lib/github-commit-mailer.rb
|
47
|
+
- lib/github-commit-mailer/version.rb
|
48
|
+
homepage: ''
|
49
|
+
licenses: []
|
50
|
+
post_install_message:
|
51
|
+
rdoc_options: []
|
52
|
+
require_paths:
|
53
|
+
- lib
|
54
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ! '>='
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
60
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
requirements: []
|
67
|
+
rubyforge_project:
|
68
|
+
rubygems_version: 1.8.24
|
69
|
+
signing_key:
|
70
|
+
specification_version: 3
|
71
|
+
summary: gem for pulling changes from a github repository and send mail with differences
|
72
|
+
test_files: []
|