Skip to content
This repository has been archived by the owner on Feb 5, 2018. It is now read-only.

Add option --milestone to open_issue command #95

2 changes: 1 addition & 1 deletion lib/teachers_pet/actions/create_student_teams.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def create_student_teams
if team
puts "Team @#{org_login}/#{team_name} already exists."
else
team = self.client.create_team(org_login, team_name)
team = JSON.parse(self.client.create_team(org_login, team_name))
end
self.client.add_users_to_team(org_login, team, usernames)
end
Expand Down
8 changes: 8 additions & 0 deletions lib/teachers_pet/actions/open_issue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ def read_info
labels: self.options[:labels]
}
}

@issue[:options][:milestone] = self.options[:milestone] unless self.options[:milestone].nil?
@issue_file = self.options[:body]
end

Expand All @@ -27,6 +29,12 @@ def create
abort('Organization could not be found') if org_hash.nil?
puts "Found organization at: #{org_hash[:login]}"

unless self.options[:milestone].nil?
milestone = self.client.milestone("#{@organization}/#{@repository}", self.options[:milestone])
abort('Milestone could not be found') if milestone.nil?
puts "Found milestone ##{milestone[:number]}: #{milestone[:title]}"
end

org_teams = self.client.get_teams_by_name(@organization)

puts "\nCreating issue in repositories..."
Expand Down
1 change: 1 addition & 0 deletions lib/teachers_pet/commands/open_issue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class Cli
option :title, desc: "The title of the issue to be created"
option :body, banner: 'PATH', desc: "The path to the file containing the issue body (.txt or .md)"
option :labels, banner: 'LABEL1,LABEL2'
option :milestone, desc: "The milestone you would like to associate with the issue", type: :numeric
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reason the CI breaks when all I add is this option

https://travis-ci.org/tarebyte/teachers_pet/jobs/40206454

Update: I created a bug elsewhere and didn't realize it. This is no longer true

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where would someone find the milestone "number"? Doesn't seem that it's reflected in the URL, e.g. https://github.com/scala/scala/milestones/on-hold.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see anywhere in the UI or the URL where the milestones are listed, maybe I'm missing something.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was trying to move away from prompts, but one solution would be that if they include --milestone without a value, it could list the milestones for the repository and ask them to choose which to use.

This leads to another question, which is how would the milestones get created across the repositories in the first place. Do we need an create_milestone command? This feels like 🐢s all the way down, and while I appreciate all the work you've put into this, I'm questioning the value relative to this extra required effort.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not a problem, if nothing else I had good learning experience out of it, and I can extract out the json code I wrote and make that into a new PR 😃.

I don't know how often educators use milestones in students repos. My guess would be not very often. Just by talking to educators the last few days it seems like it's a very rare case.


students_option
common_options
Expand Down
18 changes: 4 additions & 14 deletions spec/commands/create_student_teams_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,8 @@ def stub_owners_only
student_usernames.each_with_index do |student, i|
# Creates team
request_stubs << stub_request(:post, 'https://testteacher:[email protected]/orgs/testorg/teams').
with(body: {
name: student,
permission: 'push'
}.to_json).to_return(body: {
id: i,
name: student
})
with(body: "{\"name\":\"#{student}\",\"permission\":\"push\"}").
to_return(body: "{\"id\":#{i},\"name\":\"#{student}\"}")

# Checks for existing team members
# TODO No need to retrieve members for a new team
Expand Down Expand Up @@ -56,13 +51,8 @@ def stub_owners_only

# Creates team
request_stubs << stub_request(:post, 'https://testteacher:[email protected]/orgs/testorg/teams').
with(body: {
name: 'studentteam1',
permission: 'push'
}.to_json).to_return(body: {
id: 1,
name: 'studentteam1'
})
with(body: "{\"name\":\"studentteam1\",\"permission\":\"push\"}").
to_return(body: "{\"id\":1,\"name\":\"studentteam1\"}")

# Checks for existing team members
# TODO No need to retrieve members for a new team
Expand Down