git-commit-mailer 1.0.1 → 1.0.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3c8f402644de43c9b76f2631aef1603d127d3f12
4
- data.tar.gz: 8306e844d78ee136b1d499f9b9a73d033dcf83c5
3
+ metadata.gz: 50d31e3b90e4835ed78e0fa0ce384d0a49923ec0
4
+ data.tar.gz: 2f1ed65269c3bb8ca435994a888e2a505e30000e
5
5
  SHA512:
6
- metadata.gz: f1a33c639872bbc62c88c86cc4300bba9e6e4e9dcb8c6c32f1acfd619c43dbfc9d3258862a0619d9372f3369e890595f0a9378a56fe7e7dd2deb021673d9085a
7
- data.tar.gz: 223867affd7a3ab35163af1d1528cb19d9c2ad480dd3d0f3d7c2a29ac1dcc76dfe881d1177cd203b842e167ad5671ffeb02391b620a89824e73707abf32674f9
6
+ metadata.gz: 4f16915e4b9a8110cff707dfec33a6f7bcc7a70cfd08085f8c8afd9a9f36a7644eba3bf2ff4ef2cd9cc626e709467f240a314c8777ad9df3d822326ecaa58161
7
+ data.tar.gz: 3ebf21638075b42e1c4b7d02bd2e4a00599ebb9f22b65b90c45d31345f6927b47d782aa633af36faf9982a255f422324e0117af5b00ad03347e242f562dda248
data/.gitignore CHANGED
@@ -2,3 +2,4 @@
2
2
  /Gemfile.lock
3
3
  /vendor/
4
4
  /test/tmp/
5
+ /pkg/
data/doc/text/news.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # News
2
2
 
3
+ ## 1.0.2 - 2015-06-09 {#version-1-0-2}
4
+
5
+ GitHub support improvement release!
6
+
7
+ ### Improvements
8
+
9
+ * Supported GitHub mention link by `@XXX` form in commit message.
10
+ * Supported GitHub commit link by `HHHHHHH` form in commit message.
11
+
12
+ ### Fixes
13
+
14
+ * Fixed a bug that single quote in commit message is treated as
15
+ GitHub issue link.
16
+
3
17
  ## 1.0.1 - 2015-06-09 {#version-1-0-1}
4
18
 
5
19
  GitHub support improvement release!
@@ -214,19 +214,59 @@ class GitCommitMailer
214
214
  def format_summary(summary)
215
215
  case @mailer.repository_browser
216
216
  when "github"
217
- linked_summary = h(summary).gsub(/\#(\d+)/) do
218
- %Q(<a href="#{github_issue_url($1)}">\##{$1}</a>)
219
- end
220
- pre(linked_summary)
217
+ format_summary_github(summary)
221
218
  else
222
219
  pre(h(summary))
223
220
  end
224
221
  end
225
222
 
223
+ GITHUB_MARKUP_PATTERN_ISSUE = /\#\d+/
224
+ GITHUB_MARKUP_PATTERN_COMMIT = /[\da-fA-F]{7,}/
225
+ GITHUB_MARKUP_PATTERN_MENTION = /@[\da-zA-Z\-]+/
226
+ def format_summary_github(summary)
227
+ formatted_summary = summary.gsub(/
228
+ ['&\"<>]|
229
+ #{GITHUB_MARKUP_PATTERN_ISSUE}|
230
+ #{GITHUB_MARKUP_PATTERN_COMMIT}|
231
+ #{GITHUB_MARKUP_PATTERN_MENTION}
232
+ /x) do |matched|
233
+ case matched
234
+ when /\A#{GITHUB_MARKUP_PATTERN_ISSUE}\z/
235
+ issue_number = matched.gsub(/\A\#/, "")
236
+ tag("a",
237
+ {
238
+ "href" => github_issue_url(issue_number),
239
+ },
240
+ h(matched))
241
+ when /\A#{GITHUB_MARKUP_PATTERN_COMMIT}\z/
242
+ revision = matched
243
+ tag("a",
244
+ {
245
+ "href" => commit_url_github(revision),
246
+ },
247
+ h(matched))
248
+ when /\A#{GITHUB_MARKUP_PATTERN_MENTION}\z/
249
+ user_name = matched.gsub(/\A@/, "")
250
+ tag("a",
251
+ {
252
+ "href" => user_url_github(user_name),
253
+ },
254
+ h(matched))
255
+ else
256
+ h(matched)
257
+ end
258
+ end
259
+ pre(formatted_summary)
260
+ end
261
+
226
262
  def github_issue_url(id)
227
263
  "#{@mailer.github_base_url}/#{@mailer.github_user}/#{@mailer.github_repository}/issues/#{id}"
228
264
  end
229
265
 
266
+ def user_url_github(name)
267
+ "#{@mailer.github_base_url}/#{name}"
268
+ end
269
+
230
270
  def tag_start(name, attributes)
231
271
  start_tag = "<#{name}"
232
272
  unless attributes.empty?
@@ -31,12 +31,8 @@ class GitCommitMailer
31
31
  def commit_url
32
32
  case @mailer.repository_browser
33
33
  when "github"
34
- user = @mailer.github_user
35
- repository = @mailer.github_repository
36
- return nil if user.nil? or repository.nil?
37
- base_url = @mailer.github_base_url
38
34
  revision = @info.revision
39
- "#{base_url}/#{user}/#{repository}/commit/#{revision}"
35
+ commit_url_github(revision)
40
36
  when "github-wiki"
41
37
  file = (@info.updated_files + @info.added_files).first
42
38
  commit_file_url_github_wiki(file)
@@ -49,6 +45,15 @@ class GitCommitMailer
49
45
  end
50
46
  end
51
47
 
48
+ def commit_url_github(revision)
49
+ user = @mailer.github_user
50
+ repository = @mailer.github_repository
51
+ return nil if user.nil? or repository.nil?
52
+
53
+ base_url = @mailer.github_base_url
54
+ "#{base_url}/#{user}/#{repository}/commit/#{revision}"
55
+ end
56
+
52
57
  def commit_file_url_github_wiki(file)
53
58
  return nil if file.nil?
54
59
 
@@ -1,4 +1,4 @@
1
1
  class GitCommitMailer
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  URL = "https://github.com/clear-code/git-commit-mailer"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git-commit-mailer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryo Onodera