git-commit-notifier 0.12.0 → 0.12.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/CHANGES.md CHANGED
@@ -2,6 +2,17 @@
2
2
 
3
3
  ## Not yet released
4
4
 
5
+ ## Version 0.12.1
6
+
7
+ * The regular expression adjusted to include the underscore in repo name.
8
+ * More HTML commit messages appearance improvements.
9
+ * Fix the issue of notifications for all commits being sent out when a
10
+ new branch is pushed with unique_commits_per_branch set to false.
11
+ * gitlabhq also supports the character "-" within repository names.
12
+ * Fixing broken links of renamed files in case of gitweb and other interfaces.
13
+ * Do not list commit to closest annotated tag until configuration option set.
14
+ * Show shortlog from previous tag on tag creation.
15
+
5
16
  ## Version 0.12.0
6
17
 
7
18
  * Detects renamed files.
data/README.md CHANGED
@@ -174,6 +174,13 @@ bundle install
174
174
  rake # Run specs
175
175
  ```
176
176
 
177
+ or
178
+
179
+ ```bash
180
+ gem build git-commit-notifier.gemspec
181
+ [sudo] gem install git-commit-notifier-0.11.10.gem
182
+ ```
183
+
177
184
  Now you can create test configuration file (example provided in `config` directory) and test your code over any test repository in this manner:
178
185
 
179
186
  ```bash
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.12.0
1
+ 0.12.1
@@ -225,6 +225,13 @@ ignore_whitespace: all
225
225
  # more than 50% of it has not changed
226
226
  similarity_detection_threshold: "0.5"
227
227
 
228
+ # Show a shortlog of commits since the last tag, when creating an annotated tag
229
+ #
230
+ # Note :: this feature uses git-describe to obtain the information
231
+ # So, if git-describe is not one of your favourite ways to find the nearest tagged-commit, you will refrain from using this feature
232
+ #
233
+ show_a_shortlog_of_commits_since_the_last_annotated_tag: false
234
+
228
235
  # This is developer debugging options. Do not uncomment it if You aren't Jedi
229
236
  # debug:
230
237
  # enabled: true
@@ -195,6 +195,12 @@ module GitCommitNotifier
195
195
 
196
196
  file_name = @current_file_name
197
197
 
198
+ # Adjust filenames and hashes in case of file renames
199
+ if @file_renamed
200
+ file_name = @file_renamed_new_name
201
+ @current_sha = Git.sha_of_filename(@current_commit, file_name)
202
+ end
203
+
198
204
  # TODO: these filenames, etc, should likely be properly html escaped
199
205
  file_link = file_name
200
206
  if config['link_files'] && !@file_removed
@@ -696,6 +702,23 @@ module GitCommitNotifier
696
702
  message_array = tag_info[:contents].split("\n")
697
703
  multi_line_message = message_array.count > 1
698
704
  html += "<dt>Message</dt><dd class='#{multi_line_message ? "multi-line" : ""}'>#{message_array_as_html(message_array)}</dd>\n"
705
+
706
+ if config['show_a_shortlog_of_commits_since_the_last_annotated_tag']
707
+ list_of_commits_in_between = Git.list_of_commits_between_current_commit_and_last_tag(ref_name, tag_info[:tagobject])
708
+ if list_of_commits_in_between.length > 0
709
+ html += "<dt><br/>Commits since the last annotated tag</dt><dd><br/><br/><ul>"
710
+ list_of_commits_in_between.each do |commit|
711
+ if config['link_files'].to_s != "none"
712
+ l = markup_commit_for_html(commit[0])
713
+ l = l.gsub(/>.*<\/a>/,">#{commit[1]}</a>") # Replace the link text with the commit message (the original link text is the commit hash)
714
+ html += "<li>#{l}</li>"
715
+ else
716
+ html += "<li>#{commit[1]}</li>"
717
+ end
718
+ end
719
+ html += "</ul></dd>"
720
+ end
721
+ end
699
722
  html += "</dl>"
