diff --git a/.github/workflows/command-compile.yml b/.github/workflows/command-compile.yml index f245332d60f8d..ebc48010f913d 100644 --- a/.github/workflows/command-compile.yml +++ b/.github/workflows/command-compile.yml @@ -96,21 +96,27 @@ jobs: needs: init steps: - - name: Restore cached git repository - uses: buildjet/cache@3e70d19e31d6a8030aeddf6ed8dbe601f94d09f4 # v4.0.2 - with: - path: .git - key: git-repo - - - name: Checkout ${{ needs.init.outputs.head_ref }} + - name: Checkout (shallow) ${{ needs.init.outputs.head_ref }} uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: # Needed to allow force push later persist-credentials: true token: ${{ secrets.COMMAND_BOT_PAT }} - fetch-depth: 0 + fetch-depth: 1 ref: ${{ needs.init.outputs.head_ref }} + - name: Fetch parent commit for amend + if: ${{ contains(needs.init.outputs.arg1, 'amend') }} + run: git fetch --deepen=1 + + - name: Fetch full history for rebase + if: ${{ contains(needs.init.outputs.arg1, 'rebase') }} + run: | + git fetch --unshallow + git fetch origin "${BASE_REF}:${BASE_REF}" + env: + BASE_REF: ${{ needs.init.outputs.base_ref }} + - name: Setup git run: | git config --local user.email 'nextcloud-command@users.noreply.github.com' @@ -134,11 +140,11 @@ jobs: - name: Rebase to ${{ needs.init.outputs.base_ref }} if: ${{ contains(needs.init.outputs.arg1, 'rebase') }} + env: + BASE_REF: ${{ needs.init.outputs.base_ref }} run: | - git fetch origin '${{ needs.init.outputs.base_ref }}:${{ needs.init.outputs.base_ref }}' - # Start the rebase - git rebase 'origin/${{ needs.init.outputs.base_ref }}' || { + git rebase "$BASE_REF" || { # Handle rebase conflicts in a loop while [ -d .git/rebase-merge ] || [ -d .git/rebase-apply ]; do echo "Handling rebase conflict..." @@ -146,11 +152,11 @@ jobs: # Remove and checkout /dist and /js folders from the base branch if [ -d "dist" ]; then rm -rf dist - git checkout origin/${{ needs.init.outputs.base_ref }} -- dist/ 2>/dev/null || echo "No dist folder in base branch" + git checkout "$BASE_REF" -- dist/ 2>/dev/null || echo "No dist folder in base branch" fi if [ -d "js" ]; then rm -rf js - git checkout origin/${{ needs.init.outputs.base_ref }} -- js/ 2>/dev/null || echo "No js folder in base branch" + git checkout "$BASE_REF" -- js/ 2>/dev/null || echo "No js folder in base branch" fi # Stage all changes