git-commit-notifier 0.12.6 → 0.12.10
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 +4 -4
 - data/CHANGES.md +4 -0
 - data/VERSION +1 -1
 - data/config/git-notifier-config.example.yml +7 -1
 - data/lib/git_commit_notifier/commit_hook.rb +8 -7
 - data/lib/git_commit_notifier/diff_to_html.rb +61 -24
 - data/lib/git_commit_notifier/emailer.rb +18 -1
 - data/lib/git_commit_notifier/escape_helper.rb +8 -0
 - data/spec/lib/git_commit_notifier/diff_to_html_spec.rb +30 -0
 - data/template/email.html.erb +9 -0
 - metadata +3 -3
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: aa06b0dab1d471d02e72bfa233799193e8f70f24
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 7d3d46cf47943e7ccf971c96b884e9f8e1ae7c78
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 4d48398f5f1b80f5c5d819bef22da24503415fcc34591b22cecb6d20212db5ba9ea1fbdc555de4fc11a5d4408ff52999daec10e6a04e6185904cf3dc3bdb7501
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: a62a8662e05fbe551e9581cce82246834d6d509a55e5d50f2f46c103eb82e8f8ef2809c0161732667cece693c28c1d4b12958935002e7e154963899cb521b216
         
     | 
    
        data/CHANGES.md
    CHANGED
    
    
    
        data/VERSION
    CHANGED
    
    | 
         @@ -1 +1 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            0.12. 
     | 
| 
      
 1 
     | 
    
         
            +
            0.12.10
         
     | 
| 
         @@ -130,7 +130,7 @@ nntp_settings: 
     | 
|
| 
       130 
130 
     | 
    
         
             
              port: 119
         
     | 
| 
       131 
131 
     | 
    
         | 
| 
       132 
132 
     | 
    
         
             
            # Decorate files and commit ids with link to a webview. Possible values: none, gitweb,
         
     | 
| 
       133 
     | 
    
         
            -
            # gitorious, cgit, trac, gitlabhq, gitalist, github or  
     | 
| 
      
 133 
     | 
    
         
            +
            # gitorious, cgit, trac, gitlabhq, gitalist, github, redmine, or stash
         
     | 
| 
       134 
134 
     | 
    
         
             
            link_files: none
         
     | 
| 
       135 
135 
     | 
    
         | 
| 
       136 
136 
     | 
    
         
             
            # If link_files is set to "gitweb", you need to configure the path to your gitweb
         
     | 
| 
         @@ -157,6 +157,8 @@ cgit: 
     | 
|
| 
       157 
157 
     | 
    
         
             
            # instance
         
     | 
| 
       158 
158 
     | 
    
         
             
            trac:
         
     | 
| 
       159 
159 
     | 
    
         
             
              path: http://example.com/changeset
         
     | 
| 
      
 160 
     | 
    
         
            +
            # repository: test.git
         
     | 
| 
      
 161 
     | 
    
         
            +
            # repository defaults to nil (link to trac's default repository)
         
     | 
| 
       160 
162 
     | 
    
         | 
| 
       161 
163 
     | 
    
         
             
            # If link_files is set to "gitlabhq", you need to configure the path to your gitlabhq
         
     | 
| 
       162 
164 
     | 
    
         
             
            # instance
         
     | 
| 
         @@ -184,6 +186,10 @@ redmine: 
     | 
|
| 
       184 
186 
     | 
    
         
             
            # keywords: [refs, fixes]
         
     | 
| 
       185 
187 
     | 
    
         
             
            # project defaults to git repository name, keywords defaults to refs, fixes (for use with message_integration)
         
     | 
| 
       186 
188 
     | 
    
         | 
| 
      
 189 
     | 
    
         
            +
            # if link_files is set to "stash", you need to configure the path to your stash
         
     | 
| 
      
 190 
     | 
    
         
            +
            # instance
         
     | 
| 
      
 191 
     | 
    
         
            +
            stash:
         
     | 
| 
      
 192 
     | 
    
         
            +
              path: http://stash.example.com
         
     | 
| 
       187 
193 
     | 
    
         | 
| 
       188 
194 
     | 
    
         
             
            # commit message URL map
         
     | 
| 
       189 
195 
     | 
    
         
             
            message_map:
         
     | 
| 
         @@ -45,7 +45,7 @@ module GitCommitNotifier 
     | 
|
| 
       45 
45 
     | 
    
         
             
                  end
         
     | 
| 
       46 
46 
     | 
    
         | 
| 
       47 
47 
     | 
    
         
             
                  def add_committer_to_recipient(recipient, committer_email)
         
     | 
| 
       48 
     | 
    
         
            -
                    if email?(committer_email) 
     | 
| 
      
 48 
     | 
    
         
            +
                    if email?(committer_email)
         
     | 
| 
       49 
49 
     | 
    
         
             
                      "#{recipient},#{committer_email}"
         
     | 
| 
       50 
50 
     | 
    
         
             
                    else
         
     | 
| 
       51 
51 
     | 
    
         
             
                      recipient
         
     | 
| 
         @@ -105,15 +105,15 @@ module GitCommitNotifier 
     | 
|
| 
       105 
105 
     | 
    
         
             
                  # @return [NilClass] nil
         
     | 
| 
       106 
106 
     | 
    
         
             
                  # @see config
         
     | 
| 
       107 
107 
     | 
    
         
             
                  def run(config_name, rev1, rev2, ref_name)
         
     | 
| 
       108 
     | 
    
         
            -
             
     | 
| 
      
 108 
     | 
    
         
            +
             
     | 
| 
       109 
109 
     | 
    
         
             
                    if @start_time.nil?
         
     | 
| 
       110 
110 
     | 
    
         
             
                      @start_time = Time.new
         
     | 
| 
       111 
111 
     | 
    
         
             
                      @start_time_offset = 0
         
     | 
| 
       112 
112 
     | 
    
         
             
                    end
         
     | 
| 
       113 
113 
     | 
    
         | 
| 
       114 
114 
     | 
    
         
             
                    # Load the configuration
         
     | 
| 
       115 
     | 
    
         
            -
                    if File.exists?(config_name) 
     | 
| 
       116 
     | 
    
         
            -
                      @config = YAML::load_file(config_name) 
     | 
| 
      
 115 
     | 
    
         
            +
                    if File.exists?(config_name)
         
     | 
| 
      
 116 
     | 
    
         
            +
                      @config = YAML::load_file(config_name)
         
     | 
| 
       117 
117 
     | 
    
         
             
                    else
         
     | 
| 
       118 
118 
     | 
    
         
             
                      GitCommitNotifier::CommitHook.info("Unable to find configuration file: #{config_name}")
         
     | 
| 
       119 
119 
     | 
    
         
             
                      @config = {}
         
     | 
| 
         @@ -255,7 +255,7 @@ module GitCommitNotifier 
     | 
|
| 
       255 
255 
     | 
    
         
             
                          :repo_name => repo_name
         
     | 
| 
       256 
256 
     | 
    
         
             
                        )
         
     | 
| 
       257 
257 
     | 
    
         
             
                        webhook.send
         
     | 
| 
       258 
     | 
    
         
            -
             
     | 
| 
      
 258 
     | 
    
         
            +
             
     | 
| 
       259 
259 
     | 
    
         
             
                        @start_time_offset += 1
         
     | 
| 
       260 
260 
     | 
    
         
             
                      end
         
     | 
| 
       261 
261 
     | 
    
         
             
                    else
         
     | 
| 
         @@ -288,7 +288,8 @@ module GitCommitNotifier 
     | 
|
| 
       288 
288 
     | 
    
         
             
                          :old_rev => rev1,
         
     | 
| 
       289 
289 
     | 
    
         
             
                          :new_rev => rev2,
         
     | 
| 
       290 
290 
     | 
    
         
             
                          :ref_name => ref_name,
         
     | 
| 
       291 
     | 
    
         
            -
                          :repo_name => repo_name
         
     | 
| 
      
 291 
     | 
    
         
            +
                          :repo_name => repo_name,
         
     | 
| 
      
 292 
     | 
    
         
            +
                          :message_link => result[:commit_link]
         
     | 
| 
       292 
293 
     | 
    
         
             
                        )
         
     | 
| 
       293 
294 
     | 
    
         
             
                        emailer.send
         
     | 
| 
       294 
295 
     | 
    
         | 
| 
         @@ -309,7 +310,7 @@ module GitCommitNotifier 
     | 
|
| 
       309 
310 
     | 
    
         
             
                        end
         
     | 
| 
       310 
311 
     | 
    
         | 
| 
       311 
312 
     | 
    
         
             
                        commit_number += 1
         
     | 
| 
       312 
     | 
    
         
            -
             
     | 
| 
      
 313 
     | 
    
         
            +
             
     | 
| 
       313 
314 
     | 
    
         
             
                        @start_time_offset += 1
         
     | 
| 
       314 
315 
     | 
    
         
             
                      end
         
     | 
| 
       315 
316 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -211,13 +211,34 @@ module GitCommitNotifier 
     | 
|
| 
       211 
211 
     | 
    
         | 
| 
       212 
212 
     | 
    
         
             
                  # TODO: these filenames, etc, should likely be properly html escaped
         
     | 
| 
       213 
213 
     | 
    
         
             
                  file_link = file_name
         
     | 
| 
      
 214 
     | 
    
         
            +
                  if config['link_files'] && !@file_removed
         
     | 
| 
      
 215 
     | 
    
         
            +
                    file_link = generate_file_link(file_name)
         
     | 
| 
      
 216 
     | 
    
         
            +
                  end
         
     | 
| 
      
 217 
     | 
    
         
            +
             
     | 
| 
      
 218 
     | 
    
         
            +
                  if show_summary?
         
     | 
| 
      
 219 
     | 
    
         
            +
                    @file_changes << {
         
     | 
| 
      
 220 
     | 
    
         
            +
                      :file_name => file_name,
         
     | 
| 
      
 221 
     | 
    
         
            +
                      :text => "#{op} #{binary}file #{file_name}",
         
     | 
| 
      
 222 
     | 
    
         
            +
                    }
         
     | 
| 
      
 223 
     | 
    
         
            +
                  end
         
     | 
| 
      
 224 
     | 
    
         
            +
             
     | 
| 
      
 225 
     | 
    
         
            +
                  "<a name=\"#{file_name}\"></a><h2>#{op} #{binary}file #{file_link}</h2>\n"
         
     | 
| 
      
 226 
     | 
    
         
            +
                end
         
     | 
| 
      
 227 
     | 
    
         
            +
             
     | 
| 
      
 228 
     | 
    
         
            +
                def generate_file_link(file_name)
         
     | 
| 
       214 
229 
     | 
    
         
             
                  if config['link_files'] && !@file_removed
         
     | 
| 
       215 
230 
     | 
    
         
             
                    file_link = if config["link_files"] == "gitweb" && config["gitweb"]
         
     | 
| 
       216 
231 
     | 
    
         
             
                      "<a href='#{config['gitweb']['path']}?p=#{config['gitweb']['project'] || "#{Git.repo_name}.git"};f=#{file_name};h=#{@current_sha};hb=#{@current_commit}'>#{file_name}</a>"
         
     | 
| 
       217 
232 
     | 
    
         
             
                    elsif config["link_files"] == "gitorious" && config["gitorious"]
         
     | 
| 
       218 
233 
     | 
    
         
             
                      "<a href='#{config['gitorious']['path']}/#{config['gitorious']['project']}/#{config['gitorious']['repository']}/blobs/#{branch_name}/#{file_name}'>#{file_name}</a>"
         
     | 
| 
       219 
234 
     | 
    
         
             
                    elsif config["link_files"] == "trac" && config["trac"]
         
     | 
| 
       220 
     | 
    
         
            -
                       
     | 
| 
      
 235 
     | 
    
         
            +
                      if config["trac"]["repository"]
         
     | 
| 
      
 236 
     | 
    
         
            +
                        "<a href='#{config['trac']['path']}/#{@current_commit}/#{config['trac']['repository']}/#{file_name}'>#{file_name}</a>"
         
     | 
| 
      
 237 
     | 
    
         
            +
                      else
         
     | 
| 
      
 238 
     | 
    
         
            +
                        "<a href='#{config['trac']['path']}/#{@current_commit}/#{file_name}'>#{file_name}</a>"
         
     | 
| 
      
 239 
     | 
    
         
            +
                      end
         
     | 
| 
      
 240 
     | 
    
         
            +
                    elsif config["link_files"] == "stash" && config["stash"]
         
     | 
| 
      
 241 
     | 
    
         
            +
                      "<a href='#{config['stash']['path']}/repos/#{config['stash']['repository']}/browse/#{file_name}?at=#{@current_commit}'>#{file_name}</a>"
         
     | 
| 
       221 
242 
     | 
    
         
             
                    elsif config["link_files"] == "cgit" && config["cgit"]
         
     | 
| 
       222 
243 
     | 
    
         
             
                      "<a href='#{config['cgit']['path']}/#{config['cgit']['project'] || "#{Git.repo_name_real}"}/tree/#{file_name}?h=#{branch_name}'>#{file_name}</a>"
         
     | 
| 
       223 
244 
     | 
    
         
             
                    elsif config["link_files"] == "gitlabhq" && config["gitlabhq"]
         
     | 
| 
         @@ -240,15 +261,6 @@ module GitCommitNotifier 
     | 
|
| 
       240 
261 
     | 
    
         
             
                      file_name
         
     | 
| 
       241 
262 
     | 
    
         
             
                    end
         
     | 
| 
       242 
263 
     | 
    
         
             
                  end
         
     | 
| 
       243 
     | 
    
         
            -
             
     | 
| 
       244 
     | 
    
         
            -
                  if show_summary?
         
     | 
| 
       245 
     | 
    
         
            -
                    @file_changes << {
         
     | 
| 
       246 
     | 
    
         
            -
                      :file_name => file_name, 
         
     | 
| 
       247 
     | 
    
         
            -
                      :text => "#{op} #{binary}file #{file_name}",
         
     | 
| 
       248 
     | 
    
         
            -
                    }
         
     | 
| 
       249 
     | 
    
         
            -
                  end
         
     | 
| 
       250 
     | 
    
         
            -
             
     | 
| 
       251 
     | 
    
         
            -
                  "<a name=\"#{file_name}\"></a><h2>#{op} #{binary}file #{file_link}</h2>\n"
         
     | 
| 
       252 
264 
     | 
    
         
             
                end
         
     | 
| 
       253 
265 
     | 
    
         | 
| 
       254 
266 
     | 
    
         
             
                # Determines are two lines are sequentially placed in diff (no skipped lines between).
         
     | 
| 
         @@ -276,7 +288,7 @@ module GitCommitNotifier 
     | 
|
| 
       276 
288 
     | 
    
         
             
                    if @file_renamed
         
     | 
| 
       277 
289 
     | 
    
         
             
                      @diff_result << "<tr class='renamed'>\n<td class='ln'> </td><td class='ln'></td><td> <u>#{@file_renamed_old_name}</u> was renamed to <u>#{@file_renamed_new_name}</u></td></tr>"
         
     | 
| 
       278 
290 
     | 
    
         
             
                    end
         
     | 
| 
       279 
     | 
    
         
            -
             
     | 
| 
      
 291 
     | 
    
         
            +
             
     | 
| 
       280 
292 
     | 
    
         
             
                    removals = []
         
     | 