700
723
 
701
724
  text = "Tag: #{tag} (#{change_type == :create ? "added" : "updated"})\n"
@@ -725,7 +748,17 @@ module GitCommitNotifier
725
748
  # on this branch without regard to whether they occur on other branches"
726
749
  # The flag unique_to_current_branch passed to new_commits means the
727
750
  # opposite: "consider only commits that are unique to this branch"
728
- Git.new_commits(oldrev, newrev, ref_name, !unique_commits_per_branch?)
751
+
752
+ # Note :: In case of creation of a new branch, the oldrev passed by git
753
+ # to the post-receive hook is 00000... which causes the git commit notifier
754
+ # to send out notifications for ALL commits in the repository. Hence we force
755
+ # the "unique_commits_per_branch" config to "true" in such cases, and in other
756
+ # cases, we consider the value from the config file
757
+ if oldrev =~ /^0+$/
758
+ Git.new_commits(oldrev, newrev, ref_name, true)
759
+ else
760
+ Git.new_commits(oldrev, newrev, ref_name, !unique_commits_per_branch?)
761
+ end
729
762
  end
730
763
 
731
764
  # Add each diff to @result
@@ -70,6 +70,18 @@ class GitCommitNotifier::Git
70
70
  lines.uniq
71
71
  end
72
72
 
73
+ # Returns sha1 of the file after the most recent commit.
74
+ # Runs `git show #{rev}:#{filename} | git hash-object --stdin` to return the sha of the file.
75
+ # @note It was required as when there is a file which is renamed, and it has a 100% similarity index, its sha is not included in the git-show output.
76
+ # @return [String] sha1 of the file name.
77
+ # @see from_shell
78
+ # @param [String] rev revision where we want to get the sha of the file name
79
+ # @param [String] filename File name whose sha1 we want
80
+ def sha_of_filename(rev, filename)
81
+ lines = from_shell("git show #{rev}:#{filename} | git hash-object --stdin")
82
+ lines.strip
83
+ end
84
+
73
85
  # splits the output of changed_files
74
86
  # @return [Hash(Array)] file names sorted by status
75
87
  # @see changed_files
@@ -117,6 +129,31 @@ class GitCommitNotifier::Git
117
129
  from_shell("git rev-parse #{treeish}").strip
118
130
  end
119
131
 
132
+
133
+ # Lists commits between specified rev and closest annotated tag.
134
+ # Uses `git describe` to obtain information.
135
+ # @return [Array] Commit hashes and their messages
136
+ # @param [String] tag_name of the current tag
137
+ # @param [String] rev sha of the commit the tag is associated with
138
+ # @note There have been many complaints about using git describe to obtain this information
139
+ # but, this looked like the best way to obtain the information here.
140
+ # Here is a link http://www.xerxesb.com/2010/git-describe-and-the-tale-of-the-wrong-commits/
141
+ # discussing, the way git-describe handles the problem of finding the nearest commit with a tag.
142
+ # Looking forward to someone coming up with a better way.
143
+ def list_of_commits_between_current_commit_and_last_tag(tag_name, rev)
144
+ result = Array.new
145
+
146
+ lines = from_shell("git describe --abbrev=0 #{rev}^1 2> /dev/null | cat ").strip # the `cat` is used to suppress the error that might arise when handling the case of the first commit
147
+ if lines.length != 1
148
+ previous_tag = lines
149
+ list_of_commits = lines_from_shell("git log #{previous_tag}..#{tag_name} --format='%H::::::%s'")
150
+ list_of_commits.each do |row|
151
+ result << Array.new(row.split("::::::"))
152
+ end
153
+ end
154
+ result
155
+ end
156
+
120
157
  def new_commits(oldrev, newrev, refname, unique_to_current_branch)
121
158
  # We want to get the set of commits (^B1 ^B2 ... ^oldrev newrev)
