Skip to content
This repository has been archived by the owner on May 7, 2024. It is now read-only.

Support shallow clones #66

Open
lubo opened this issue Oct 25, 2020 · 0 comments
Open

Support shallow clones #66

lubo opened this issue Oct 25, 2020 · 0 comments

Comments

@lubo
Copy link

lubo commented Oct 25, 2020

Currently, a full clone is required for this action to work properly. As we need commits since the last common ancestor only, the current behavior isn't optimal on huge repositories.

So, I propose doing something like this:

  1. Check out refs/pull/${{ github.event.issue.number }}/head instead of the default branch with the depth of 1. At the point of checkout, this is the only commit we know for sure we'll need and we can refer to it. Patch:

    Click to expand
    diff --git a/README.md b/README.md
    index c88b62d..a66029c 100644
    --- a/README.md
    +++ b/README.md
    @@ -24,7 +24,8 @@ jobs:
         - name: Checkout the latest code
           uses: actions/checkout@v2
           with:
    -        fetch-depth: 0
    +        fetch-depth: 1
    +        ref: refs/pull/${{ github.event.issue.number }}/head
         - name: Automatic Rebase
           uses: cirrus-actions/rebase@1.3.1
           env:
    
  2. Fetch the head branch and deepen the history by the number of commits in the PR (see --deepen and --shallow-exclude fetch options). This should fetch all the remaining commits in the head branch, plus the the last common ancestor.

  3. Fetch the base branch.

At this point, we should have all the commits we need to rebase the head branch.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant