-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpivotal_to_github.rb
29 lines (24 loc) · 1.03 KB
/
pivotal_to_github.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
%w[rubygems pivotal-tracker github_api date].each{|lib| require lib}
CONFIG = YAML::load(File.open('config.yml'))
pivotal_email = CONFIG['pivotal_email']
pivotal_password = CONFIG['pivotal_password']
repos = CONFIG['repos']
module PivotalToGithub
def self.push_updates(repo, stories)
stories.each do |story|
GithubAPI::close_issue(repo, story.other_id) if (story.story_type == 'chore' && story.current_state == 'accepted') || (story.story_type == 'bug' && story.current_state == 'finished')
end
end
end
PivotalTracker::Client.token(pivotal_email, pivotal_password)
@projects = PivotalTracker::Project.all
@projects.each do |project|
stories = project.activities.all("occurred_since_date=#{DateTime.now - 1}").collect do |activity|
if activity.event_type == 'story_update'
story_ids = []
activity.stories.each{|ac| story_ids << ac.id if ac.other_id }
story_ids.compact
end
end
PivotalToGithub::push_updates(repos[project.name], project.stories.all(:id => stories.compact.flatten.uniq.join(',')))
end