gitLib is_dirty_worktree #654
Labels
No labels
dependencies
difficulty::high
difficulty::low
difficulty::medium
good first issue
help wanted
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
justin/makes#654
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
github.com/fluidattacks/makes@874fb8ca2e/src/args/lib-git/template.sh (L3-L7)is_dirty_worktreeI figured in some situations one might want to ensure that things are run on a clean dir.
One such use case is:
(a witness of a deployed state, but this can be moved up the chain and only allow deploys on clean git workdirs in the first place)
/cc @nrdxp
@blaggacao what about gitignored files ? should they be considered part of the dirty state? git status does not take them into account, but if they exists, they will cause NAR serializations drift on nix-stable
should we consider a clean worktree one that is: git reset --hard COMMIT && git clean -dffx ?
the above is exactly equal as cloning the repository from scratch and checking out a given commit
I'd say that if a gitops engineer deploys any state off of a gitignore file, that engineer is very deliberately shooting himself in the foot (or doesn't know better).
I currently don't think we need to prevent that type of self harm if minimum gitops ethics is a given.
The issue here is rather deploying an uncommitted change by mistake (and thereby loosing auditability).
Understood,
my concern was more purity and security. I heard of someone once deploying a file with plain text secrets to a public docker container image. The file was gitignored so that person was not aware of its existence. Other story is, python automatically writes
__pycache__folders when executed, which are also gitignored, and they cause ./path/to/folder hashes to change on Nix stable. Since those folders are "invisible", people normally have bad times debugging why the hash changesIf you use the unstable path, Nix itself already warns you of a dirty worktree, so doing this in makes may become redundant. Then again you can choose to turn that warning off in Nix.
Oh yeah, I can see that happen. Let's ignore it for
is_dirty_worktree, I'd say. Here is why:has_uncommitted_changes, that's less of a misnomer, then.My main used case here is to make a hard stop sign for a run-book and don't let the user get past that point during the control flow of an interactive script.