helm-git icon indicating copy to clipboard operation
helm-git copied to clipboard

Sparse support for git 2.22

Open Nuru opened this issue 5 years ago • 11 comments

The plugin fails when ref refers to an annotated tag, which is the usual case for GitHub release tags.

For example:

helm repo add istio git+https://github.com/istio/istio@install/kubernetes/helm?ref=1.1.4
Error in plugin 'helm-git': error Unable to pull. Check your git_ref and git_path.

(By the way, it would be nice if you included the parsed git_ref and git_path in your error message.)

Digging in deeper, I uncovered this error message:

error: cannot update ref 'refs/heads/1.1.4': trying to write non-commit object 5f41cee7af25cb717ecff9a6cb9d8cdf747437d2 to branch 'refs/heads/1.1.4'

which lead me to this StackOverflow post and this solution and a lot of extra info here. The problem is that the plugin is trying to do a git pull into master. The solution is to instead to git fetch and then git checkout, or maybe to do git clone instead. (I am not a git expert and do not know the best way to get just the files you want. These are suggestions to help start further investigation.)

Nuru avatar May 02 '19 02:05 Nuru

Thank you for reporting! I have to push an update that checkout the whole repo if the branch is not master. Haven't found any other way to reference a path that doesn't exists in the master branch when another branch is selected with sparse checkout. I let you know!

aslafy-z avatar May 20 '19 07:05 aslafy-z

@aslafy-z I have found that git clone --depth 1 --branch <TAG> works reliably to clone just the files at that tag. This SO answer suggest you can use file:/// to get just part of the repo after that.

Nuru avatar May 20 '19 15:05 Nuru

definitely need this please!

bitsofinfo avatar Jun 10 '19 17:06 bitsofinfo

As a workaround, you can add sparse=0 parameter at the end of your url to force clone the full repo before building chart.

aslafy-z avatar Jun 11 '19 08:06 aslafy-z

(By the way, it would be nice if you included the parsed git_ref and git_path in your error message.)

@nuru you can get some more info when you do

export HELM_GIT_DEBUG=1

and run it again.

mrtndwrd avatar Jun 27 '19 10:06 mrtndwrd

@aslafy-z This is more urgent now with the release of git version 2.22

  • The filter specification "--filter=sparse:path=" used to create a lazy/partial clone has been removed. Using a blob that is part of the project as sparse specification is still supported with the "--filter=sparse:oid=" option.

Now I cannot even use a ref=SHA to get around this issue.

Nuru avatar Aug 02 '19 01:08 Nuru

Any progress on this?

Nuru avatar May 21 '20 18:05 Nuru

I have no time to try and implement this feature. I'd love to review and merge any PR around this. I'll change position soon and hopefully will get more time.

aslafy-z avatar Nov 11 '20 15:11 aslafy-z

@Nuru How are you currently continuing to use the helm-git plugin at this time? Did you just downgrade Git (as seen in above merge request) to keep that working?

jwlai avatar Jan 13 '21 20:01 jwlai