capistrano-flowdock 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4cac34e546340767b69509127f8075a8de849527
4
- data.tar.gz: ab7e1e5d550d99064053be02d97d36a0776875c5
3
+ metadata.gz: f3671e13d25179f5eae4e319b55c2aed74ca239e
4
+ data.tar.gz: 0dbb414ba178ac0eefc6fbeb211318e1c26b8308
5
5
  SHA512:
6
- metadata.gz: 7250374f37415e2402cc69dc2176c52e04b9073952a5e3e5de558e7e124aae7c7aeee3e9f68ed6607132a21fd27ae4ac623eca4594fa29aa478a67790b2d600c
7
- data.tar.gz: 5bb6992a382e64d680f3b47c5186318c312b3ae4e0235568875302f8e4e804fdd6ac1869a79e190a63b8b007ef56ffd1e886f3ea43557bed596590ae3278d577
6
+ metadata.gz: cc98cffa9eaae2a57ef624e463107380fd3458e51b71a552162d630b157e2b6c20096b7e8bcefdd6ec4d9cfaf0f45b48241ceefdc247ce996555359c4e7879f4
7
+ data.tar.gz: 63323508afaa1bbe30f0a6cd11cd60ba4ee4aac388a13d79d79c99bb1c0bef61f81d411eb3c1f792fa9543ac14cd47e81b64d27f917cf31630ab532cc8b17f8e
@@ -18,9 +18,9 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_runtime_dependency "flowdock", "~> 0.3.1"
21
+ spec.add_runtime_dependency "flowdock", "~> 0.5.0"
22
22
  spec.add_runtime_dependency "capistrano", "~> 3.0"
23
- spec.add_runtime_dependency "grit", "~> 2.4"
23
+ spec.add_runtime_dependency "rugged", "~> 0.19.0"
24
24
  spec.add_development_dependency "bundler", "~> 1.3"
25
25
  spec.add_development_dependency "rake"
26
26
  end
@@ -1,5 +1,24 @@
1
1
  require 'flowdock'
2
2
  require 'digest/md5'
3
3
  require 'cgi'
4
+ require 'rugged'
5
+
6
+ module Capistrano
7
+ module Flowdock
8
+ class << self
9
+ def commits_between(repository, before, after)
10
+ walker = Rugged::Walker.new(repository)
11
+ walker.push(after)
12
+ walker.hide(before)
13
+ walker.sorting Rugged::SORT_TOPO
14
+ walker.walk.to_a
15
+ end
16
+
17
+ def id_abbrev(id)
18
+ id[0...7]
19
+ end
20
+ end
21
+ end
22
+ end
4
23
 
5
24
  load File.expand_path('../tasks/flowdock.cap', __FILE__)
@@ -1,5 +1,5 @@
1
1
  module Capistrano
2
2
  module Flowdock
3
- VERSION = "2.0.0"
3
+ VERSION = "2.1.0"
4
4
  end
5
5
  end
@@ -14,7 +14,7 @@ namespace :flowdock do
14
14
  task :save_deployed_branch do
15
15
  on roles(:all) do
16
16
  begin
17
- execute("echo '#{fetch(:repo).head.name.chomp}' > #{current_path}/BRANCH")
17
+ execute("echo '#{fetch(:flowdock_deploy_head_name)}' > #{current_path}/BRANCH")
18
18
  rescue => e
19
19
  puts "Flowdock: error in saving deployed branch information: #{e.to_s}"
20
20
  end
@@ -24,10 +24,8 @@ namespace :flowdock do
24
24
  task :set_flowdock_api do
25
25
  set :flowdock_deploy_env, fetch(:stage, fetch(:rails_env, ENV["RAILS_ENV"] || "production"))
26
26
  begin
27
- require 'grit'
28
- repo = Grit::Repo.new(".")
29
- set :repo, repo
30
- config = Grit::Config.new(repo)
27
+ set :repo, Rugged::Repository.new(".")
28
+ set :flowdock_deploy_head_name, fetch(:repo).head.name.split("/", 3).last.chomp
31
29
  rescue LoadError => e
32
30
  puts "Flowdock: you need to have Grit gem installed: #{e.to_s}"
33
31
  rescue => e
@@ -38,7 +36,7 @@ namespace :flowdock do
38
36
  flows = Array(fetch(:flowdock_api_token)).map do |api_token|
39
37
  Flowdock::Flow.new(:api_token => api_token,
40
38
  :source => "Capistrano deployment", :project => fetch(:flowdock_project_name),
41
- :from => {:name => config["user.name"], :address => config["user.email"]})
39
+ :from => {:name => fetch(:repo).config["user.name"], :address => fetch(:repo).config["user.email"]})
42
40
  end