| 
       281 
293 
     | 
    
         
             
                    additions = []
         
     | 
| 
       282 
294 
     | 
    
         | 
| 
         @@ -324,6 +336,7 @@ module GitCommitNotifier 
     | 
|
| 
       324 
336 
     | 
    
         
             
                  @binary = false
         
     | 
| 
       325 
337 
     | 
    
         
             
                end
         
     | 
| 
       326 
338 
     | 
    
         | 
| 
      
 339 
     | 
    
         
            +
                RE_DIFF_FILE_NAME_ESCAPED = /^diff --git "a\/(.*)" "?b\//
         
     | 
| 
       327 
340 
     | 
    
         
             
                RE_DIFF_FILE_NAME = /^diff\s\-\-git\sa\/(.*)\sb\//
         
     | 
| 
       328 
341 
     | 
    
         
             
                RE_DIFF_SHA       = /^index [0-9a-fA-F]+\.\.([0-9a-fA-F]+)/
         
     | 
| 
       329 
342 
     | 
    
         | 
| 
         @@ -355,6 +368,10 @@ module GitCommitNotifier 
     | 
|
| 
       355 
368 
     | 
    
         
             
                      file_name = $1
         
     | 
| 
       356 
369 
     | 
    
         
             
                      add_changes_to_result
         
     | 
| 
       357 
370 
     | 
    
         
             
                      @current_file_name = file_name
         
     | 
| 
      
 371 
     | 
    
         
            +
                    when RE_DIFF_FILE_NAME_ESCAPED then
         
     | 
| 
      
 372 
     | 
    
         
            +
                      file_name = decode_escaped_filename( $1 )
         
     | 
| 
      
 373 
     | 
    
         
            +
                      add_changes_to_result
         
     | 
| 
      
 374 
     | 
    
         
            +
                      @current_file_name = file_name
         
     | 
| 
       358 
375 
     | 
    
         
             
                    when RE_DIFF_SHA then
         
     | 
| 
       359 
376 
     | 
    
         
             
                      @current_sha = $1
         
     | 
| 
       360 
377 
     | 
    
         
             
                    else
         
     | 
| 
         @@ -547,7 +564,16 @@ module GitCommitNotifier 
     | 
|
| 
       547 
