Skip to content

fix: returns 0 exit code on error #1322

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

Merged
merged 2 commits into from
Sep 18, 2022
Merged

Conversation

snapdgn
Copy link
Contributor

@snapdgn snapdgn commented Sep 10, 2022

This Pull Request fixes/closes #1315.

It changes the following:

  • changes exit code to 1, while initializing gitui in a bare git repo (let me know if the exit code needs to be something else)

I followed the checklist:

  • I added unittests
  • I ran make check without errors
  • I tested the overall application
  • I added an appropriate item to the changelog

src/main.rs Outdated
@@ -113,7 +113,7 @@ fn main() -> Result<()> {

if !valid_path(&cliargs.repo_path) {
eprintln!("invalid path\nplease run gitui inside of a non-bare git repository");
return Ok(());
process::exit(1);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Did you check if there other places that should return non zero?

Copy link
Contributor Author

@snapdgn snapdgn Sep 11, 2022

Choose a reason for hiding this comment

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

did you mean, checking at all potential places for all kinds of errors which should've returned a non-zero exit code ?.Sorry, I haven't. Will do :)

Choose a reason for hiding this comment

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

Thanks for tackling this! Wouldn't it be more ideomatic to use return Err(..) or bail!(...) here, as main returns a Result? I think an error should get turned into exit code 1 automatically.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hey, thanks a lot for the review. I completely agree with you, will update this accordingly. Also, please do let me know, if there are any other places i could potentially look into, would be very grateful. Thanks!

src/main.rs Outdated
@@ -113,7 +113,7 @@ fn main() -> Result<()> {

if !valid_path(&cliargs.repo_path) {
eprintln!("invalid path\nplease run gitui inside of a non-bare git repository");
return Ok(());
process::exit(1);

Choose a reason for hiding this comment

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

Thanks for tackling this! Wouldn't it be more ideomatic to use return Err(..) or bail!(...) here, as main returns a Result? I think an error should get turned into exit code 1 automatically.

@extrawurst extrawurst merged commit d156686 into gitui-org:master Sep 18, 2022
@extrawurst
Copy link
Collaborator

Thanks!

heiskane pushed a commit to heiskane/gitui that referenced this pull request Oct 20, 2022
IndianBoy42 pushed a commit to IndianBoy42/gitui that referenced this pull request Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Gitui returns zero exit code on error
3 participants