pivotal_tracker_pr 0.2.1 → 0.3.0

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: a9c3e9901c795695f1626f9b9a511ae70ea08557
4
- data.tar.gz: 3a053c2ac7bb181918a6c7c74b4a4ee844e8f946
3
+ metadata.gz: b31214a83e3747a65c01fc9bdce4d4ea2399eeaa
4
+ data.tar.gz: 07176180c76bc00aa6913482b1ca4269673ed41f
5
5
  SHA512:
6
- metadata.gz: fce63427146fc9e5a2f831b6d60d2d38f1d0c5b5966fc19429eb863a8fef23b7cb107032d4656c582e47bb6fd5e0f990cac37216ca1fc451a6bc86c97ce99bbf
7
- data.tar.gz: ab00cfb57aab45211347a390bf698e2c444a0f8ad4f2c4e49ce0a4fe2b3d2dd8cea3532b6eb44bd87cfc9f43a000770f324b86b9ccfc9e7cbff6abb5cfb6b8ef
6
+ metadata.gz: b8a2f590cbe8025bdc1c4e494448ca54577bc80d22983e186e81f86539c82ca2386135d4441155f218d3d62b0e2a6477aa6cd10aee439e4a3777c1946bd82987
7
+ data.tar.gz: 7984823b003c0254d33b4f86202202f5075c66c640b3e2e2821e05b1b0da05717bfeafa909a0527f8841b9e1c346088d667e04b640386186cb76484c2763aae0
@@ -4,7 +4,8 @@ require 'net/http'
4
4
  require 'thor'
5
5
 
6
6
  module PivotalTrackerPr
7
- PULL_REQUEST_TEMPLATE = 'PULLREQ_EDITMSG'.freeze
7
+ PULL_REQUEST_MESSAGE = 'PULLREQ_EDITMSG'.freeze
8
+ MESSAGE_TEMPLATE = 'PULLREQ_MSG_TEMPLATE'.freeze
8
9
 
9
10
  class CLI < Thor
10
11
  desc 'create', 'Generate pull request use story id / story name.'
@@ -21,7 +22,6 @@ module PivotalTrackerPr
21
22
  write_pull_request_template story_id, story_name
22
23
  end
23
24
 
24
- say 'Done.'
25
25
  system 'hub pull-request --browse'
26
26
  end
27
27
 
@@ -61,15 +61,34 @@ module PivotalTrackerPr
61
61
  end
62
62
 
63
63
  def write_pull_request_template(story_id, story_name)
64
- open(template_path, 'w') do |file|
65
- file.puts "[fixed ##{story_id}]#{story_name}"
66
- file.puts "\n"
67
- file.puts "https://www.pivotaltracker.com/story/show/#{story_id}"
64
+ message_context = if File.exists?(message_template_path)
65
+ message_from_template(story_id, story_name)
66
+ else
67
+ default_message
68
68
  end
69
+
70
+ open(pull_request_message, 'w') { |file| file.puts message_context }
71
+ end
72
+
73
+ def message_template_path
74
+ File.join(Dir.pwd, '.git', MESSAGE_TEMPLATE)
75
+ end
76
+
77
+ def message_from_template(story_id, story_name)
78
+ template_content = File.open(message_template_path).read
79
+ template_content.gsub('{{STORY_ID}}', story_id).gsub('{{STORY_NAME}}')
80
+ end
81
+
82
+ def pull_request_message
83
+ File.join(Dir.pwd, '.git', PULL_REQUEST_MESSAGE)
69
84
  end
70
85
 
71
- def template_path
72
- File.join(Dir.pwd, '.git', PULL_REQUEST_TEMPLATE)
86
+ def default_message(story_id, story_name)
87
+ <<~EOF
88
+ "[fixed ##{story_id}]#{story_name}"
89
+ "\n"
90
+ "https://www.pivotaltracker.com/story/show/#{story_id}"
91
+ EOF
73
92
  end
74
93
  end
75
94
  end
@@ -1,3 +1,3 @@
1
1
  module PivotalTrackerPr
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pivotal_tracker_pr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - blueplanet
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-09 00:00:00.000000000 Z
11
+ date: 2016-06-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler