Make squasing more robust (#6713)
authorGereon Kremer <nafur42@gmail.com>
Wed, 9 Jun 2021 19:25:04 +0000 (21:25 +0200)
committerGitHub <noreply@github.com>
Wed, 9 Jun 2021 19:25:04 +0000 (19:25 +0000)
This PR makes squashing olds commits in the docs-cleanup CI job more robust: it makes sure that the squash commit has a proper commit date and that we gracefully handle if there is nothing to squash.

.github/workflows/docs_cleanup.yml

index 761736e75492898f06bc26ff0374cf3cc8a70380..6632cbf45610bf0ecc3c5ddad2492874e62640db 100644 (file)
@@ -44,15 +44,19 @@ jobs:
             SSH_AUTH_SOCK: /tmp/ssh_agent.sock
         run: |
           cd target
-          git log
           first=`git rev-list --max-parents=0 HEAD`
           last=`git rev-list --until=1.month.ago -n1 HEAD`
           if [ -n "$last" ]; then
             git checkout $last
+            ts=`git log -1 --format=%ct`
             git reset --soft $first
-            git commit -m "Squash old history"
+            if git diff --cached --exit-code
+            then
+              echo "Nothing to squash"
+            else
+              git commit -m "Squash old history" --date=$ts
+            fi
             git cherry-pick $last..main
-            git log
           fi
       
       - name: Push