capnotify-commit_log 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +40 -0
- data/Rakefile +1 -0
- data/capnotify-commit_log.gemspec +29 -0
- data/lib/capnotify-commit_log/version.rb +5 -0
- data/lib/capnotify-commit_log.rb +161 -0
- data/lib/templates/_commit_log.html.erb +34 -0
- data/lib/templates/_commit_log.txt.erb +7 -0
- metadata +175 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Spike Grobstein
|
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,40 @@
|
|
1
|
+
# Capnotify::CommitLog
|
2
|
+
|
3
|
+
This adds a commit log to your capnotify emails.
|
4
|
+
|
5
|
+
This will list commits that are new to this deploy (compared to the previous deploy).
|
6
|
+
Currently it only supports git and uses the `git log --oneline` command internaly.
|
7
|
+
|
8
|
+
A future version should support other SCMs if you're into that kind of thing. Anyone with
|
9
|
+
repositories on other SCMs is encouraged to send me a pull request implementing that.
|
10
|
+
|
11
|
+
NOTE: This is very much a work in progress and is NOT production ready. This is the first
|
12
|
+
plugin for Capnotify and it's being used to work out aspects of the extension API.
|
13
|
+
|
14
|
+
## Installation
|
15
|
+
|
16
|
+
Add this line to your application's Gemfile:
|
17
|
+
|
18
|
+
gem 'capnotify-commit_log'
|
19
|
+
|
20
|
+
And then execute:
|
21
|
+
|
22
|
+
$ bundle
|
23
|
+
|
24
|
+
Or install it yourself as:
|
25
|
+
|
26
|
+
$ gem install capnotify-commit_log
|
27
|
+
|
28
|
+
## Usage
|
29
|
+
|
30
|
+
All you need to do is include the following code after requiring `capnotify`:
|
31
|
+
|
32
|
+
require 'capnotify/commit_log'
|
33
|
+
|
34
|
+
## Contributing
|
35
|
+
|
36
|
+
1. Fork it
|
37
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
38
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
39
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
40
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'capnotify-commit_log/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "capnotify-commit_log"
|
8
|
+
spec.version = Capnotify::CommitLog::VERSION
|
9
|
+
spec.authors = ["Spike Grobstein"]
|
10
|
+
spec.email = ["me@spike.cx"]
|
11
|
+
spec.description = %q{Add a detailed Git commit log to your Capnotify deloyment notification emails}
|
12
|
+
spec.summary = %q{Git commit log for Capnotify emails}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "capnotify", '~> 0.2'
|
22
|
+
spec.add_dependency "git", "~> 1.2"
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
25
|
+
spec.add_development_dependency "rake"
|
26
|
+
spec.add_development_dependency "awesome_print"
|
27
|
+
spec.add_development_dependency "pry"
|
28
|
+
spec.add_development_dependency "rspec"
|
29
|
+
end
|
@@ -0,0 +1,161 @@
|
|
1
|
+
require 'git'
|
2
|
+
require "capnotify"
|
3
|
+
require "capnotify-commit_log/version"
|
4
|
+
require 'pry'
|
5
|
+
|
6
|
+
module Capnotify
|
7
|
+
module CommitLog
|
8
|
+
|
9
|
+
PLUGIN_NAME = :capnotify_commit_log
|
10
|
+
|
11
|
+
DEFAULT_COMMIT_LOG_ENTRY = {
|
12
|
+
:author => 'n/a',
|
13
|
+
:date => nil,
|
14
|
+
:email => 'n/a',
|
15
|
+
:sha => 'n/a',
|
16
|
+
:message => 'Log output not available.'
|
17
|
+
}
|
18
|
+
|
19
|
+
def self.load_into(config)
|
20
|
+
config.load do
|
21
|
+
on(:load) do
|
22
|
+
capnotify.load_plugin(Capnotify::CommitLog)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def init
|
28
|
+
capnotify.components << Capnotify::Component.new(:capnotify_commit_log) do |c|
|
29
|
+
c.header = 'Log'
|
30
|
+
|
31
|
+
c.css_class = 'commit-log'
|
32
|
+
c.custom_css = <<-CSS
|
33
|
+
ul.commit_log {
|
34
|
+
list-style: none;
|
35
|
+
margin: 0;
|
36
|
+
padding: 0;
|
37
|
+
clear: both;
|
38
|
+
}
|
39
|
+
|
40
|
+
ul.commit_log li {
|
41
|
+
clear: both;
|
42
|
+
display: block;
|
43
|
+
white-space: nowrap;
|
44
|
+
}
|
45
|
+
|
46
|
+
ul.commit_log h4.sha {
|
47
|
+
font-family: monospace;
|
48
|
+
background-color: #eee;
|
49
|
+
color: #666;
|
50
|
+
float: left;
|
51
|
+
padding: 2px 0px;
|
52
|
+
margin: 0;
|
53
|
+
margin-right: 5px;
|
54
|
+
width: 70px;
|
55
|
+
text-align: center;
|
56
|
+
}
|
57
|
+
|
58
|
+
ul.commit_log .commit_body {
|
59
|
+
<!-- float: left; -->
|
60
|
+
white-space: normal;
|
61
|
+
|
62
|
+
margin-left: 75px;
|
63
|
+
}
|
64
|
+
|
65
|
+
ul.commit_log .commit_body h4 {
|
66
|
+
padding: 2px 0px;
|
67
|
+
font-weight: bold;
|
68
|
+
margin: 0;
|
69
|
+
}
|
70
|
+
|
71
|
+
ul.commit_log .commit_body .commit_message {
|
72
|
+
white-space: pre-wrap;
|
73
|
+
font-family: monospace;
|
74
|
+
}
|
75
|
+
|
76
|
+
ul.commit_log a {
|
77
|
+
font-weight: bold;
|
78
|
+
text-decoration: none;
|
79
|
+
}
|
80
|
+
|
81
|
+
ul.commit_log a:hover {
|
82
|
+
text-decoration: underline;
|
83
|
+
}
|
84
|
+
CSS
|
85
|
+
|
86
|
+
c.template_path = File.join( File.dirname(__FILE__), 'templates' )
|
87
|
+
|
88
|
+
c.render_for :html => '_commit_log.html.erb', :txt => '_commit_log.txt.erb'
|
89
|
+
|
90
|
+
c.content = commit_log(fetch(:previous_revision, nil), fetch(:real_revision, nil))
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
def unload
|
95
|
+
capnotify.delete_component :capnotify_commit_log
|
96
|
+
end
|
97
|
+
|
98
|
+
# locate the git repository for the project
|
99
|
+
# starting with the local_git_repository_path
|
100
|
+
# or current working directory (or path, if specified),
|
101
|
+
# traverse the filesystem going up until we hit a git repository.
|
102
|
+
# returns nil if one is not found. otherwise returns a Git object
|
103
|
+
def find_git_repo(path=nil)
|
104
|
+
# use local_git_repository_path or Dir.pwd if path is not specified
|
105
|
+
path = fetch(:local_git_repository_path, Dir.pwd) if path.nil?
|
106
|
+
|
107
|
+
# expand the path
|
108
|
+
path = File.expand_path(path)
|
109
|
+
|
110
|
+
return nil if path == '/'
|
111
|
+
|
112
|
+
# try to open the current path
|
113
|
+
# if fail, go up a directory
|
114
|
+
begin
|
115
|
+
::Git.open(path)
|
116
|
+
rescue ArgumentError
|
117
|
+
find_git_repo(File.join(path, '..'))
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
# git log between +first_ref+ to +last_ref+
|
122
|
+
# memoizes the output so this function can be called multiple times without re-running
|
123
|
+
# FIXME: memoization does not account for arguments
|
124
|
+
# FIXME: this should probably use the git gem
|
125
|
+
# FIXME: this only supports git.
|
126
|
+
#
|
127
|
+
# returns an array of 2-element arrays in the form of
|
128
|
+
# [ ref, log_text ]
|
129
|
+
def commit_log(first_ref, last_ref)
|
130
|
+
puts "running commit log"
|
131
|
+
return @commit_log unless @commit_log.nil?
|
132
|
+
|
133
|
+
git = find_git_repo
|
134
|
+
|
135
|
+
begin
|
136
|
+
raise "Ref missing" if first_ref.nil? || last_ref.nil? # jump to rescue block.
|
137
|
+
|
138
|
+
log_results = git.log.between(first_ref, last_ref)
|
139
|
+
|
140
|
+
@commit_log = log_results.map do |log|
|
141
|
+
{
|
142
|
+
:author => log.author.name,
|
143
|
+
:date => log.date,
|
144
|
+
:email => log.author.email,
|
145
|
+
:sha => log.sha,
|
146
|
+
:message => log.message
|
147
|
+
}
|
148
|
+
end
|
149
|
+
|
150
|
+
rescue
|
151
|
+
[ DEFAULT_COMMIT_LOG_ENTRY ]
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
if Capistrano::Configuration.instance
|
159
|
+
Capnotify::CommitLog.load_into(Capistrano::Configuration.instance)
|
160
|
+
end
|
161
|
+
|
@@ -0,0 +1,34 @@
|
|
1
|
+
<ul class="commit_log">
|
2
|
+
<% @content.each do |commit| %>
|
3
|
+
<li>
|
4
|
+
<h4 class="sha">
|
5
|
+
<% if config.fetch(:github_url, nil) && commit[:sha].length >= 7 %>
|
6
|
+
<a href="<%= config.github_url %>/commit/<%= commit[:sha] %>"><%= commit[:sha][0,7] %></a>
|
7
|
+
<% else %>
|
8
|
+
<%= commit[:sha][0,7] %>
|
9
|
+
<% end %>
|
10
|
+
</h4>
|
11
|
+
|
12
|
+
<div class="commit_body">
|
13
|
+
<h4>
|
14
|
+
<span class="commit_author">
|
15
|
+
<% if commit[:email].match /@/ %>
|
16
|
+
<%# include the author's name with a link to their email if it's there %>
|
17
|
+
<a href="mailto:<%= commit[:email] %>"><%= commit[:author] %></a>
|
18
|
+
<% else %>
|
19
|
+
<%= commit[:author] %>
|
20
|
+
<% end %>
|
21
|
+
</span>
|
22
|
+
@
|
23
|
+
<span class="commit_date">
|
24
|
+
<%= commit[:date] ? commit[:date].strftime('%Y-%m-%d') : 'n/a' %>
|
25
|
+
</span>
|
26
|
+
</h4>
|
27
|
+
|
28
|
+
<p class="commit_message"><%= commit[:message] %></p>
|
29
|
+
</div>
|
30
|
+
</li>
|
31
|
+
<% end %>
|
32
|
+
</ul>
|
33
|
+
<div style="float:none; clear:both;"><!-- float-fix --></div>
|
34
|
+
|
metadata
ADDED
@@ -0,0 +1,175 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capnotify-commit_log
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Spike Grobstein
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-06-08 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: capnotify
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0.2'
|
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.2'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: git
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '1.2'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '1.2'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: bundler
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '1.3'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.3'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rake
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: awesome_print
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: pry
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: rspec
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
description: Add a detailed Git commit log to your Capnotify deloyment notification
|
127
|
+
emails
|
128
|
+
email:
|
129
|
+
- me@spike.cx
|
130
|
+
executables: []
|
131
|
+
extensions: []
|
132
|
+
extra_rdoc_files: []
|
133
|
+
files:
|
134
|
+
- .gitignore
|
135
|
+
- Gemfile
|
136
|
+
- LICENSE.txt
|
137
|
+
- README.md
|
138
|
+
- Rakefile
|
139
|
+
- capnotify-commit_log.gemspec
|
140
|
+
- lib/capnotify-commit_log.rb
|
141
|
+
- lib/capnotify-commit_log/version.rb
|
142
|
+
- lib/templates/_commit_log.html.erb
|
143
|
+
- lib/templates/_commit_log.txt.erb
|
144
|
+
homepage: ''
|
145
|
+
licenses:
|
146
|
+
- MIT
|
147
|
+
post_install_message:
|
148
|
+
rdoc_options: []
|
149
|
+
require_paths:
|
150
|
+
- lib
|
151
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
152
|
+
none: false
|
153
|
+
requirements:
|
154
|
+
- - ! '>='
|
155
|
+
- !ruby/object:Gem::Version
|
156
|
+
version: '0'
|
157
|
+
segments:
|
158
|
+
- 0
|
159
|
+
hash: -1094105692905918392
|
160
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
161
|
+
none: false
|
162
|
+
requirements:
|
163
|
+
- - ! '>='
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '0'
|
166
|
+
segments:
|
167
|
+
- 0
|
168
|
+
hash: -1094105692905918392
|
169
|
+
requirements: []
|
170
|
+
rubyforge_project:
|
171
|
+
rubygems_version: 1.8.24
|
172
|
+
signing_key:
|
173
|
+
specification_version: 3
|
174
|
+
summary: Git commit log for Capnotify emails
|
175
|
+
test_files: []
|