Skip to content
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

error: unable to commit to git #60

Closed
mamrhein opened this issue Nov 29, 2021 · 9 comments
Closed

error: unable to commit to git #60

mamrhein opened this issue Nov 29, 2021 · 9 comments

Comments

@mamrhein
Copy link

When running 'cargo ws version minor' I get a message 'error: unable to commit to git, out = [main 33d1199] Release ...'.
Nonetheless the intended changes of the versions in all Cargo.toml files are done and committed.
But no tag is generated in git!

I'm using cargo-workspaces version 0.2.28.

@pksunkara
Copy link
Owner

Can you please paste the full message?

@mamrhein
Copy link
Author

ma@mahlbox: ~/work/fpdec.rs > cargo ws version minor
info current common version 0.1.1

Changes:

  • fpdec: 0.1.1 => 0.2.0
  • fpdec-core: 0.1.1 => 0.2.0
  • fpdec-macros: 0.1.1 => 0.2.0

✔ Are you sure you want to create these versions? · yes
Updating crates.io index
Updating fpdec v0.1.1 (/home/ma/work/fpdec.rs) -> v0.2.0
Updating fpdec-core v0.1.1 (/home/ma/work/fpdec.rs/fpdec-core) -> v0.2.0
Updating fpdec-macros v0.1.1 (/home/ma/work/fpdec.rs/fpdec-macros) -> v0.2.0
Updating crates.io index
info version committing changes
error: unable to commit to git, out = [main 33d1199] Release 0.2.0
5 files changed, 21 insertions(+), 8 deletions(-)
create mode 100644 CHANGES.TXT, err = 1 Pfad vom Index aktualisiert
C CHANGES.TXT
1 Pfad vom Index aktualisiert
C Cargo.toml
1 Pfad vom Index aktualisiert
C README.md
1 Pfad vom Index aktualisiert
C fpdec-core/Cargo.toml
1 Pfad vom Index aktualisiert
C fpdec-macros/Cargo.toml

@mamrhein
Copy link
Author

The changes are committed:
git log --name-status -n 1
commit 33d1199d3ecc790fe0cd3cde206840111335dccc (HEAD -> main)
Author: Michael Amrhein <michael...>
Date: Mon Nov 29 17:33:14 2021 +0100

Release 0.2.0

[email protected]
[email protected]
[email protected]

Generated by cargo-workspaces

A CHANGES.TXT
M Cargo.toml
M README.md
M fpdec-core/Cargo.toml
M fpdec-macros/Cargo.toml

@pksunkara
Copy link
Owner

1 Pfad vom Index aktualisiert
C CHANGES.TXT
1 Pfad vom Index aktualisiert
C Cargo.toml
1 Pfad vom Index aktualisiert
C README.md
1 Pfad vom Index aktualisiert
C fpdec-core/Cargo.toml
1 Pfad vom Index aktualisiert
C fpdec-macros/Cargo.toml

What are those? The git command got error which is why it was complaining.

@mamrhein
Copy link
Author

The tree Cargo.toml files are the files modified by cargo-workspace.
CHANGES.TXT has been added before and README.md has been modified before; both not committed before.
The git commit did succeed as you can see from the log command.
So, what was the error?
And why did cargo-workspace not create any tag?
If the problem is that there were uncommitted changes when running cargo-workspace version, should it then check that and stop?

@mamrhein
Copy link
Author

Note:
1 Pfad vom Index aktualisiert
means
1 Path updated from index

@mamrhein
Copy link
Author

mamrhein commented Dec 1, 2021

The output you mentioned above is created by a post-commit hook I have installed to be executed by git after each commit.
Obviously cargo-workspaces considers this output - or the bare fact that there is any output - as an error!
Why?

@mamrhein
Copy link
Author

mamrhein commented Dec 1, 2021

Currently a non-empty output on stderror after calling git commit is treated as an error, although the call to git exited with code 0.

This prohibits - for example - git hooks from outputting informational messages (these seem to go to stderror by default).

@mamrhein
Copy link
Author

mamrhein commented Dec 1, 2021

Proposed fix:

--- a/cargo-workspaces/src/utils/git.rs
+++ b/cargo-workspaces/src/utils/git.rs
@@ -235,7 +235,7 @@ impl GitOpt {
 
             let committed = git(root, &args.iter().map(|x| x.as_str()).collect::<Vec<_>>())?;
 
-            if !committed.0.contains(&branch) || !committed.1.is_empty() {
+            if !committed.0.contains(&branch) {
                 return Err(Error::NotCommitted(committed.0, committed.1));
             }

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

No branches or pull requests

2 participants