564 
     | 
    
         
             
                COMMIT_LINK_MAP = {
         
     | 
| 
       548 
565 
     | 
    
         
             
                  :gitweb    => lambda { |config, commit| "<a href='#{config['gitweb']['path']}?p=#{config['gitweb']['project'] || "#{Git.repo_name}.git"};a=commitdiff;h=#{commit}'>#{commit}</a>" },
         
     | 
| 
       549 
566 
     | 
    
         
             
                  :gitorious => lambda { |config, commit| "<a href='#{config['gitorious']['path']}/#{config['gitorious']['project']}/#{config['gitorious']['repository']}/commit/#{commit}'>#{commit}</a>" },
         
     | 
| 
       550 
     | 
    
         
            -
                  :trac      => lambda { |config, commit| 
     | 
| 
      
 567 
     | 
    
         
            +
                  :trac      => lambda { |config, commit|
         
     | 
| 
      
 568 
     | 
    
         
            +
                    if config['trac']['repository']
         
     | 
| 
      
 569 
     | 
    
         
            +
                      "<a href='#{config['trac']['path']}/#{commit}/#{config['trac']['repository']}'>#{commit}</a>"
         
     | 
| 
      
 570 
     | 
    
         
            +
                    else
         
     | 
| 
      
 571 
     | 
    
         
            +
                      "<a href='#{config['trac']['path']}/#{commit}'>#{commit}</a>"
         
     | 
| 
      
 572 
     | 
    
         
            +
                    end
         
     | 
| 
      
 573 
     | 
    
         
            +
                  },
         
     | 
| 
      
 574 
     | 
    
         
            +
                  :stash     => lambda { |config, commit|
         
     | 
| 
      
 575 
     | 
    
         
            +
                    "<a href='#{config['stash']['path']}/repos/#{config['stash']['repository']}/commits/#{commit}'>#{commit}</a>"
         
     | 
| 
      
 576 
     | 
    
         
            +
                  },
         
     | 
| 
       551 
577 
     | 
    
         
             
                  :cgit      => lambda { |config, commit| "<a href='#{config['cgit']['path']}/#{config['cgit']['project'] || "#{Git.repo_name_real}"}/commit/?id=#{commit}'>#{commit}</a>" },
         
     | 
| 
       552 
578 
     | 
    
         
             
                  :gitlabhq  => lambda { |config, commit|
         
     | 
| 
       553 
579 
     | 
    
         
             
                    if config['gitlabhq']['version'] >= 5.0
         
     | 
| 
         @@ -575,6 +601,11 @@ module GitCommitNotifier 
     | 
|
| 
       575 
601 
     | 
    
         
             
                  COMMIT_LINK_MAP[mode].call(config, commit)
         
     | 
| 
       576 
602 
     | 
    
         
             
                end
         
     | 
| 
       577 
603 
     | 
    
         | 
| 
      
 604 
     | 
    
         
            +
                def extract_link(a_tag)
         
     | 
| 
      
 605 
     | 
    
         
            +
                  m = /href\s*=\s*["']([^"']+)["']/i.match(a_tag)
         
     | 
| 
      
 606 
     | 
    
         
            +
                  m && m[1]
         
     | 
| 
      
 607 
     | 
    
         
            +
                end
         
     | 
| 
      
 608 
     | 
    
         
            +
             
     | 
| 
       578 
609 
     | 
    
         
             
                def diff_for_commit(commit)
         
     | 
| 
       579 
610 
     | 
    
         
             
                  @current_commit = commit
         
     | 
| 
       580 
611 
     | 
    
         
             
                  raw_diff = truncate_long_lines(Git.show(commit, :ignore_whitespace => ignore_whitespace))
         
     | 
| 
         @@ -603,8 +634,9 @@ module GitCommitNotifier 
     | 
|
| 
       603 
634 
     | 
    
         
             
                    changed_files = "Changed files:\n\n#{changed_file_list.uniq.join()}\n"
         
     | 
| 
       604 
635 
     | 
    
         
             
                  end
         
     | 
| 
       605 
636 
     | 
    
         | 
| 
      
 637 
     | 
    
         
            +
                  commit_link = markup_commit_for_html(commit_info[:commit])
         
     | 
| 
       606 
638 
     | 
    
         
             
                  title = "<dl class=\"title\">"
         
     | 
| 
       607 
     | 
    
         
            -
                  title += "<dt>Commit</dt><dd>#{ 
     | 
| 
      
 639 
     | 
    
         
            +
                  title += "<dt>Commit</dt><dd>#{commit_link}</dd>\n"
         
     | 
| 
       608 
640 
     | 
    
         
             
                  title += "<dt>Branch</dt><dd>#{CGI.escapeHTML(branch_name)}</dd>\n" if branch_name
         
     | 
| 
       609 
641 
     | 
    
         | 
| 
       610 
642 
     | 
    
         
             
                  title += "<dt>Author</dt><dd>#{CGI.escapeHTML(commit_info[:author])} <#{commit_info[:email]}></dd>\n"
         
     | 
| 
         @@ -650,7 +682,8 @@ module GitCommitNotifier 
     | 
|
| 
       650 
682 
     | 
    
         
             
                  {
         
     | 
| 
       651 
683 
     | 
    
         
             
                    :commit_info  => commit_info,
         
     | 
| 
       652 
684 
     | 
    
         
             
                    :html_content => html,
         
     | 
| 
       653 
     | 
    
         
            -
                    :text_content => text
         
     | 
| 
      
 685 
     | 
    
         
            +
                    :text_content => text,
         
     | 
| 
      
 686 
     | 
    
         
            +
                    :commit_link  => extract_link( commit_link ),
         
     | 
| 
       654 
687 
     | 
    
         
             
                  }
         
     | 
| 
       655 
688 
     | 
    
         
             
                end
         
     | 
| 
       656 
689 
     | 
    
         | 
| 
         @@ -658,11 +691,12 @@ module GitCommitNotifier 
     | 
|
| 
       658 
691 
     | 
    
         | 
| 
       659 
692 
     | 
    
         
             
                  if change_type == :delete
         
     | 
| 
       660 
693 
     | 
    
         
             
                    message = "Remove Lightweight Tag #{tag}"
         
     | 
| 
      
 694 
     | 
    
         
            +
                    commit_link = markup_commit_for_html(rev)
         
     | 
| 
       661 
695 
     | 
    
         | 
| 
       662 
696 
     | 
    
         
             
                    html = "<dl class='title'>"
         
     | 
| 
       663 
697 
     | 
    
         
             
                    html += "<dt>Tag</dt><dd>#{CGI.escapeHTML(tag)} (removed)</dd>\n"
         
     | 
| 
       664 
698 
     | 
    
         
             
                    html += "<dt>Type</dt><dd>lightweight</dd>\n"
         
     | 
| 
       665 
     | 
    
         
            -
                    html += "<dt>Commit</dt><dd>#{ 
     | 
| 
      
 699 
     | 
    
         
            +
                    html += "<dt>Commit</dt><dd>#{commit_link}</dd>\n"
         
     | 
| 
       666 
700 
     | 
    
         
             
                    html += "</dl>"
         
     | 
| 
       667 
701 
     | 
    
         | 
| 
       668 
702 
     | 
    
         
             
                    text = "Remove Tag: #{tag}\n"
         
     | 
| 
         @@ -690,7 +724,8 @@ module GitCommitNotifier 
     | 
|
| 
       690 
724 
     | 
    
         
             
                  @result << {
         
     | 
| 
       691 
725 
     | 
    
         
             
                    :commit_info => commit_info,
         
     | 
| 
       692 
726 
     | 
    
         
             
                    :html_content => html,
         
     | 
| 
       693 
     | 
    
         
            -
                    :text_content => text
         
     | 
| 
      
 727 
     | 
    
         
            +
                    :text_content => text,
         
     | 
| 
      
 728 
     | 
    
         
            +
                    :commit_link => extract_link( commit_link )
         
     | 
| 
       694 
729 
     | 
    
         
             
                  }
         
     | 
| 
       695 
730 
     | 
    
         
             
                end
         
     | 
| 
       696 
731 
     | 
    
         | 
| 
         @@ -714,11 +749,12 @@ module GitCommitNotifier 
     | 
|
| 
       714 
749 
     | 
    
         
             
                    tag_info = Git.tag_info(ref_name)
         
     | 
| 
       715 
750 
     | 
    
         | 
| 
       716 
751 
     | 
    
         
             
                    message = tag_info[:subject] || "#{change_type == :create ? "Add" : "Update"} Annotated Tag #{tag}"
         
     | 
| 
      
 752 
     | 
    
         
            +
                    commit_link = markup_commit_for_html(tag_info[:tagobject])
         
     | 
| 
       717 
753 
     | 
    
         | 
| 
       718 
754 
     | 
    
         
             
                    html = "<dl class='title'>"
         
     | 
| 
       719 
755 
     | 
    
         
             
                    html += "<dt>Tag</dt><dd>#{CGI.escapeHTML(tag)} (#{change_type == :create ? "added" : "updated"})</dd>\n"
         
     | 
| 
       720 
756 
     | 
    
         
             
                    html += "<dt>Type</dt><dd>annotated</dd>\n"
         
     | 
| 
       721 
     | 
    
         
            -
                    html += "<dt>Commit</dt><dd>#{ 
     | 
| 
      
 757 
     | 
    
         
            +
                    html += "<dt>Commit</dt><dd>#{commit_link}</dd>\n"
         
     | 
| 
       722 
758 
     | 
    
         
             
                    html += "<dt>Tagger</dt><dd>#{CGI.escapeHTML(tag_info[:taggername])} #{CGI.escapeHTML(tag_info[:taggeremail])}</dd>\n"
         
     | 
| 
       723 
759 
     | 
    
         | 
| 
       724 
760 
     | 
    
         
             
                    message_array = tag_info[:contents].split("\n")
         
     | 
| 
         @@ -728,7 +764,7 @@ module GitCommitNotifier 
     | 
|
| 
       728 
764 
     | 
    
         
             
                    if config['show_a_shortlog_of_commits_since_the_last_annotated_tag']
         
     | 
| 
       729 
765 
     | 
    
         
             
                      list_of_commits_in_between = Git.list_of_commits_between_current_commit_and_last_tag(ref_name, tag_info[:tagobject])
         
     | 
| 
       730 
766 
     | 
    
         
             
                      if list_of_commits_in_between.length > 0
         
     | 
| 
       731 
     | 
    
         
            -
                        html += "<dt><br/>Commits since the last annotated tag</dt><dd><br/><br/><ul>" 
     | 
| 
      
 767 
     | 
    
         
            +
                        html += "<dt><br/>Commits since the last annotated tag</dt><dd><br/><br/><ul>"
         
     | 
| 
       732 
768 
     | 
    
         
             
                        list_of_commits_in_between.each do |commit|
         
     | 
| 
       733 
769 
     | 
    
         
             
                          if config['link_files'].to_s != "none"
         
     | 
| 
       734 
770 
     | 
    
         
             
                            l = markup_commit_for_html(commit[0])
         
     | 
| 
         @@ -754,9 +790,10 @@ module GitCommitNotifier 
     | 
|
| 
       754 
790 
     | 
    
         
             
                  end
         
     | 
| 
       755 
791 
     | 
    
         | 
| 
       756 
792 
     | 
    
         
             
                  @result << {
         
     | 
| 
       757 
     | 
    
         
            -
                    :commit_info 
     | 
| 
      
 793 
     | 
    
         
            +
                    :commit_info  => commit_info,
         
     | 
| 
       758 
794 
     | 
    
         
             
                    :html_content => html,
         
     | 
| 
       759 
     | 
    
         
            -
                    :text_content => text
         
     | 
| 
      
 795 
     | 
    
         
            +
                    :text_content => text,
         
     | 
| 
      
 796 
     | 
    
         
            +
                    :commit_link  => extract_link( commit_link )
         
     | 
| 
       760 
797 
     | 
    
         
             
                  }
         
     | 
| 
       761 
798 
     | 
    
         
             
                end
         
     | 
| 
       762 
799 
     | 
    
         | 
| 
         @@ -771,10 +808,10 @@ module GitCommitNotifier 
     | 
|
| 
       771 
808 
     | 
    
         
             
                    # The flag unique_to_current_branch passed to new_commits means the
         
     | 
| 
       772 
809 
     | 
    
         
             
                    # opposite: "consider only commits that are unique to this branch"
         
     | 
| 
       773 
810 
     | 
    
         | 
| 
       774 
     | 
    
         
            -
                   	# Note :: In case of creation of a new branch, the oldrev passed by git 
     | 
| 
       775 
     | 
    
         
            -
                   	# to the post-receive hook is 00000... which causes the git commit notifier 
     | 
| 
       776 
     | 
    
         
            -
                   	# to send out notifications for ALL commits in the repository. Hence we force 
     | 
| 
       777 
     | 
    
         
            -
                   	# the "unique_commits_per_branch" config to "true" in such cases, and in other 
     | 
| 
      
 811 
     | 
    
         
            +
                   	# Note :: In case of creation of a new branch, the oldrev passed by git
         
     | 
| 
      
 812 
     | 
    
         
            +
                   	# to the post-receive hook is 00000... which causes the git commit notifier
         
     | 
| 
      
 813 
     | 
    
         
            +
                   	# to send out notifications for ALL commits in the repository. Hence we force
         
     | 
| 
      
 814 
     | 
    
         
            +
                   	# the "unique_commits_per_branch" config to "true" in such cases, and in other
         
     | 
| 
       778 
815 
     | 
    
         
             
                   	# cases, we consider the value from the config file
         
     | 
| 
       779 
816 
     | 
    
         
             
                    if oldrev =~ /^0+$/
         
     | 
| 
       780 
817 
     | 
    
         
             
                      Git.new_commits(oldrev, newrev, ref_name, true)
         
     | 
| 
         @@ -9,7 +9,24 @@ class GitCommitNotifier::Emailer 
     | 
|
| 
       9 
9 
     | 
    
         
             
              # Default ERB template file path
         
     | 
| 
       10 
10 
     | 
    
         
             
              TEMPLATE = File.join(File.dirname(__FILE__), *'../../template/email.html.erb'.split('/')).freeze
         
     | 
| 
       11 
11 
     | 
    
         
             
              # Instance variable names
         
     | 
| 
       12 
     | 
    
         
            -
              PARAMETERS = %w[ 
     | 
| 
      
 12 
     | 
    
         
            +
              PARAMETERS = %w[
         
     | 
| 
      
 13 
     | 
    
         
            +
                project_path
         
     | 
| 
      
 14 
     | 
    
         
            +
                recipient
         
     | 
| 
      
 15 
     | 
    
         
            +
                from_address
         
     | 
| 
      
 16 
     | 
    
         
            +
                from_alias
         
     | 
| 
      
 17 
     | 
    
         
            +
                reply_to_address
         
     | 
| 
      
 18 
     | 
    
         
            +
                commit_date
         
     | 
| 
      
 19 
     | 
    
         
            +
                current_date
         
     | 
| 
      
 20 
     | 
    
         
            +
                offset_date
         
     | 
| 
      
 21 
     | 
    
         
            +
                subject
         
     | 
| 
      
 22 
     | 
    
         
            +
                text_message
         
     | 
| 
      
 23 
     | 
    
         
            +
                html_message
         
     | 
| 
      
 24 
     | 
    
         
            +
                repo_name
         
     | 
| 
      
 25 
     | 
    
         
            +
                ref_name
         
     | 
| 
      
 26 
     | 
    
         
            +
                old_rev
         
     | 
| 
      
 27 
     | 
    
         
            +
                new_rev
         
     | 
| 
      
 28 
     | 
    
         
            +
                message_link
         
     | 
| 
      
 29 
     | 
    
         
            +
              ].freeze
         
     | 
| 
       13 
30 
     | 
    
         | 
| 
       14 
31 
     | 
    
         
             
              # Gets config.
         
     | 
| 
       15 
32 
     | 
    
         
             
              # @return [Hash] Configuration
         
     | 
| 
         @@ -23,4 +23,12 @@ module GitCommitNotifier::EscapeHelper 
     | 
|
| 
       23 
23 
     | 
    
         
             
              def escape_content(s)
         
     | 
| 
       24 
24 
     | 
    
         
             
                CGI.escapeHTML(expand_tabs(s, 4)).gsub(" ", " ")
         
     | 
| 
       25 
25 
     | 
    
         
             
              end
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
              def decode_escaped_filename( filename )
         
     | 
| 
      
 28 
     | 
    
         
            +
                filename.gsub( /\\\d\d\d\\\d\d\d/ ) { |match|
         
     | 
| 
      
 29 
     | 
    
         
            +
                  mb_char_code  = match.split( '\\' )[ 1, 2 ]
         
     | 
| 
      
 30 
     | 
    
         
            +
                  mb_char_code.map! { |x| x.oct }
         
     | 
| 
      
 31 
     | 
    
         
            +
                  mb_char_code.pack( 'C*' ).force_encoding( 'UTF-8')
         
     | 
| 
      
 32 
     | 
    
         
            +
                }
         
     | 
| 
      
 33 
     | 
    
         
            +
              end
         
     | 
| 
       26 
34 
     | 
    
         
             
            end
         
     | 
| 
         @@ -17,6 +17,36 @@ describe GitCommitNotifier::DiffToHtml do 
     | 
|
| 
       17 
17 
     | 
    
         
             
                end
         
     | 
| 
       18 
18 
     | 
    
         
             
              end
         
     | 
| 
       19 
19 
     | 
    
         | 
| 
      
 20 
     | 
    
         
            +
              describe :generate_file_link do
         
     | 
| 
      
 21 
     | 
    
         
            +
                it "should generate proper url for stash" do
         
     | 
| 
      
 22 
     | 
    
         
            +
                  diff = GitCommitNotifier::DiffToHtml.new(
         
     | 
| 
      
 23 
     | 
    
         
            +
                          "link_files" => "stash",
         
     | 
| 
      
 24 
     | 
    
         
            +
                          "stash" => {
         
     | 
| 
      
 25 
     | 
    
         
            +
                            "path" => "http://example.com/projects/TEST",
         
     | 
| 
      
 26 
     | 
    
         
            +
                            "repository" => "TESTREPO"
         
     | 
| 
      
 27 
     | 
    
         
            +
                          })
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
                  mock(GitCommitNotifier::Git).rev_type(REVISIONS[1]) { "commit" }
         
     | 
| 
      
 30 
     | 
    
         
            +
                  mock(GitCommitNotifier::Git).rev_type(REVISIONS[2]) { "commit" }
         
     | 
| 
      
 31 
     | 
    
         
            +
                  mock(GitCommitNotifier::Git).new_commits(anything, anything, anything, anything) { [REVISIONS[1]] }
         
     | 
| 
      
 32 
     | 
    
         
            +
                  [REVISIONS[1]].each do |rev|
         
     | 
| 
      
 33 
     | 
    
         
            +
                    mock(GitCommitNotifier::Git).show(rev, :ignore_whitespace => 'all') { IO.read(FIXTURES_PATH + 'git_show_' + rev) }
         
     | 
| 
      
 34 
     | 
    
         
            +
                    dont_allow(GitCommitNotifier::Git).describe(rev) { IO.read(FIXTURES_PATH + 'git_describe_' + rev) }
         
     | 
| 
      
 35 
     | 
    
         
            +
                  end
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
                  diff.diff_between_revisions REVISIONS[1], REVISIONS[2], 'testproject', 'refs/heads/master'
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
                  diff.result.should have(1).commits # one result for each of the commits
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
                  diff.result.each do |html|
         
     | 
| 
      
 42 
     | 
    
         
            +
                    html.should_not be_include('@@') # diff correctly processed
         
     | 
| 
      
 43 
     | 
    
         
            +
                  end
         
     | 
| 
      
 44 
     | 
    
         
            +
             
         
     | 
| 
      
 45 
     | 
    
         
            +
                  expect(diff.generate_file_link("x/file1.html")).to \
         
     | 
| 
      
 46 
     | 
    
         
            +
                    eq("<a href='http://example.com/projects/TEST/repos/TESTREPO/browse/x/file1.html?at=a4629e707d80a5769f7a71ca6ed9471015e14dc9'>x/file1.html</a>")
         
     | 
| 
      
 47 
     | 
    
         
            +
                end
         
     | 
| 
      
 48 
     | 
    
         
            +
              end
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
       20 
50 
     | 
    
         
             
              describe :lines_are_sequential? do
         
     | 
| 
       21 
51 
     | 
    
         
             
                before(:all) do
         
     | 
| 
       22 
52 
     | 
    
         
             
                  @diff_to_html = GitCommitNotifier::DiffToHtml.new
         
     | 
    
        data/template/email.html.erb
    CHANGED
    
    | 
         @@ -6,5 +6,14 @@ 
     | 
|
| 
       6 
6 
     | 
    
         
             
            </head>
         
     | 
| 
       7 
7 
     | 
    
         
             
            <body>
         
     | 
| 
       8 
8 
     | 
    
         
             
            <%= @html_message %>
         
     | 
| 
      
 9 
     | 
    
         
            +
            <% if @message_link %>
         
     | 
| 
      
 10 
     | 
    
         
            +
            <div itemscope itemtype="http://schema.org/EmailMessage">
         
     | 
| 
      
 11 
     | 
    
         
            +
              <div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
         
     | 
| 
      
 12 
     | 
    
         
            +
                <link itemprop="url" href="<%= @message_link %>"></link>
         
     | 
| 
      
 13 
     | 
    
         
            +
                <meta itemprop="name" content="View Commit"></meta>
         
     | 
| 
      
 14 
     | 
    
         
            +
              </div>
         
     | 
| 
      
 15 
     | 
    
         
            +
              <meta itemprop="description" content="View this Commit on Website"></meta>
         
     | 
| 
      
 16 
     | 
    
         
            +
            </div>
         
     | 
| 
      
 17 
     | 
    
         
            +
            <% end %>
         
     | 
| 
       9 
18 
     | 
    
         
             
            </body>
         
     | 
| 
       10 
19 
     | 
    
         
             
            </html>
         
     | 
    
        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. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.12.10
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Bodo Tasche
         
     | 
| 
         @@ -9,7 +9,7 @@ authors: 
     | 
|
| 
       9 
9 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       10 
10 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       11 
11 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       12 
     | 
    
         
            -
            date: 2014- 
     | 
| 
      
 12 
     | 
    
         
            +
            date: 2014-11-06 00:00:00.000000000 Z
         
     | 
| 
       13 
13 
     | 
    
         
             
            dependencies:
         
     | 
| 
       14 
14 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       15 
15 
     | 
    
         
             
              name: diff-lcs
         
     | 
| 
         @@ -302,7 +302,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       302 
302 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       303 
303 
     | 
    
         
             
            requirements: []
         
     | 
| 
       304 
304 
     | 
    
         
             
            rubyforge_project: 
         
     | 
| 
       305 
     | 
    
         
            -
            rubygems_version: 2.2. 
     | 
| 
      
 305 
     | 
    
         
            +
            rubygems_version: 2.2.2
         
     | 
| 
       306 
306 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       307 
307 
     | 
    
         
             
            specification_version: 3
         
     | 
| 
       308 
308 
     | 
    
         
             
            summary: Sends git commit messages with diffs
         
     |