gruntwork-io / fetch

Download files, folders, and release assets from a specific git commit, branch, or tag of public and private GitHub repos.
https://www.gruntwork.io/
MIT License
587 stars 90 forks source link

fetch no longer works with just --branch #87

Closed brikis98 closed 3 years ago

brikis98 commented 3 years ago

It looks like adding --ref in https://github.com/gruntwork-io/fetch/pull/79 may have broken the --branch parameter.

With fetch version v0.3.9:

gruntwork-install \
  --module-name "gcp-helpers" \
  --repo "https://github.com/gruntwork-io/terraform-google-ci" \
  --branch "gcp-helpers"

Works as follows:

2021-02-01 14:10:38 [INFO] [gruntwork-install] Installing from gcp-helpers...
2021-02-01 14:10:38 [INFO] [gruntwork-install] Downloading module gcp-helpers from https://github.com/gruntwork-io/terraform-google-ci
Downloading latest commit from branch "gcp-helpers" of https://github.com/gruntwork-io/terraform-google-ci ...
Extracting files from <repo>/modules/gcp-helpers to /tmp/gruntwork-script-modules/gcp-helpers ...
Download and file extraction complete.
2021-02-01 14:10:39 [INFO] [gruntwork-install] Setting GRUNTWORK_INSTALL_TAG to 
2021-02-01 14:10:39 [INFO] [gruntwork-install] Setting GRUNTWORK_INSTALL_BRANCH to gcp-helpers
2021-02-01 14:10:39 [INFO] [gruntwork-install] Executing /tmp/gruntwork-script-modules/gcp-helpers/install.sh 

But with fetch version v0.3.13:

2021-02-01 13:31:02 [INFO] [gruntwork-install] Installing from gcp-helpers...
2021-02-01 13:31:02 [INFO] [gruntwork-install] Downloading module gcp-helpers from https://github.com/gruntwork-io/terraform-google-ci
Downloading git reference "v0.1.0" of https://github.com/gruntwork-io/terraform-google-ci ...
Extracting files from <repo>/modules/gcp-helpers to /tmp/gruntwork-script-modules/gcp-helpers ... 0 files extracted
Download and file extraction complete.
2021-02-01 13:31:02 [ERROR] [gruntwork-install] No files were downloaded. Are you sure "gcp-helpers" is a valid Script Module in https://github.com/gruntwork-io/terraform-google-ci (tag = , branch = gcp-helpers)?

I'm guessing the way GitRef is set here to latestTag is causing the code to go down the wrong code path.

robmorgan commented 3 years ago

I can see you've come across the errors. Using an older version, everything is okay:

❯ ~/Downloads/fetch_darwin_amd64_0_3_11 --repo="https://github.com/gruntwork-io/terraform-google-ci" --branch="gcp-helpers" --source-path="/modules/gcp-helpers" "/tmp/download-dir/gcp-helpers"
Downloading latest commit from branch "gcp-helpers" of https://github.com/gruntwork-io/terraform-google-ci ...
Extracting files from <repo>/modules/gcp-helpers to /tmp/download-dir/gcp-helpers ... 3 files extracted
Download and file extraction complete.

However when I try with v0.3.13:

❯ ~/Downloads/fetch_darwin_amd64_0_3_13 --repo="https://github.com/gruntwork-io/terraform-google-ci" --branch="gcp-helpers" --source-path="/modules/gcp-helpers" "/tmp/download-dir/gcp-helpers"
Downloading git reference "v0.1.0" of https://github.com/gruntwork-io/terraform-google-ci ...
Extracting files from <repo>/modules/gcp-helpers to /tmp/download-dir/gcp-helpers ... 0 files extracted
Download and file extraction complete.

It attempts to pull files from the latest tag. I haven't tracked down the offending code yet. cc @brikis98, @pete0emerson