detect that a merge will result in an empty commit from the api #12131

Open
opened 2025-11-02 09:59:22 -06:00 by GiteaMirror · 0 comments
Owner

Originally created by @rafipiccolo on GitHub (Nov 30, 2023).

Feature Description

in the ux, next to the "merge" button, there is a warning "The changes on this branch are already on the target branch. This will be an empty commit. "
how can i detect it by using the api ?

here is my detailed case :
i have a bot creating pull requests.
sometime it creates 2 identical commits on 2 branches and sends 2 PRs.

i have another bot that merges pull requests by using "squash merge". When he merges the first one it's ok, but then when he tries the second PR it fails to merge. and every time it retries it says the same error :

git commit [root/infra:renovate -> root/infra:master]: exit status 1
On branch base
You are in a sparse checkout with 2% of tracked files present.

Changes not staged for commit:
  (use \"git add/rm <file>...\" to update what will be committed)
  (use \"git restore <file>...\" to discard changes in working directory)
    deleted:    package-lock.json
    deleted:    package.json

no changes added to commit (use \"git add\" and/or \"git commit -a\")

when i do normal merge commits it works. it only fails using squash merge.

when i go in the UX to check the PR it shows a warning :
"The changes on this branch are already on the target branch. This will be an empty commit. "

i think i have tested all endpoints of the api related to pulls and diff and i dont know how to detect this fact.

i'd like to know that this merge would result in empty commit, so i could just automatically delete the PR.

any advice ?

Screenshots

No response

Originally created by @rafipiccolo on GitHub (Nov 30, 2023). ### Feature Description in the ux, next to the "merge" button, there is a warning "The changes on this branch are already on the target branch. This will be an empty commit. " how can i detect it by using the api ? here is my detailed case : i have a bot creating pull requests. sometime it creates 2 identical commits on 2 branches and sends 2 PRs. i have another bot that merges pull requests by using "squash merge". When he merges the first one it's ok, but then when he tries the second PR it fails to merge. and every time it retries it says the same error : ``` git commit [root/infra:renovate -> root/infra:master]: exit status 1 On branch base You are in a sparse checkout with 2% of tracked files present. Changes not staged for commit: (use \"git add/rm <file>...\" to update what will be committed) (use \"git restore <file>...\" to discard changes in working directory) deleted: package-lock.json deleted: package.json no changes added to commit (use \"git add\" and/or \"git commit -a\") ``` when i do normal merge commits it works. it only fails using squash merge. when i go in the UX to check the PR it shows a warning : "The changes on this branch are already on the target branch. This will be an empty commit. " i think i have tested all endpoints of the api related to pulls and diff and i dont know how to detect this fact. i'd like to know that this merge would result in empty commit, so i could just automatically delete the PR. any advice ? ### Screenshots _No response_
GiteaMirror added the topic/apitype/proposal labels 2025-11-02 09:59:22 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#12131