Skip to content

Gitea webhook commits wrong hash on HEAD reset #11802

Closed
@bfueldner

Description

@bfueldner

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions