Add a new flag dput --comment-extra to add text to the commit message#108
Add a new flag dput --comment-extra to add text to the commit message#108
dput --comment-extra to add text to the commit message#108Conversation
|
@emanueleaina I'm not sure if the format |
emanueleaina
left a comment
There was a problem hiding this comment.
Ooooh, this is definitely what I was looking for, thank you!
| let commit_message = comment_extra.map_or_else( | ||
| || dsc_filename.to_owned(), | ||
| |extra| format!("{dsc_filename}\n\n{extra}"), | ||
| ); |
There was a problem hiding this comment.
non-blocking[bikeshedding]: when not chaining I find match to be more straightforward than map_or_else:
| let commit_message = comment_extra.map_or_else( | |
| || dsc_filename.to_owned(), | |
| |extra| format!("{dsc_filename}\n\n{extra}"), | |
| ); | |
| let commit_message = match comment_extra { | |
| None => dsc_filename.to_owned(), | |
| Some(extra) => format!("{dsc_filename}\n\n{extra}"), | |
| }; |
There was a problem hiding this comment.
Yeah agreed; Or even just an if let Some(message) = :) Many ways to skin that cat, but the more functional combinator doesn't seem to add value here
| #[clap(long, flag_supporting_explicit_value())] | ||
| pub rebuild_if_unchanged: bool, | ||
| #[clap(long, default_value = "")] | ||
| pub comment_extra: String, |
There was a problem hiding this comment.
| pub comment_extra: String, | |
| pub comment_extra: Option<String>, |
A default value of empty which is then meant to mean unset is odd.
Also bikeshedding on the name why "--comment-extra" ? What's extra about it? Also seems more obvious to use -m, --message similar to e.g. osc commit (which is what we're doing in the end) or things like git
There was a problem hiding this comment.
A default value of empty which is then meant to mean unset is odd.
It's intentional, since when using the runner there's no way to conditionally pass an argument, so if you want to optionally give a value the only option is to do --arg=$VALUE anyway and let the empty string mean "no". This is also why branch_to defaults to the empty string just a few lines above.
Also bikeshedding on the name why "--comment-extra" ? What's extra about it? Also seems more obvious to use -m, --message similar to e.g. osc commit (which is what we're doing in the end) or things like git
"extra" since it appends to it, "comment" because I thought OBS called it "comments" and it was previously incorrect of me to use "message" (I had not considered that osc itself uses "message", oops).
Changed now to --message.
|
|
||
| let commit_message = comment_extra.map_or_else( | ||
| || dsc_filename.to_owned(), | ||
| |extra| format!("{dsc_filename}\n\n{extra}"), |
There was a problem hiding this comment.
Why force the dsc filename to be in the commit message? (also shows why your naming is strange as you go from an extra_comment to a commit_message :p ).
The dsc filename is a good default; But if the user specifies a message they can decide on whether that's useful for them or whether they just want to put in say " <gitlab link/commit/branch/snake>"
There was a problem hiding this comment.
It was mostly because, if you wanted to exclusively append, then getting the dsc basename yourself in the prior steps is mildly annoying, and OBS shows all lines of the message on the history page anyway. That being said I guess the dsc filename was probably derived dynamically anyway, so in that case it's a pretty easy change?
Updated the code to just always replace the message instead.
| let commit_message = comment_extra.map_or_else( | ||
| || dsc_filename.to_owned(), | ||
| |extra| format!("{dsc_filename}\n\n{extra}"), | ||
| ); |
There was a problem hiding this comment.
Yeah agreed; Or even just an if let Some(message) = :) Many ways to skin that cat, but the more functional combinator doesn't seem to add value here
3899e62 to
59e010b
Compare
If non-empty, it gets appended after the .dsc filename (the current message). Fixes #107.
59e010b to
172cbb2
Compare
| #[clap(long, flag_supporting_explicit_value())] | ||
| pub rebuild_if_unchanged: bool, | ||
| #[clap(long, default_value = "")] | ||
| pub message: String, |
There was a problem hiding this comment.
your commit message/PR title still says comment-extra
sjoerdsimons
left a comment
There was a problem hiding this comment.
Just needs the commit message/merge title changing now
If non-empty, it gets appended after the .dsc filename (the current message).
Fixes #107.