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

132: Add version and git hash/status to agent CLI #80

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

mattgeddes
Copy link
Contributor

Closes #issue-number

@mattgeddes mattgeddes self-assigned this Feb 24, 2025
@mattgeddes mattgeddes requested a review from a team as a code owner February 24, 2025 06:49
@mattgeddes mattgeddes enabled auto-merge February 27, 2025 22:03
Comment on lines +4 to +5
let output = Command::new("git")
.args(&["rev-parse", "HEAD"])
Copy link
Contributor

Choose a reason for hiding this comment

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

.git is not part of the source directory in nix flakes so this will not work as intended. which explains the error on CI: https://buildbot-nix-0.infra.holochain.org/#/builders/416/builds/370

nix itself knows about the revision and there's a way to pass it through, maybe via an environment variable. if you rewrite this in a way that first tries to read the environment and only falls back to calling git we can make it work. i also suggest graceful handling of the inexistence of either.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you can tell me which environment variable(s) are present during the build, I can definitely change the above to use those instead.

.unwrap();
if status.success() {
println!("cargo:rustc-env=GIT_STATUS=clean");
} else {
Copy link
Contributor

Choose a reason for hiding this comment

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

this will consider a failed attempt at merely calling git to be in a dirty state. which is far from the truth for when git isn't even in PATH and .git is not present.

Copy link
Contributor

Choose a reason for hiding this comment

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

i suggest to differentiate between a failed execution of git and git reporting that the tree is dirty. for deployment in production via any of nix' tooling this is not relevant as per the discussion above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If it reports it as dirty and there's no hash in a controlled environment, it's pretty clear that it was a failure to run git. Let me know the environment variables and how to execute the build under that environment and I'll make some changes to the code.

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.

3 participants