Skip to content

Additional git tagger variants (TreeSha, AbbrevTreeSha)#1905

Merged
nkubala merged 5 commits intoGoogleContainerTools:masterfrom
corneliusweig:git-tagger-tree-sha
May 20, 2019
Merged

Additional git tagger variants (TreeSha, AbbrevTreeSha)#1905
nkubala merged 5 commits intoGoogleContainerTools:masterfrom
corneliusweig:git-tagger-tree-sha

Conversation

@corneliusweig
Copy link
Copy Markdown
Contributor

@corneliusweig corneliusweig commented Apr 2, 2019

Synopsis

PR #1902 has introduced git tagger variants Tags, CommitSha, and AbbrevCommitSha. Issue #407 also suggests tree hash variants, which are part of this PR. Originally these variants were also part of #1902, but OSX has problems to determine the relative git path, so these two variants were extracted.

  • TreeSha: use the full tree hash of the artifact workingdir
  • AbbrevTreeSha: use the abbreviated tree hash of the artifact workingdir

The tree hash variants are similar in spirit to the sha256 tagger in that it is based on the (committed) workingdir content. As the hash is pre-computed by git, this should be faster than the sha256Tagger.

Config change

There are no config changes wrt. PR #1902, but gitCommit.variant now understands the TreeSha and AbbrevTreeSha variants:

tagPolicy:
  gitCommit:
   # variant is an enum with valid values (case-insensitive)
   # - Tags
   # - CommitSha
   # - AbbrevCommitSha
   # - TreeSha                  NEW
   # - AbbrevTreeSha       NEW
    variant: Tags # default

Close #407

@corneliusweig
Copy link
Copy Markdown
Contributor Author

corneliusweig commented Apr 2, 2019

So the problem on OSX seems to be that filepath.Abs() reports /var/folders/... for the workingdir, but git rev-parse --show-toplevel prepends an additional folder: /private/var/folders/....

absWd=/var/folders/nz/vv4_9tw56nv9k3tkvyszvwg80000gn/T/skaffold810560671
gitRoot=/private/var/folders/nz/vv4_9tw56nv9k3tkvyszvwg80000gn/T/skaffold810560671

So this is probably a real problem on OSX and not just a bad test setup.

@codecov-io
Copy link
Copy Markdown

codecov-io commented Apr 2, 2019

Codecov Report

Merging #1905 into master will increase coverage by 0.07%.
The diff coverage is 82.6%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1905      +/-   ##
==========================================
+ Coverage   56.74%   56.81%   +0.07%     
==========================================
  Files         183      183              
  Lines        7860     7883      +23     
==========================================
+ Hits         4460     4479      +19     
- Misses       2988     2990       +2     
- Partials      412      414       +2
Impacted Files Coverage Δ
pkg/skaffold/schema/latest/config.go 100% <ø> (ø) ⬆️
pkg/skaffold/schema/v1beta10/upgrade.go 66.66% <ø> (ø) ⬆️
pkg/skaffold/build/tag/git_commit.go 80.88% <82.6%> (+0.88%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update eb9916f...a977f5c. Read the comment docs.

@corneliusweig corneliusweig changed the title WIP Git tagger variants (TreeSha, AbbrevTreeSha) Git tagger variants (TreeSha, AbbrevTreeSha) Apr 2, 2019
@corneliusweig corneliusweig changed the title Git tagger variants (TreeSha, AbbrevTreeSha) Additional git tagger variants (TreeSha, AbbrevTreeSha) Apr 4, 2019
@corneliusweig corneliusweig force-pushed the git-tagger-tree-sha branch 2 times, most recently from 354cb1b to a1ef727 Compare April 16, 2019 20:03
@nkubala
Copy link
Copy Markdown
Contributor

nkubala commented Apr 25, 2019

So the problem on OSX seems to be that filepath.Abs() reports /var/folders/... for the workingdir, but git rev-parse --show-toplevel prepends an additional folder: /private/var/folders/....

I actually don't see this when I run git rev-parse --show-toplevel on my machine (git version 2.19.0.605). might just be a weird quirk of some versions of git. in the case that it fails, is there something we can use as a fallback? maybe try and strip off the /private prefix if we get a failure, and then actually fail if that also doesn't work?

@corneliusweig
Copy link
Copy Markdown
Contributor Author

@nkubala So I think the root cause is that /var on some OSX variants is actually a symlink to /private/var. Go Abs does not expand the symlink, whereas git rev-parse --show-toplevel does. At least this is my assumption, because in lack of an OSX system I can't be sure.
However, I would not put in some extra logic for stripping /private, this just feels horribly brittle. For example, if an affected OSX user has another symlink somewhere in his dir hierarchy, this would fail already.
Maybe you can do further checks on your machine?

- TreeSha: use the full tree hash of the artifact workingdir
- AbbrevTreeSha: use the abbreviated tree hash of the artifact workingdir

Signed-off-by: Cornelius Weig <22861411+corneliusweig@users.noreply.github.com>
Signed-off-by: Cornelius Weig <22861411+corneliusweig@users.noreply.github.com>
tejal29
tejal29 previously approved these changes Apr 29, 2019
Copy link
Copy Markdown
Contributor

@tejal29 tejal29 left a comment

Choose a reason for hiding this comment

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

approve with nits!

Copy link
Copy Markdown
Contributor

@tejal29 tejal29 left a comment

Choose a reason for hiding this comment

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

I only verified this on Linux. Please hold until i verify on mac too.

@tejal29 tejal29 self-requested a review April 29, 2019 23:26
@tejal29 tejal29 dismissed their stale review April 29, 2019 23:26

I only verified this on Linux. Please hold until i verify on mac too.

Signed-off-by: Cornelius Weig <22861411+corneliusweig@users.noreply.github.com>
@dgageot
Copy link
Copy Markdown
Contributor

dgageot commented May 17, 2019

@corneliusweig can this be merged?

@corneliusweig
Copy link
Copy Markdown
Contributor Author

@dgageot No, it should come after #2109 (config freeze). Unless this change goes under the radar config-wise. All it does is add new enum values, so this would be possible without breaking anybody.

Copy link
Copy Markdown
Contributor

@nkubala nkubala left a comment

Choose a reason for hiding this comment

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

@corneliusweig I merged the config version upgrade PR, can you add an change to upgrade() in the v1beta10 config? then I'll merge this in

@corneliusweig corneliusweig force-pushed the git-tagger-tree-sha branch from a625dd4 to a977f5c Compare May 20, 2019 21:04
@corneliusweig
Copy link
Copy Markdown
Contributor Author

@nkubala Done. I merged in master after the config freeze.

@nkubala nkubala merged commit ec24f54 into GoogleContainerTools:master May 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enhance git tagger to tag with latest git tag or other formats

6 participants