Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fetch necessary git refs #162

Merged
merged 5 commits into from
Oct 6, 2021
Merged

Fetch necessary git refs #162

merged 5 commits into from
Oct 6, 2021

Conversation

korthout
Copy link
Owner

@korthout korthout commented Oct 6, 2021

This change makes sure the action fetches the necessary git refs so it has all necessary git history available. It uses refs/pull/$num/head for fetching the history that is part of the pull request that should be backported. This means that the action now works even when you've already deleted the branch of that pull request.

This also removes the need for checking out the entire git history with the checkout action. Previously, the action required users to set the fetch-depth to 0 for the checkout action. That looked like:

  - uses: actions/checkout@v2
    with:
      # required to find all branches
      fetch-depth: 0
  - uses: zeebe-io/backport-action@master
    ...

Now, you can simply checkout the default branch:

  - uses: actions/checkout@v2
  - uses: zeebe-io/backport-action@master
    ...

This should significantly speed up running this action for projects with large git repos that have many refs hanging around.

These changes have been manually tested by deleting branch from https://github.com/zeebe-io/automation-lab/pull/56 and then triggering the action. See: https://github.com/zeebe-io/automation-lab/pull/56#issuecomment-935754194

resolves #90

By fetching the pull head, we make sure that we have all commit shas
available, even if the branch itself is already deleted from github.

Ofcourse, we only want to fetch the head once, since it doesn't change for
each of the different targets. And if none of the labels match, then we
don't even have to fetch.

Potentially this allows us to remove the `fetch-depth: 0` input from the
checkout action. To achieve that goal, we'll need to also fetch each of
the targets individually.
We don't always have to fetch: only when there are actual backport
labels present.

We only have to fetch the head once, but we need to make sure that
we actually fetch and not forget about it. Then, we also need to fetch
each of the targets.
It is no longer necessary to fetch all git history during the checkout,
because the action is now fetching all necessary refs specifically.

Since the fetch-depth 0 setting can be very slow for large projects, it
is discouraged to use this now.
This is no longer necessary and new users should not be encouraged to
use `fetch-depth: 0`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Possible issue with backporting after a branch has been deleted
1 participant