-
Notifications
You must be signed in to change notification settings - Fork 82
Always add git user info to run_command #759
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: dvermd <[email protected]>
7fc7ee3
to
13b4c10
Compare
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.
Thanks.
One thing to improve.
Looks good otherwise.
fn run_git_command( | ||
command: &dyn AsRef<OsStr>, | ||
input: &[&dyn AsRef<OsStr>], | ||
cwd: Option<&Path>, | ||
) -> Result<Output, String> { | ||
// This is needed on systems where nothing is configured. | ||
// git really needs something here, or it will fail. | ||
// Even using --author is not enough. | ||
let git_cmd = &[ | ||
&"git" as &dyn AsRef<OsStr>, | ||
&"-c" as &dyn AsRef<OsStr>, | ||
&"user.name=None" as &dyn AsRef<OsStr>, | ||
&"-c" as &dyn AsRef<OsStr>, | ||
&"[email protected]" as &dyn AsRef<OsStr>, | ||
&"-c" as &dyn AsRef<OsStr>, | ||
&"core.autocrlf=false" as &dyn AsRef<OsStr>, | ||
&"-c" as &dyn AsRef<OsStr>, | ||
&"commit.gpgSign=false" as &dyn AsRef<OsStr>, | ||
] | ||
.into_iter() | ||
.chain([command]) | ||
.chain(input.iter().cloned()) | ||
.collect::<Vec<_>>()[..]; | ||
run_command(git_cmd, cwd) | ||
} | ||
|
||
fn run_git_command_with_output( | ||
command: &dyn AsRef<OsStr>, | ||
input: &[&dyn AsRef<OsStr>], | ||
cwd: Option<&Path>, | ||
) -> Result<(), String> { | ||
// This is needed on systems where nothing is configured. | ||
// git really needs something here, or it will fail. | ||
// Even using --author is not enough. | ||
let git_cmd = &[ | ||
&"git" as &dyn AsRef<OsStr>, | ||
&"-c" as &dyn AsRef<OsStr>, | ||
&"user.name=None" as &dyn AsRef<OsStr>, | ||
&"-c" as &dyn AsRef<OsStr>, | ||
&"[email protected]" as &dyn AsRef<OsStr>, | ||
&"-c" as &dyn AsRef<OsStr>, | ||
&"core.autocrlf=false" as &dyn AsRef<OsStr>, | ||
&"-c" as &dyn AsRef<OsStr>, | ||
&"commit.gpgSign=false" as &dyn AsRef<OsStr>, | ||
] | ||
.into_iter() | ||
.chain([command]) | ||
.chain(input.iter().cloned()) | ||
.collect::<Vec<_>>()[..]; | ||
run_command_with_output(git_cmd, cwd) | ||
} |
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.
There's some duplication between these 2 functions.
Could you please refactor these functions to avoid this?
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.
Moved the command definitions to a const
13b4c10
to
99fabbf
Compare
Signed-off-by: dvermd <[email protected]>
99fabbf
to
bd303ca
Compare
This PR always pass the
user.name
,user.email
,core.autocrlf
andcommit.gpgSign
git parameters to therun_command
andrun_command_with_output
functions.With this PR, I managed to successfully run
./y.sh prepare
after a./y.sh clean all" with and without
user.nameand
user.email` parameters defined for the repo.Fixes #731