122
159
  # Where B1, B2, ..., are any other branch
@@ -215,8 +252,8 @@ class GitCommitNotifier::Git
215
252
  if git_path.empty?
216
253
  git_path = git_dir
217
254
  end
218
- name_with_parent = File.expand_path(git_path).scan(/[a-zA-z0-9]+\/[a-zA-Z0-9]+.git$/).first;
219
- return name_with_parent.sub(/\.git$/, '') unless name_with_parent.empty?
255
+ name_with_parent = File.expand_path(git_path).scan(/[a-zA-z0-9\-_]+\/[a-zA-Z0-9\-_]+.git$/).first;
256
+ return name_with_parent.sub(/\.git$/, '') unless name_with_parent.empty?
220
257
  File.expand_path(git_path).split("/").last.sub(/\.git$/, '')
221
258
  end
222
259
 
data/template/styles.css CHANGED
@@ -1,14 +1,27 @@
1
- * {font-size:12px;}
2
- h2 {font-family:Verdana;font-size:12px;background-color: #bbb; font-weight: bold; line-height:25px; margin-bottom:2px; padding-left:5px}
3
- table {width:100%;border-collapse:collapse}
1
+ * {font-size:12px; font-family: Verdana, sans-serif; }
2
+
3
+ h2 {font-size:14px; background-color: #2e7bcc; color: white; font-weight: bold; padding: 10px;}
4
+
5
+ h2 a {color: #FFCC33; text-decoration: none; font-size: 14px; font-weight: bold;}
6
+ h2 a:visited {color: #CCCC66; text-decoration: none; font-size: 14px; font-weight: bold;}
7
+ a, a:visited {color: #0B6CDA; text-decoration: none;}
8
+ a:hover {text-decoration: underline;}
9
+
10
+ .title {background-color: #FFFFCC; padding: 10px; border: 1px solid #FFAA00;}
11
+ dt { float: left; font-weight: bold; min-width: 8em; }
12
+ dt, dd { padding-bottom: 0.5em; }
13
+ dt:after { content: ':'; }
14
+ dd.multi-line { clear: both; margin-left: 0; padding-top: 1em; }
15
+
16
+ ul li { padding-bottom: 0.5em; }
17
+
18
+ table {width:100%; border-collapse:collapse;}
19
+ td {color:#000; font-family: "Bitstream Vera Sans Mono","Monaco","Courier",monospace;}
20
+ td.sep {text-align:center; border-top:1px solid DimGray; border-bottom:1px solid DimGray;}
21
+
22
+ .ln {background-color: white; width: 35px; padding-right: 5px; text-align:right; color: #666; border-right: 1px solid #ccc; }
23
+
4
24
  .r {background-color: #fdd;}
5
25
  .rr {background-color: #faa;}
6
26
  .a {background-color: #dfd;}
7
27
  .aa {background-color: #afa;}
8
- .title {background-color: #ddd; padding: 10px;font-family:Verdana;font-size:12px;}
9
- dt { float: left; font-weight: bold; min-width: 6em; }
10
- dt:after { content: ':'; }
11
- dd.multi-line { clear: both; margin-left: 0; padding-top: 1em; }
12
- td {color:#000;font-family: "Bitstream Vera Sans Mono","Monaco","Courier",monospace}
13
- .ln {background-color: #ccc; width:23px; text-align:right}
14
- td.sep {text-align:center;border-top:1px solid DimGray;border-bottom:1px solid DimGray;}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git-commit-notifier
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.0
4
+ version: 0.12.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-06-30 00:00:00.000000000 Z
13
+ date: 2013-08-29 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: diff-lcs
@@ -339,7 +339,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
339
339
  version: '0'
340
340
  segments:
341
341
  - 0
342
- hash: -459626784997908862
342
+ hash: -137437954914361840
343
343
  required_rubygems_version: !ruby/object:Gem::Requirement
344
344
  none: false
345
345
  requirements: