-
Notifications
You must be signed in to change notification settings - Fork 74
Add option --milestone to open_issue command #95
Changes from 9 commits
419a073
7b2bf9b
c5fe543
f6af4b4
c92ea82
720cba8
d964df7
dd60ad6
b4da552
f99aea2
4019073
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Update: I created a bug elsewhere and didn't realize it. This is no longer true There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 This leads to another question, which is how would the milestones get created across the repositories in the first place. Do we need an There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
include CommandHelpers | ||
|
||
context 'through CLI' do | ||
def common_test(labels='') | ||
def common_test(labels='', milestone=nil) | ||
issue_title = "Issue Test" | ||
request_stubs = [] | ||
|
||
|
@@ -16,6 +16,10 @@ def common_test(labels='') | |
student_usernames.each do |username| | ||
# Action checks that repos exist already | ||
request_stubs << stub_request(:get, "https://testteacher:[email protected]/repos/testorg/#{username}-testrepo") | ||
|
||
unless milestone | ||
request_stubs << stub_get_json("https://testteacher:[email protected]/repos/testorg/#{username}-testrepo/milestones/", number: milestone) | ||
end | ||
end | ||
|
||
# create the issue in each repo | ||
|
@@ -26,10 +30,15 @@ def common_test(labels='') | |
team_id = st[:id] | ||
end | ||
end | ||
issue_body = File.read(issue_fixture_path).gsub("\n", "\\n") | ||
labels_list = labels.split(",").map(&:strip).to_s.delete(' ') | ||
issue_body = File.read(issue_fixture_path) | ||
labels_list = labels.split(",").map(&:strip) | ||
request_stubs << stub_request(:post, "https://testteacher:[email protected]/repos/testorg/#{username}-testrepo/issues"). | ||
with(body: "{\"labels\":#{labels_list},\"title\":\"#{issue_title}\",\"body\":\"#{issue_body}\"}"). | ||
with(body: { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems a lot better to me than trying to type out the raw string yourself. This convention is also being used in create_student_teams_spec.rb There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
milestone: milestone, | ||
labels: labels_list, | ||
title: issue_title, | ||
body: issue_body | ||
}.to_json). | ||
to_return(status: 201) | ||
end | ||
|
||
|
@@ -40,6 +49,7 @@ def common_test(labels='') | |
title: issue_title, | ||
body: issue_fixture_path, | ||
labels: labels, | ||
milestone: milestone, | ||
|
||
students: students_list_fixture_path, | ||
|
||
|
@@ -59,5 +69,9 @@ def common_test(labels='') | |
it "open issue with labels" do | ||
common_test('bug, feature') | ||
end | ||
|
||
it "open issue with milestone" do | ||
common_test('bug, feature', 1) | ||
end | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A little hard to understand what these conditionals are doing... mind adding inline comments, or (better yet) moving them into a method with a descriptive name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree it is a convoluted.
The code I have actually won't work because it runs the conditional only if the milestone is nil.
What do you think about something like this?