guitarrapc / git-shallow-clone-orb

circleci orb to execute git shallow clone for faster checkout.
https://circleci.com/orbs/registry/orb/guitarrapc/git-shallow-clone
MIT License
21 stars 11 forks source link

Add tag_fetch_options to advanced checkout #23

Closed ankushg closed 3 years ago

ankushg commented 3 years ago

This orb currently fetches all tags when run from a tag. This can be problematic when a repo has many tags. For example, we have a repo with almost 3000 tags and the checkout process takes around 3 minutes on a tagged build in CI.

This PR adds tag_fetch_options to advanced_checkout.

ankushg commented 3 years ago

@guitarrapc I think this should be ok, but would definitely like your feedback on this because there might be other reasons for the -t flag that I'm missing

guitarrapc commented 3 years ago

This orb currently fetches all tags when run from a tag. This can be problematic when a repo has many tags. For example, we have a repo with almost 3000 tags and the checkout process takes around 3 minutes on a tagged build in CI.

Yes, I understood.

Instead of fetching all tags, we instead fetch and create a reference to the specific tag we are trying to check out. This should also let consumers pass in --no-tags in fetch_options

I do want respect your idea.

guitarrapc commented 3 years ago

@ankushg

I think this should be ok, but would definitely like your feedback on this because there might be other reasons for the -t flag that I'm missing

Why I use -t is to follow what CircleCI checkout do. CircleCI is checking out tag with following, that's all reason.

  echo 'Fetching from remote repository'
  if [ -n "$CIRCLE_TAG" ]; then
    git fetch --force --tags origin
  else
    git fetch --force origin '+refs/pull/23/head:refs/remotes/origin/pull/23'
  fi

git-shallow-clone-orb's concept is add small spices to faster original checkout. I love your idea, so let me think how to offer this functionality.

To achieve consistency of `fetch_options: --no-tags, option2 is better, presumably. Or if only few people is using all tags, Option3 is the choise.

I don't have concrete reason to select Option2 or 3, or others right now.

ankushg commented 3 years ago

I'm ok with option 1 with some sort of "tag_fetch_options" that's set to "--tags" to fetch all tags by default so it's not breaking. Then we can change it to "--no-tags" for us

Definitely want to minimize breaking changes for your users!

ankushg commented 3 years ago

@guitarrapc I updated this PR to add an additional tag_fetch_options configuration parameter so it doesn't break anyone's existing configuration!

guitarrapc commented 3 years ago

@ankushg I've released v2.4.0.

https://circleci.com/developer/orbs/orb/guitarrapc/git-shallow-clone?version=2.4.0

There are 2 choice to skip fetch tags.

  1. If you use git-shallow-clone/checkout, then use no_tags: true.

    - git-shallow-clone/checkout:
    no_tags: true
  2. If you use git-shallow-clone/checkout_advanced, then use tag_fetch_options: '--no-tags'. Optionally add --no-tags to fetch_options if needed.

    # use --no-tags to fetch single tag on git `TAG`.
    - git-shallow-clone/checkout_advanced
    fetch_options: '--depth 10 --no-tags' # you can omit this.
    tag_fetch_options: '--no-tags'