GoogleContainerTools / GoogleContainerTools/skaffold
Suggested improvement to gitCommit tagging for dirty repos
- Dominant language
- Go
- Stars
- 15.9k
- Forks
- 1.7k
- Avg merge
- 3d 9h
- Merged PRs (30d)
- 10
Description
### Expected behavior
Skaffold should do a better job of detecting containers to rebuild even if you are using a `gitCommit` tagging policy.
### Actual behavior
Currently the gitCommit tagger provides the same tag for dirty repos no matter what changes you are making. This can cause Skaffold to miss changes to your code, especially if you make the mistake of pushing a `-dirty` tag.
This issue provides a custom tagging policy that illustrates a technique for resolving this, and I would like to propose that it be included in the standard `gitCommit` policy, perhaps as an option.
### Information
- Skaffold version: v1.39.2
- Operating system: macOS
- Installed via: skaffold.dev
### Solution
Consider the following `customTemplate`:
```
customTemplate:
template: "{{.GIT2}}{{if ne .GIT .GIT2}}-{{.INPUT}}{{end}}"
components:
- name: GIT
gitCommit:
variant: AbbrevTreeSha
- name: GIT2
gitCommit:
variant: AbbrevTreeSha
ignoreChanges: true
- name: INPUT
inputDigest: {}
```
The simplest way to describe this is that it replaces the `dirty` suffix with the `inputDigest` value. In this way, as you make changes to your code, your tag changes, until you commit.
It seems to me that it would be great to include a new option, say `digestIfDirty`, that accomplishes this natively.
Contributor guide
Assessment
This issue has not been assessed yet.