Gitea webhook commits wrong hash on HEAD reset #5514

Closed
opened 2025-11-02 06:27:22 -06:00 by GiteaMirror · 2 comments
Owner

Originally created by @bfueldner on GitHub (Jun 8, 2020).

Description

Gitea webhook has already deleted git hash in list commits, if a git push --force is initiated after a git reset --hard to a previous commit.

If this is an intended behaviour, please correct me.

Steps to reproduce

  1. Make a commit an a branch of your choice
  2. Push it on the server git push (initiates webhook with correct commits content)
  3. Reset head of branch to a previous commit (e.g. git reset --hard HEAD~1)
  4. Push the new branch head to gitea git push --force (initiates webhook with wrong commits content)

For example after step 2 described above we have the following commit hashes:

commit b44305a4f7cad8617cd2b5ac5d0251b05cf03fdb (HEAD -> master, origin/master)
commit da2c75d512a3f0aa36cc025723d9ea17631a6609
commit df4b604249f70ad99938f502ce7677da3a0cded6

Now we reset to da2c75d512a3f0aa36cc025723d9ea17631a6609 and push it to gitea.

Expected behaviour

Expectect JSON content of webhook (unrelevant data cut away) with git hash of the new branch head:

...
"ref": "refs/heads/master",
"before": "b44305a4f7cad8617cd2b5ac5d0251b05cf03fdb",
"after": "da2c75d512a3f0aa36cc025723d9ea17631a6609",
"compare_url": "https://try.gitea.io/bfueldner/testrepo/compare/b44305a4f7cad8617cd2b5ac5d0251b05cf03fdb...da2c75d512a3f0aa36cc025723d9ea17631a6609",
"commits": [
  {
    "id": "da2c75d512a3f0aa36cc025723d9ea17631a6609",
    "message": "Add more text.\n",
    "url": "https://try.gitea.io/bfueldner/testrepo/commit/da2c75d512a3f0aa36cc025723d9ea17631a6609",
    ...
  }
],
...

Actual behaviour

The actual webhook contains the already deleted hash b44305a4f7cad8617cd2b5ac5d0251b05cf03fdb as a commit. Triggered buildservers try to checkout an invalid hash and can not build the new head of the branch.

...
"ref": "refs/heads/master",
"before": "b44305a4f7cad8617cd2b5ac5d0251b05cf03fdb",
"after": "da2c75d512a3f0aa36cc025723d9ea17631a6609",
"compare_url": "https://try.gitea.io/bfueldner/testrepo/compare/b44305a4f7cad8617cd2b5ac5d0251b05cf03fdb...da2c75d512a3f0aa36cc025723d9ea17631a6609",
"commits": [
  {
    "id": "b44305a4f7cad8617cd2b5ac5d0251b05cf03fdb",
    "message": "Delete readme file.\n",
    "url": "https://try.gitea.io/bfueldner/testrepo/commit/b44305a4f7cad8617cd2b5ac5d0251b05cf03fdb",
    ...
  }
],
...

System information

Originally created by @bfueldner on GitHub (Jun 8, 2020). ## Description Gitea webhook has already deleted git hash in list `commits`, if a `git push --force` is initiated after a `git reset --hard` to a previous commit. If this is an intended behaviour, please correct me. ## Steps to reproduce 1. Make a commit an a branch of your choice 2. Push it on the server `git push` (initiates webhook with correct `commits` content) 3. Reset head of branch to a previous commit (e.g. `git reset --hard HEAD~1`) 4. Push the new branch head to gitea `git push --force` (initiates webhook with wrong `commits` content) For example after step 2 described above we have the following commit hashes: commit b44305a4f7cad8617cd2b5ac5d0251b05cf03fdb (HEAD -> master, origin/master) commit da2c75d512a3f0aa36cc025723d9ea17631a6609 commit df4b604249f70ad99938f502ce7677da3a0cded6 Now we reset to `da2c75d512a3f0aa36cc025723d9ea17631a6609` and push it to gitea. ## Expected behaviour Expectect JSON content of webhook (unrelevant data cut away) with git hash of the new branch head: ... "ref": "refs/heads/master", "before": "b44305a4f7cad8617cd2b5ac5d0251b05cf03fdb", "after": "da2c75d512a3f0aa36cc025723d9ea17631a6609", "compare_url": "https://try.gitea.io/bfueldner/testrepo/compare/b44305a4f7cad8617cd2b5ac5d0251b05cf03fdb...da2c75d512a3f0aa36cc025723d9ea17631a6609", "commits": [ { "id": "da2c75d512a3f0aa36cc025723d9ea17631a6609", "message": "Add more text.\n", "url": "https://try.gitea.io/bfueldner/testrepo/commit/da2c75d512a3f0aa36cc025723d9ea17631a6609", ... } ], ... ## Actual behaviour The actual webhook contains the already deleted hash `b44305a4f7cad8617cd2b5ac5d0251b05cf03fdb` as a commit. Triggered buildservers try to checkout an invalid hash and can not build the new head of the branch. ... "ref": "refs/heads/master", "before": "b44305a4f7cad8617cd2b5ac5d0251b05cf03fdb", "after": "da2c75d512a3f0aa36cc025723d9ea17631a6609", "compare_url": "https://try.gitea.io/bfueldner/testrepo/compare/b44305a4f7cad8617cd2b5ac5d0251b05cf03fdb...da2c75d512a3f0aa36cc025723d9ea17631a6609", "commits": [ { "id": "b44305a4f7cad8617cd2b5ac5d0251b05cf03fdb", "message": "Delete readme file.\n", "url": "https://try.gitea.io/bfueldner/testrepo/commit/b44305a4f7cad8617cd2b5ac5d0251b05cf03fdb", ... } ], ... ## System information - Gitea version (or commit ref): 1.11.6 - Git version: 2.17.1 (should not be relevant) - Operating system: Ubuntu 18.04.4 LTS - Database (use `[x]`): - [ ] PostgreSQL - [x] MySQL - [ ] MSSQL - [ ] SQLite - Can you reproduce the bug at https://try.gitea.io: - [x] Yes (https://try.gitea.io/bfueldner/testrepo/settings/hooks/343) - [ ] No - [ ] Not relevant - Log gist: Not relevant
GiteaMirror added the type/bug label 2025-11-02 06:27:22 -06:00
Author
Owner

@stale[bot] commented on GitHub (Aug 16, 2020):

This issue has been automatically marked as stale because it has not had recent activity. I am here to help clear issues left open even if solved or waiting for more insight. This issue will be closed if no further activity occurs during the next 2 weeks. If the issue is still valid just add a comment to keep it alive. Thank you for your contributions.

@stale[bot] commented on GitHub (Aug 16, 2020): This issue has been automatically marked as stale because it has not had recent activity. I am here to help clear issues left open even if solved or waiting for more insight. This issue will be closed if no further activity occurs during the next 2 weeks. If the issue is still valid just add a comment to keep it alive. Thank you for your contributions.
Author
Owner

@6543 commented on GitHub (Aug 16, 2020):

nop stale

@6543 commented on GitHub (Aug 16, 2020): nop stale
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#5514