Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upAuto-increment default names for PRs #334
Conversation
devonhollowood
added some commits
Oct 5, 2018
This comment has been minimized.
This comment has been minimized.
|
Thanks for the PR! Unfortunately there is a bug with your implementation: you always generate a new name for the experiment, but the new name should only be generated for the As for the n+1 queries, it shouldn't really be a problem (I don't expect to have more than 5 runs for a single PR). If you still want to avoid that you could select the count of experiments pointing to the same PR (checking the API URL in the database). |
This comment has been minimized.
This comment has been minimized.
|
Ah, that makes sense. I'll take another shot at this tonight then. |
This comment has been minimized.
This comment has been minimized.
|
Okay, I think it should work now. If not, I'll try to catch you on Discord to discuss some more. Let me know if you want me to squash these commits or anything. |
This comment has been minimized.
This comment has been minimized.
|
There are still a few quirks in the implementation: if a second run is created and then edited, the edit command uses the first run's name. The way I'd like to see this implemented is the following:
If you have any doubt just ping me on Discord! |
devonhollowood
added some commits
Oct 8, 2018
pietroalbini
requested changes
Oct 9, 2018
| if name_supplied { | ||
| name | ||
| } else { | ||
| let new_name = auto_increment_experiment_name(&data.db, &name)?; |
This comment has been minimized.
This comment has been minimized.
pietroalbini
Oct 9, 2018
Member
By passing as argument the previously stored name this is generating weird results, like last-name-1-1-1 (like pr-123-1-1-1-1).
| @@ -15,7 +15,17 @@ pub fn ping(data: &Data, issue: &Issue) -> Result<()> { | |||
| } | |||
|
|
|||
| pub fn run(host: &str, data: &Data, issue: &Issue, args: RunArgs) -> Result<()> { | |||
| let name = get_name(&data.db, issue, args.name)?; | |||
| let name = { | |||
| let name_supplied = args.name.is_some(); | |||
This comment has been minimized.
This comment has been minimized.
pietroalbini
Oct 9, 2018
Member
This can be factored out as a standalone function, so it's easily testable.
This comment has been minimized.
This comment has been minimized.
|
I think that commit addresses the issues you brought up and behaves as specified; let me know if I missed something. |
pietroalbini
requested changes
Oct 10, 2018
|
This works great now, thanks! I left a small comment, and then this can be merged. |
| name = format!("pr-{}-{}", issue.number, idx); | ||
| idx = idx | ||
| .checked_add(1) | ||
| .expect("too many similarly-named pull requests"); |
This comment has been minimized.
This comment has been minimized.
pietroalbini
Oct 10, 2018
Member
Can you avoid panicking here? I'd prefer for the server not to crash if someone creates way too many experiments.
This comment has been minimized.
This comment has been minimized.
devonhollowood
added some commits
Oct 10, 2018
pietroalbini
approved these changes
Oct 11, 2018
This comment has been minimized.
This comment has been minimized.
|
Thanks! @bors r+ |
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
bors
added a commit
that referenced
this pull request
Oct 11, 2018
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
Changes deployed. |


devonhollowood commentedOct 5, 2018
Fix #306
I thought that the easiest way to go about this was to adjust
default_experiment_name(), and to just have it automatically try new names in case of a clash until it finds one that works. This makes the assumption that there won't be too too many experiments for a given PR, since experimentNwill make N calls to the database, which is only really okay if N is small. Let me know if you'd like me to do something smarter here, or to adjust a different area of the code instead.