mark_stories_as_finisehd 0.0.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 +7 -0
- data/mark_as_finished.rb +106 -0
- metadata +52 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
data.tar.gz: dfbafa1897f78db320efeca5518f28968a399409
|
|
4
|
+
metadata.gz: e87d221b3612ac624dd87d31921057f669e952c5
|
|
5
|
+
SHA512:
|
|
6
|
+
data.tar.gz: 5fe88457925d040727ee5a0d64d76ae033f6dac6be78755671e9c68eafe82942a28b8b00a624b1fdf13bd1919b33d40d8d05df72a24f2266b0cf71291a2ca1f3
|
|
7
|
+
metadata.gz: e2e665f36e5901b8cb1093633fba6c2aa5bc7b577cf22186391e03f00f8329e7a9a67ddc38e913a417d8e4f214bee77c9132ca3e59899e817eea877ff134f01d
|
data/mark_as_finished.rb
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require 'bundler'
|
|
4
|
+
Bundler.require(:default)
|
|
5
|
+
|
|
6
|
+
require 'pivotal-tracker'
|
|
7
|
+
require 'github_api'
|
|
8
|
+
require 'waitutil'
|
|
9
|
+
|
|
10
|
+
class GithubApi
|
|
11
|
+
def initialize(login, password)
|
|
12
|
+
@api = Github.new basic_auth:"#{login}:#{password}"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def get_pull_request(user, repo, branch_name)
|
|
16
|
+
data = nil
|
|
17
|
+
|
|
18
|
+
WaitUtil.wait_for_condition("pull request", :timeout_sec => 5 * 60, :delay_sec => 10, :verbose => true) do
|
|
19
|
+
data = @api.pull_requests.all(user, repo).detect { |it| it.head.ref == branch_name }
|
|
20
|
+
if data.nil?
|
|
21
|
+
[false, "No pull request was found for #{branch_name}, will try again in 30 seconds..."]
|
|
22
|
+
else
|
|
23
|
+
true
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
if data.nil?
|
|
28
|
+
puts "No pull request was found for branch #{branch_name}, aborting"
|
|
29
|
+
exit -1
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
PullRequest.new data
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
class PullRequest
|
|
37
|
+
def initialize(data)
|
|
38
|
+
@data = data
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def retro_message
|
|
42
|
+
body = @data.body
|
|
43
|
+
title = "Retro:"
|
|
44
|
+
|
|
45
|
+
if body.include? title
|
|
46
|
+
body[body.index(title), body.length]
|
|
47
|
+
else
|
|
48
|
+
nil
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def belongs_to_story(id)
|
|
53
|
+
@data.body.include? "[Finishes ##{id}]"
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def method_missing(name)
|
|
57
|
+
@data.send(name)
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
TRACKER_TOKEN = ARGV[0]
|
|
62
|
+
TRACKER_PROJECT_ID = ARGV[1]
|
|
63
|
+
|
|
64
|
+
GITHUB_LOGIN_USER = ARGV[2]
|
|
65
|
+
GITHUB_LOGIN_PASSWORD = ARGV[3]
|
|
66
|
+
|
|
67
|
+
GITHUB_USER = ARGV[4]
|
|
68
|
+
REPO_NAME = ARGV[5]
|
|
69
|
+
BRANCH_NAME = ARGV[6]
|
|
70
|
+
|
|
71
|
+
if BRANCH_NAME == "development" || BRANCH_NAME == "master"
|
|
72
|
+
puts "Doesn't make any sense to run this for development or master. Exiting..."
|
|
73
|
+
exit 0
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
PivotalTracker::Client.token = TRACKER_TOKEN
|
|
77
|
+
PivotalTracker::Client.use_ssl = true
|
|
78
|
+
|
|
79
|
+
unpakt_project = PivotalTracker::Project.find(TRACKER_PROJECT_ID)
|
|
80
|
+
stories = unpakt_project.stories.all(:state => "started", :story_type => ['bug', 'feature'])
|
|
81
|
+
|
|
82
|
+
github = GithubApi.new GITHUB_LOGIN_USER, GITHUB_LOGIN_PASSWORD
|
|
83
|
+
pull_request = github.get_pull_request(GITHUB_USER, REPO_NAME, BRANCH_NAME)
|
|
84
|
+
|
|
85
|
+
stories.each do | story |
|
|
86
|
+
puts "Searching for #{story.id} in pull request #{pull_request.number} in repo #{REPO_NAME}."
|
|
87
|
+
if pull_request.belongs_to_story(story.id)
|
|
88
|
+
puts "Found #{story.id}, marking as finished."
|
|
89
|
+
story.notes.create(:text => "This story is now at code review, please go to #{pull_request.html_url} and check it out!")
|
|
90
|
+
|
|
91
|
+
retro_message = pull_request.retro_message
|
|
92
|
+
if not retro_message.nil?
|
|
93
|
+
if not story.labels.nil?
|
|
94
|
+
story.labels += ","
|
|
95
|
+
else
|
|
96
|
+
story.labels = ""
|
|
97
|
+
end
|
|
98
|
+
story.labels += "retro"
|
|
99
|
+
story.notes.create(:text => retro_message)
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
story.update({"current_state" => "finished"})
|
|
103
|
+
else
|
|
104
|
+
puts "Coult not find #{story.id} in pull request."
|
|
105
|
+
end
|
|
106
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: mark_stories_as_finisehd
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Parsimotion
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
|
|
12
|
+
date: 2015-06-25 00:00:00 Z
|
|
13
|
+
dependencies: []
|
|
14
|
+
|
|
15
|
+
description: PivotalTracker + Github
|
|
16
|
+
email: info@parsimotion.com
|
|
17
|
+
executables: []
|
|
18
|
+
|
|
19
|
+
extensions: []
|
|
20
|
+
|
|
21
|
+
extra_rdoc_files: []
|
|
22
|
+
|
|
23
|
+
files:
|
|
24
|
+
- mark_as_finished.rb
|
|
25
|
+
homepage: http://rubygems.org/gems/mark_stories_as_finished
|
|
26
|
+
licenses:
|
|
27
|
+
- MIT
|
|
28
|
+
metadata: {}
|
|
29
|
+
|
|
30
|
+
post_install_message:
|
|
31
|
+
rdoc_options: []
|
|
32
|
+
|
|
33
|
+
require_paths:
|
|
34
|
+
- lib
|
|
35
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- &id001
|
|
38
|
+
- ">="
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: "0"
|
|
41
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
42
|
+
requirements:
|
|
43
|
+
- *id001
|
|
44
|
+
requirements: []
|
|
45
|
+
|
|
46
|
+
rubyforge_project:
|
|
47
|
+
rubygems_version: 2.4.2
|
|
48
|
+
signing_key:
|
|
49
|
+
specification_version: 4
|
|
50
|
+
summary: PivotalTracker + Github
|
|
51
|
+
test_files: []
|
|
52
|
+
|