skaffold icon indicating copy to clipboard operation
skaffold copied to clipboard

Suggested improvement to gitCommit tagging for dirty repos

Open mcg1969 opened this issue 3 years ago • 0 comments

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.

mcg1969 avatar Aug 29 '22 17:08 mcg1969