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

Suggested improvement to gitCommit tagging for dirty repos #7822

Open
mcg1969 opened this issue Aug 29, 2022 · 2 comments
Open

Suggested improvement to gitCommit tagging for dirty repos #7822

mcg1969 opened this issue Aug 29, 2022 · 2 comments

Comments

@mcg1969
Copy link

mcg1969 commented Aug 29, 2022

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.

@aaron-prindle
Copy link
Contributor

aaron-prindle commented Nov 28, 2022

+1, I agree this would be a great new option here. @mcg1969 did you want to take a stab at adding this functionality to Skaffold?

@mcg1969
Copy link
Author

mcg1969 commented Nov 28, 2022

Aaron, I must confess it is not likely I will be able to do so. I recognize that this means it's therefore at the mercy of the developers' priorities! However, my custom approach above is working well for me right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants