paketo-buildpacks / git

Paketo Buildpack for Git
Apache License 2.0
1 stars 4 forks source link

Build fails if workspace is a submodule #275

Open menehune23 opened 1 year ago

menehune23 commented 1 year ago

If running pack with a workspace that is a submodule, the build will fail with a message:

Paketo Buildpack for Git 1.0.6
failed to execute 'git rev-parse HEAD': exit status 128
        fatal: not a git repository: /workspace/../../../../.git/modules/vendor/github.com/triggermesh/triggermesh-event-sources-bundle

For instance:

git clone https://gitlab.eng.vmware.com/tanzu-application-platform/runtime-program/eventing.git
cd eventing
git submodule update --init --recursive
pack build debug --path vendor/github.com/triggermesh/triggermesh-event-sources-bundle --builder paketobuildpacks/builder:tiny --env "BP_GO_TARGETS=cmd/awscloudwatchlogssource-adapter"

I think this might be because the .git file inside of a submodule is different in structure than when at the root of a repo.

I've found that if I simply delete the .git file inside of the submodule, the build will pass. However, this is not a feasible workaround for my scenario (I'll spare the details).

menehune23 commented 1 year ago

I'm thinking that this buildpack should probably check to see if the .git is a folder vs a file. If it's a file, we know we're in a submodule and can treat it the same as the .git folder not existing.