43
41
  set :flowdock_api, flows
44
42
  rescue => e
@@ -53,7 +51,7 @@ namespace :flowdock do
53
51
  flow.push_to_team_inbox(:format => "html",
54
52
  :subject => "#{fetch(:flowdock_project_name)} deployed with branch #{fetch(:branch)} on ##{fetch(:flowdock_deploy_env)}",
55
53
  :content => notification_message,
56
- :tags => ["deploy", "#{fetch(:flowdock_deploy_env)}"] | fetch(:flowdock_deploy_tags))
54
+ :tags => fetch(:flowdock_deploy_tags, ["deploy", "#{fetch(:flowdock_deploy_env)}"]))
57
55
  end unless fetch('dry_run')
58
56
  rescue => e
59
57
  puts "Flowdock: error in sending notification to your flow: #{e.to_s}"
@@ -63,24 +61,26 @@ namespace :flowdock do
63
61
  def notification_message
64
62
  if fetch(:branch) == fetch(:current_branch)
65
63
  message = "<p>The following changes were just deployed to #{fetch(:flowdock_deploy_env)}:</p>"
66
- commits = fetch(:repo).commits_between(
67
- fetch(:previous_revision), fetch(:current_revision)
68
- ).reverse
64
+ commits = if fetch(:previous_revision)
65
+ Capistrano::Flowdock.commits_between(fetch(:repo), fetch(:previous_revision), fetch(:current_revision))
66
+ else
67
+ []
68
+ end
69
69
 
70
70
  unless commits.empty?
71
71
  commits.each do |c|
72
72
  short, long = c.message.split(/\n+/, 2)
73
- message << "\n<div style=\"margin-bottom: 10px\"><div style=\"height:30px;width:30px;float:left;margin-right:5px;\"><img src=\"https://secure.gravatar.com/avatar/#{Digest::MD5::hexdigest(c.author.email.downcase)}?s=30\" /></div>"
73
+ message << "\n<div style=\"margin-bottom: 10px\"><div style=\"height:30px;width:30px;float:left;margin-right:5px;\"><img src=\"https://secure.gravatar.com/avatar/#{Digest::MD5::hexdigest(c.author[:email].to_s.downcase)}?s=30\" /></div>"
74
74
  message << "<div style=\"padding-left: 35px;\">#{CGI.escapeHTML(short)}<br/>"
75
75
  if long
76
76
  long.gsub!(/\n/, '<br />')
77
77
  message << '<p style="margin:5px 0px; padding: 0 5px; border-left: 3px solid #ccc">' + long + '</p>'
78
78
  end
79
- message << "<span style=\"font-size: 90%; color: #333\"><code>#{c.id_abbrev}</code> <a href=\"mailto:#{CGI.escapeHTML(c.author.email)}\">#{CGI.escapeHTML(c.author.name)}</a> on #{c.authored_date.strftime("%b %d, %H:%M")}</span></div></div>"
79
+ message << "<span style=\"font-size: 90%; color: #333\"><code>#{Capistrano::Flowdock.id_abbrev(c.oid)}</code> <a href=\"mailto:#{CGI.escapeHTML(c.author[:email].to_s)}\">#{CGI.escapeHTML(c.author[:name].to_s)}</a> on #{c.time.strftime("%b %d, %H:%M")}</span></div></div>"
80
80
  end
81
81
  end
82
82
  else
83
- message = "Branch #{fetch(:repo).head.name} was deployed to #{fetch(:flowdock_deploy_env)}. Previously deployed branch was #{fetch(:current_branch)}."
83
+ message = "Branch #{fetch(:flowdock_deploy_head_name)} was deployed to #{fetch(:flowdock_deploy_env)}. Previously deployed branch was #{fetch(:current_branch)}."
84
84
  end
85
85
  message
86
86
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-flowdock
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ville Lautanala
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-22 00:00:00.000000000 Z
11
+ date: 2015-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: flowdock
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.3.1
19
+ version: 0.5.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.3.1
26
+ version: 0.5.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: capistrano
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -39,19 +39,19 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '3.0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: grit
42
+ name: rugged
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '2.4'
47
+ version: 0.19.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '2.4'
54
+ version: 0.19.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: bundler
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -117,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
117
  version: '0'
118
118
  requirements: []
119
119
  rubyforge_project:
120
- rubygems_version: 2.2.0
120
+ rubygems_version: 2.4.5
121
121
  signing_key:
122
122
  specification_version: 4
123
123
  summary: Flowdock notifier for Capistrano