diff --git a/.cspell.json b/.cspell.json index be615d7d17f..525ca62c94a 100644 --- a/.cspell.json +++ b/.cspell.json @@ -47,6 +47,7 @@ "datacenter", "DATASOURCE", "Debugf", + "Demilestoned", "desaturate", "devx", "dind", @@ -116,6 +117,7 @@ "mapstructure", "markdownlint", "mdbook", + "Milestoned", "memswap", "Metas", "mhmxs", diff --git a/cmd/server/openapi/docs.go b/cmd/server/openapi/docs.go index 926cfb98a0a..8399bbcd052 100644 --- a/cmd/server/openapi/docs.go +++ b/cmd/server/openapi/docs.go @@ -4913,6 +4913,12 @@ const docTemplate = `{ "event": { "$ref": "#/definitions/WebhookEvent" }, + "event_reason": { + "type": "array", + "items": { + "type": "string" + } + }, "finished": { "type": "integer" }, @@ -5551,6 +5557,7 @@ const docTemplate = `{ "push", "pull_request", "pull_request_closed", + "pull_request_metadata", "tag", "release", "deployment", @@ -5561,6 +5568,7 @@ const docTemplate = `{ "EventPush", "EventPull", "EventPullClosed", + "EventPullMetadata", "EventTag", "EventRelease", "EventDeploy", @@ -5684,6 +5692,12 @@ const docTemplate = `{ "event": { "type": "string" }, + "event_reason": { + "type": "array", + "items": { + "type": "string" + } + }, "finished": { "type": "integer" }, diff --git a/docs/docs/20-usage/20-workflow-syntax.md b/docs/docs/20-usage/20-workflow-syntax.md index 9c5c21d955b..386a1bcec7e 100644 --- a/docs/docs/20-usage/20-workflow-syntax.md +++ b/docs/docs/20-usage/20-workflow-syntax.md @@ -284,6 +284,7 @@ The available events are: - `push`: triggered when a commit is pushed to a branch. - `pull_request`: triggered when a pull request is opened or a new commit is pushed to it. - `pull_request_closed`: triggered when a pull request is closed or merged. +- `pull_request_metadata`: triggered when a pull request metadata has changed (e.g. title, body, label, milestone, ...). - `tag`: triggered when a tag is pushed. - `release`: triggered when a release, pre-release or draft is created. (You can apply further filters using [evaluate](#evaluate) with [environment variables](./50-environment.md#built-in-environment-variables).) - `deployment`: triggered when a deployment is created in the repository. (This event can be triggered from Woodpecker directly. GitHub also supports webhook triggers.) diff --git a/docs/docs/20-usage/50-environment.md b/docs/docs/20-usage/50-environment.md index 13552548bb0..b6d2690d9a5 100644 --- a/docs/docs/20-usage/50-environment.md +++ b/docs/docs/20-usage/50-environment.md @@ -48,97 +48,99 @@ Please note that the environment section is not able to expand environment varia This is the reference list of all environment variables available to your pipeline containers. These are injected into your pipeline step and plugins containers, at runtime. -| NAME | Description | Example | -| ---------------------------------- | ------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | -| `CI` | CI environment name | `woodpecker` | -| | **Repository** | | -| `CI_REPO` | repository full name `/` | `john-doe/my-repo` | -| `CI_REPO_OWNER` | repository owner | `john-doe` | -| `CI_REPO_NAME` | repository name | `my-repo` | -| `CI_REPO_REMOTE_ID` | repository remote ID, is the UID it has in the forge | `82` | -| `CI_REPO_URL` | repository web URL | `https://git.example.com/john-doe/my-repo` | -| `CI_REPO_CLONE_URL` | repository clone URL | `https://git.example.com/john-doe/my-repo.git` | -| `CI_REPO_CLONE_SSH_URL` | repository SSH clone URL | `git@git.example.com:john-doe/my-repo.git` | -| `CI_REPO_DEFAULT_BRANCH` | repository default branch | `main` | -| `CI_REPO_PRIVATE` | repository is private | `true` | -| `CI_REPO_TRUSTED_NETWORK` | repository has trusted network access | `false` | -| `CI_REPO_TRUSTED_VOLUMES` | repository has trusted volumes access | `false` | -| `CI_REPO_TRUSTED_SECURITY` | repository has trusted security access | `false` | -| | **Current Commit** | | -| `CI_COMMIT_SHA` | commit SHA | `eba09b46064473a1d345da7abf28b477468e8dbd` | -| `CI_COMMIT_REF` | commit ref | `refs/heads/main` | -| `CI_COMMIT_REFSPEC` | commit ref spec | `issue-branch:main` | -| `CI_COMMIT_BRANCH` | commit branch (equals target branch for pull requests) | `main` | -| `CI_COMMIT_SOURCE_BRANCH` | commit source branch (set only for `pull_request` and `pull_request_closed` events) | `issue-branch` | -| `CI_COMMIT_TARGET_BRANCH` | commit target branch (set only for `pull_request` and `pull_request_closed` events) | `main` | -| `CI_COMMIT_TAG` | commit tag name (empty if event is not `tag`) | `v1.10.3` | -| `CI_COMMIT_PULL_REQUEST` | commit pull request number (set only for `pull_request` and `pull_request_closed` events) | `1` | -| `CI_COMMIT_PULL_REQUEST_LABELS` | labels assigned to pull request (set only for `pull_request` and `pull_request_closed` events) | `server` | -| `CI_COMMIT_PULL_REQUEST_MILESTONE` | milestone assigned to pull request (set only for `pull_request` and `pull_request_closed` events) | `summer-sprint` | -| `CI_COMMIT_MESSAGE` | commit message | `Initial commit` | -| `CI_COMMIT_AUTHOR` | commit author username | `john-doe` | -| `CI_COMMIT_AUTHOR_EMAIL` | commit author email address | `john-doe@example.com` | -| `CI_COMMIT_PRERELEASE` | release is a pre-release (empty if event is not `release`) | `false` | -| | **Current pipeline** | | -| `CI_PIPELINE_NUMBER` | pipeline number | `8` | -| `CI_PIPELINE_PARENT` | number of parent pipeline | `0` | -| `CI_PIPELINE_EVENT` | pipeline event (see [`event`](../20-usage/20-workflow-syntax.md#event)) | `push`, `pull_request`, `pull_request_closed`, `tag`, `release`, `manual`, `cron` | -| `CI_PIPELINE_URL` | link to the web UI for the pipeline | `https://ci.example.com/repos/7/pipeline/8` | -| `CI_PIPELINE_FORGE_URL` | link to the forge's web UI for the commit(s) or tag that triggered the pipeline | `https://git.example.com/john-doe/my-repo/commit/eba09b46064473a1d345da7abf28b477468e8dbd` | -| `CI_PIPELINE_DEPLOY_TARGET` | pipeline deploy target for `deployment` events | `production` | -| `CI_PIPELINE_DEPLOY_TASK` | pipeline deploy task for `deployment` events | `migration` | -| `CI_PIPELINE_CREATED` | pipeline created UNIX timestamp | `1722617519` | -| `CI_PIPELINE_STARTED` | pipeline started UNIX timestamp | `1722617519` | -| `CI_PIPELINE_FILES` | changed files (empty if event is not `push` or `pull_request`), it is undefined if more than 500 files are touched | `[]`, `[".woodpecker.yml","README.md"]` | -| `CI_PIPELINE_AUTHOR` | pipeline author username | `octocat` | -| `CI_PIPELINE_AVATAR` | pipeline author avatar | `https://git.example.com/avatars/5dcbcadbce6f87f8abef` | -| | **Current workflow** | | -| `CI_WORKFLOW_NAME` | workflow name | `release` | -| | **Current step** | | -| `CI_STEP_NAME` | step name | `build package` | -| `CI_STEP_NUMBER` | step number | `0` | -| `CI_STEP_STARTED` | step started UNIX timestamp | `1722617519` | -| `CI_STEP_URL` | URL to step in UI | `https://ci.example.com/repos/7/pipeline/8` | -| | **Previous commit** | | -| `CI_PREV_COMMIT_SHA` | previous commit SHA | `15784117e4e103f36cba75a9e29da48046eb82c4` | -| `CI_PREV_COMMIT_REF` | previous commit ref | `refs/heads/main` | -| `CI_PREV_COMMIT_REFSPEC` | previous commit ref spec | `issue-branch:main` | -| `CI_PREV_COMMIT_BRANCH` | previous commit branch | `main` | -| `CI_PREV_COMMIT_SOURCE_BRANCH` | previous commit source branch (set only for `pull_request` and `pull_request_closed` events) | `issue-branch` | -| `CI_PREV_COMMIT_TARGET_BRANCH` | previous commit target branch (set only for `pull_request` and `pull_request_closed` events) | `main` | -| `CI_PREV_COMMIT_URL` | previous commit link in forge | `https://git.example.com/john-doe/my-repo/commit/15784117e4e103f36cba75a9e29da48046eb82c4` | -| `CI_PREV_COMMIT_MESSAGE` | previous commit message | `test` | -| `CI_PREV_COMMIT_AUTHOR` | previous commit author username | `john-doe` | -| `CI_PREV_COMMIT_AUTHOR_EMAIL` | previous commit author email address | `john-doe@example.com` | -| | **Previous pipeline** | | -| `CI_PREV_PIPELINE_NUMBER` | previous pipeline number | `7` | -| `CI_PREV_PIPELINE_PARENT` | previous pipeline number of parent pipeline | `0` | -| `CI_PREV_PIPELINE_EVENT` | previous pipeline event (see [`event`](../20-usage/20-workflow-syntax.md#event)) | `push`, `pull_request`, `pull_request_closed`, `tag`, `release`, `manual`, `cron` | -| `CI_PREV_PIPELINE_URL` | previous pipeline link in CI | `https://ci.example.com/repos/7/pipeline/7` | -| `CI_PREV_PIPELINE_FORGE_URL` | previous pipeline link to event in forge | `https://git.example.com/john-doe/my-repo/commit/15784117e4e103f36cba75a9e29da48046eb82c4` | -| `CI_PREV_PIPELINE_DEPLOY_TARGET` | previous pipeline deploy target for `deployment` events | `production` | -| `CI_PREV_PIPELINE_DEPLOY_TASK` | previous pipeline deploy task for `deployment` events | `migration` | -| `CI_PREV_PIPELINE_STATUS` | previous pipeline status | `success`, `failure` | -| `CI_PREV_PIPELINE_CREATED` | previous pipeline created UNIX timestamp | `1722610173` | -| `CI_PREV_PIPELINE_STARTED` | previous pipeline started UNIX timestamp | `1722610173` | -| `CI_PREV_PIPELINE_FINISHED` | previous pipeline finished UNIX timestamp | `1722610383` | -| `CI_PREV_PIPELINE_AUTHOR` | previous pipeline author username | `octocat` | -| `CI_PREV_PIPELINE_AVATAR` | previous pipeline author avatar | `https://git.example.com/avatars/5dcbcadbce6f87f8abef` | -| |   | | -| `CI_WORKSPACE` | Path of the workspace where source code gets cloned to | `/woodpecker/src/git.example.com/john-doe/my-repo` | -| | **System** | | -| `CI_SYSTEM_NAME` | name of the CI system | `woodpecker` | -| `CI_SYSTEM_URL` | link to CI system | `https://ci.example.com` | -| `CI_SYSTEM_HOST` | hostname of CI server | `ci.example.com` | -| `CI_SYSTEM_VERSION` | version of the server | `2.7.0` | -| | **Forge** | | -| `CI_FORGE_TYPE` | name of forge | `bitbucket` , `bitbucket_dc` , `forgejo` , `gitea` , `github` , `gitlab` | -| `CI_FORGE_URL` | root URL of configured forge | `https://git.example.com` | -| | **Internal** - Please don't use! | | -| `CI_SCRIPT` | Internal script path. Used to call pipeline step commands. | | -| `CI_NETRC_USERNAME` | Credentials for private repos to be able to clone data. (Only available for specific images) | | -| `CI_NETRC_PASSWORD` | Credentials for private repos to be able to clone data. (Only available for specific images) | | -| `CI_NETRC_MACHINE` | Credentials for private repos to be able to clone data. (Only available for specific images) | | +| NAME | Description | Example | +| ---------------------------------- | ------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------- | +| `CI` | CI environment name | `woodpecker` | +| | **Repository** | | +| `CI_REPO` | repository full name `/` | `john-doe/my-repo` | +| `CI_REPO_OWNER` | repository owner | `john-doe` | +| `CI_REPO_NAME` | repository name | `my-repo` | +| `CI_REPO_REMOTE_ID` | repository remote ID, is the UID it has in the forge | `82` | +| `CI_REPO_URL` | repository web URL | `https://git.example.com/john-doe/my-repo` | +| `CI_REPO_CLONE_URL` | repository clone URL | `https://git.example.com/john-doe/my-repo.git` | +| `CI_REPO_CLONE_SSH_URL` | repository SSH clone URL | `git@git.example.com:john-doe/my-repo.git` | +| `CI_REPO_DEFAULT_BRANCH` | repository default branch | `main` | +| `CI_REPO_PRIVATE` | repository is private | `true` | +| `CI_REPO_TRUSTED_NETWORK` | repository has trusted network access | `false` | +| `CI_REPO_TRUSTED_VOLUMES` | repository has trusted volumes access | `false` | +| `CI_REPO_TRUSTED_SECURITY` | repository has trusted security access | `false` | +| | **Current Commit** | | +| `CI_COMMIT_SHA` | commit SHA | `eba09b46064473a1d345da7abf28b477468e8dbd` | +| `CI_COMMIT_REF` | commit ref | `refs/heads/main` | +| `CI_COMMIT_REFSPEC` | commit ref spec | `issue-branch:main` | +| `CI_COMMIT_BRANCH` | commit branch (equals target branch for pull requests) | `main` | +| `CI_COMMIT_SOURCE_BRANCH` | commit source branch (set only for pull request events) | `issue-branch` | +| `CI_COMMIT_TARGET_BRANCH` | commit target branch (set only for pull request events) | `main` | +| `CI_COMMIT_TAG` | commit tag name (empty if event is not `tag`) | `v1.10.3` | +| `CI_COMMIT_PULL_REQUEST` | commit pull request number (set only for pull request events) | `1` | +| `CI_COMMIT_PULL_REQUEST_LABELS` | labels assigned to pull request (set only for pull request events) | `server` | +| `CI_COMMIT_PULL_REQUEST_MILESTONE` | milestone assigned to pull request (set only for `pull_request` and `pull_request_closed` events) | `summer-sprint` | +| `CI_COMMIT_MESSAGE` | commit message | `Initial commit` | +| `CI_COMMIT_AUTHOR` | commit author username | `john-doe` | +| `CI_COMMIT_AUTHOR_EMAIL` | commit author email address | `john-doe@example.com` | +| `CI_COMMIT_PRERELEASE` | release is a pre-release (empty if event is not `release`) | `false` | +| | **Current pipeline** | | +| `CI_PIPELINE_NUMBER` | pipeline number | `8` | +| `CI_PIPELINE_PARENT` | number of parent pipeline | `0` | +| `CI_PIPELINE_EVENT` | pipeline event (see [`event`](../20-usage/20-workflow-syntax.md#event)) | `push`, `pull_request`, `pull_request_closed`, `pull_request_metadata`, `tag`, `release`, `manual`, `cron` | +| `CI_PIPELINE_EVENT_REASON` | exact reason why `pull_request_metadata` event was send. it is forge instance specific and can change | `label_updated`, `milestoned`, `demilestoned`, `assigned`, `edited`, ... | +| `CI_PIPELINE_URL` | link to the web UI for the pipeline | `https://ci.example.com/repos/7/pipeline/8` | +| `CI_PIPELINE_FORGE_URL` | link to the forge's web UI for the commit(s) or tag that triggered the pipeline | `https://git.example.com/john-doe/my-repo/commit/eba09b46064473a1d345da7abf28b477468e8dbd` | +| `CI_PIPELINE_DEPLOY_TARGET` | pipeline deploy target for `deployment` events | `production` | +| `CI_PIPELINE_DEPLOY_TASK` | pipeline deploy task for `deployment` events | `migration` | +| `CI_PIPELINE_CREATED` | pipeline created UNIX timestamp | `1722617519` | +| `CI_PIPELINE_STARTED` | pipeline started UNIX timestamp | `1722617519` | +| `CI_PIPELINE_FILES` | changed files (empty if event is not `push` or `pull_request`), it is undefined if more than 500 files are touched | `[]`, `[".woodpecker.yml","README.md"]` | +| `CI_PIPELINE_AUTHOR` | pipeline author username | `octocat` | +| `CI_PIPELINE_AVATAR` | pipeline author avatar | `https://git.example.com/avatars/5dcbcadbce6f87f8abef` | +| | **Current workflow** | | +| `CI_WORKFLOW_NAME` | workflow name | `release` | +| | **Current step** | | +| `CI_STEP_NAME` | step name | `build package` | +| `CI_STEP_NUMBER` | step number | `0` | +| `CI_STEP_STARTED` | step started UNIX timestamp | `1722617519` | +| `CI_STEP_URL` | URL to step in UI | `https://ci.example.com/repos/7/pipeline/8` | +| | **Previous commit** | | +| `CI_PREV_COMMIT_SHA` | previous commit SHA | `15784117e4e103f36cba75a9e29da48046eb82c4` | +| `CI_PREV_COMMIT_REF` | previous commit ref | `refs/heads/main` | +| `CI_PREV_COMMIT_REFSPEC` | previous commit ref spec | `issue-branch:main` | +| `CI_PREV_COMMIT_BRANCH` | previous commit branch | `main` | +| `CI_PREV_COMMIT_SOURCE_BRANCH` | previous commit source branch (set only for pull request events) | `issue-branch` | +| `CI_PREV_COMMIT_TARGET_BRANCH` | previous commit target branch (set only for pull request events) | `main` | +| `CI_PREV_COMMIT_URL` | previous commit link in forge | `https://git.example.com/john-doe/my-repo/commit/15784117e4e103f36cba75a9e29da48046eb82c4` | +| `CI_PREV_COMMIT_MESSAGE` | previous commit message | `test` | +| `CI_PREV_COMMIT_AUTHOR` | previous commit author username | `john-doe` | +| `CI_PREV_COMMIT_AUTHOR_EMAIL` | previous commit author email address | `john-doe@example.com` | +| | **Previous pipeline** | | +| `CI_PREV_PIPELINE_NUMBER` | previous pipeline number | `7` | +| `CI_PREV_PIPELINE_PARENT` | previous pipeline number of parent pipeline | `0` | +| `CI_PREV_PIPELINE_EVENT` | previous pipeline event (see [`event`](../20-usage/20-workflow-syntax.md#event)) | `push`, `pull_request`, `pull_request_closed`, `pull_request_metadata`, `tag`, `release`, `manual`, `cron` | +| `CI_PREV_PIPELINE_EVENT_REASON` | previous exact reason `pull_request_metadata` event was send. it is forge instance specific and can change | `label_updated`, `milestoned`, `demilestoned`, `assigned`, `edited`, ... | +| `CI_PREV_PIPELINE_URL` | previous pipeline link in CI | `https://ci.example.com/repos/7/pipeline/7` | +| `CI_PREV_PIPELINE_FORGE_URL` | previous pipeline link to event in forge | `https://git.example.com/john-doe/my-repo/commit/15784117e4e103f36cba75a9e29da48046eb82c4` | +| `CI_PREV_PIPELINE_DEPLOY_TARGET` | previous pipeline deploy target for `deployment` events | `production` | +| `CI_PREV_PIPELINE_DEPLOY_TASK` | previous pipeline deploy task for `deployment` events | `migration` | +| `CI_PREV_PIPELINE_STATUS` | previous pipeline status | `success`, `failure` | +| `CI_PREV_PIPELINE_CREATED` | previous pipeline created UNIX timestamp | `1722610173` | +| `CI_PREV_PIPELINE_STARTED` | previous pipeline started UNIX timestamp | `1722610173` | +| `CI_PREV_PIPELINE_FINISHED` | previous pipeline finished UNIX timestamp | `1722610383` | +| `CI_PREV_PIPELINE_AUTHOR` | previous pipeline author username | `octocat` | +| `CI_PREV_PIPELINE_AVATAR` | previous pipeline author avatar | `https://git.example.com/avatars/5dcbcadbce6f87f8abef` | +| |   | | +| `CI_WORKSPACE` | Path of the workspace where source code gets cloned to | `/woodpecker/src/git.example.com/john-doe/my-repo` | +| | **System** | | +| `CI_SYSTEM_NAME` | name of the CI system | `woodpecker` | +| `CI_SYSTEM_URL` | link to CI system | `https://ci.example.com` | +| `CI_SYSTEM_HOST` | hostname of CI server | `ci.example.com` | +| `CI_SYSTEM_VERSION` | version of the server | `2.7.0` | +| | **Forge** | | +| `CI_FORGE_TYPE` | name of forge | `bitbucket` , `bitbucket_dc` , `forgejo` , `gitea` , `github` , `gitlab` | +| `CI_FORGE_URL` | root URL of configured forge | `https://git.example.com` | +| | **Internal** - Please don't use! | | +| `CI_SCRIPT` | Internal script path. Used to call pipeline step commands. | | +| `CI_NETRC_USERNAME` | Credentials for private repos to be able to clone data. (Only available for specific images) | | +| `CI_NETRC_PASSWORD` | Credentials for private repos to be able to clone data. (Only available for specific images) | | +| `CI_NETRC_MACHINE` | Credentials for private repos to be able to clone data. (Only available for specific images) | | ## Global environment variables @@ -224,3 +226,34 @@ Example variable substitution strips `v` prefix from `v.1.0.0`: settings: + target: /target/${CI_COMMIT_TAG##v} ``` + +## `pull_request_metadata` specific event reason values + +For the `pull_request_metadata` event, the exact reason a metadata change was detected is passe through in `CI_PIPELINE_EVENT_REASON`. + +**GitLab** merges metadata updates into one webhook. Event reasons are separated by `,` as a list. + +:::note +Event reason values are forge-specific and may change between versions. +::: + +| Event | GitHub | Gitea | Forgejo | GitLab | Bitbucket | Bitbucket Datacenter | Description | +| -------------------- | ------------------ | ------------------ | ------------------ | ------------------ | --------- | -------------------- | ------------------------------------------------------------------------------ | +| `assigned` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :x: | Pull request was assigned to a user | +| `converted_to_draft` | :white_check_mark: | :x: | :x: | :x: | :x: | :x: | Pull request was converted to a draft | +| `demilestoned` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :x: | Pull request was removed from a milestone | +| `description_edited` | :x: | :x: | :x: | :white_check_mark: | :x: | :x: | Description edited | +| `edited` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :x: | :x: | The title or body of a pull request was edited, or the base branch was changed | +| `label_added` | :x: | :x: | :x: | :white_check_mark: | :x: | :x: | Pull had no labels and now got label(s) added | +| `label_cleared` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :x: | All labels removed | +| `label_updated` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :x: | New label(s) added / label(s) changed | +| `locked` | :white_check_mark: | :x: | :x: | :x: | :x: | :x: | Conversation on a pull request was locked | +| `milestoned` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :x: | Pull request was added to a milestone | +| `ready_for_review` | :white_check_mark: | :x: | :x: | :x: | :x: | :x: | Draft pull request was marked as ready for review | +| `review_requested` | :x: | :x: | :x: | :white_check_mark: | :x: | :x: | New review was requested | +| `title_edited` | :x: | :x: | :x: | :white_check_mark: | :x: | :x: | Title edited | +| `unassigned` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :x: | User was unassigned from a pull request | +| `unlabeled` | :white_check_mark: | :x: | :x: | :x: | :x: | :x: | Label was removed from a pull request | +| `unlocked` | :white_check_mark: | :x: | :x: | :x: | :x: | :x: | Conversation on a pull request was unlocked | + +**Bitbucket** and **Bitbucket Datacenter** [are not supported at the moment](https://github.com/woodpecker-ci/woodpecker/pull/5214). diff --git a/docs/docs/30-administration/10-configuration/12-forges/11-overview.md b/docs/docs/30-administration/10-configuration/12-forges/11-overview.md index e819ea73d6f..5167f4f358e 100644 --- a/docs/docs/30-administration/10-configuration/12-forges/11-overview.md +++ b/docs/docs/30-administration/10-configuration/12-forges/11-overview.md @@ -2,14 +2,15 @@ ## Supported features -| Feature | [GitHub](20-github.md) | [Gitea](30-gitea.md) | [Forgejo](35-forgejo.md) | [Gitlab](40-gitlab.md) | [Bitbucket](50-bitbucket.md) | [Bitbucket Datacenter](60-bitbucket_datacenter.md) | -| ---------------------------------------------------------------- | :--------------------: | :------------------: | :----------------------: | :--------------------: | :--------------------------: | :------------------------------------------------: | -| Event: Push | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| Event: Tag | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| Event: Pull-Request | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| Event: Release | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :x: | -| Event: Deploy¹ | :white_check_mark: | :x: | :x: | :x: | :x: | :x: | -| [Multiple workflows](../../../20-usage/25-workflows.md) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| [when.path filter](../../../20-usage/20-workflow-syntax.md#path) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :white_check_mark: | +| Feature | [GitHub](20-github.md) | [Gitea](30-gitea.md) | [Forgejo](35-forgejo.md) | [Gitlab](40-gitlab.md) | [Bitbucket](50-bitbucket.md) | [Bitbucket Datacenter](60-bitbucket_datacenter.md) | +| ---------------------------------------------------------------------------------------------------------------------- | ---------------------- | -------------------- | ------------------------ | ---------------------- | ---------------------------- | -------------------------------------------------- | +| Event: Push | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| Event: Tag | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| Event: Pull-Request | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| Event: Release | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :x: | +| Event: Deploy¹ | :white_check_mark: | :x: | :x: | :x: | :x: | :x: | +| [Event: Pull-Request-Metadata](../../../20-usage/50-environment.md#pull_request_metadata-specific-event-reason-values) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :x: | +| [Multiple workflows](../../../20-usage/25-workflows.md) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| [when.path filter](../../../20-usage/20-workflow-syntax.md#path) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :white_check_mark: | ¹ The deployment event can be triggered for all forges from Woodpecker directly. However, only GitHub can trigger them using webhooks. diff --git a/pipeline/frontend/metadata/const.go b/pipeline/frontend/metadata/const.go index f00ed170984..69b971d93fd 100644 --- a/pipeline/frontend/metadata/const.go +++ b/pipeline/frontend/metadata/const.go @@ -16,16 +16,27 @@ package metadata // Event types corresponding to forge hooks. const ( - EventPush = "push" - EventPull = "pull_request" - EventPullClosed = "pull_request_closed" - EventTag = "tag" - EventRelease = "release" - EventDeploy = "deployment" - EventCron = "cron" - EventManual = "manual" + EventPush = "push" + EventPull = "pull_request" + EventPullClosed = "pull_request_closed" + EventPullMetadata = "pull_request_metadata" + EventTag = "tag" + EventRelease = "release" + EventDeploy = "deployment" + EventCron = "cron" + EventManual = "manual" ) +func EventIsPull(event string) bool { + switch event { + case EventPull, + EventPullClosed, + EventPullMetadata: + return true + } + return false +} + // Different ways to handle failure states. const ( FailureIgnore = "ignore" diff --git a/pipeline/frontend/metadata/environment.go b/pipeline/frontend/metadata/environment.go index 2c595d26f4c..16e128f8a62 100644 --- a/pipeline/frontend/metadata/environment.go +++ b/pipeline/frontend/metadata/environment.go @@ -68,6 +68,7 @@ func (m *Metadata) Environ() map[string]string { setNonEmptyEnvVar(params, "CI_PIPELINE_NUMBER", strconv.FormatInt(pipeline.Number, 10)) setNonEmptyEnvVar(params, "CI_PIPELINE_PARENT", strconv.FormatInt(pipeline.Parent, 10)) setNonEmptyEnvVar(params, "CI_PIPELINE_EVENT", pipeline.Event) + setNonEmptyEnvVar(params, "CI_PIPELINE_EVENT_REASON", strings.Join(pipeline.EventReason, ",")) setNonEmptyEnvVar(params, "CI_PIPELINE_URL", m.getPipelineWebURL(pipeline, 0)) setNonEmptyEnvVar(params, "CI_PIPELINE_FORGE_URL", pipeline.ForgeURL) setNonEmptyEnvVar(params, "CI_PIPELINE_DEPLOY_TARGET", pipeline.DeployTo) @@ -102,7 +103,7 @@ func (m *Metadata) Environ() map[string]string { if pipeline.Event == EventRelease { setNonEmptyEnvVar(params, "CI_COMMIT_PRERELEASE", strconv.FormatBool(pipeline.Commit.IsPrerelease)) } - if pipeline.Event == EventPull || pipeline.Event == EventPullClosed { + if EventIsPull(pipeline.Event) { sourceBranch, targetBranch := getSourceTargetBranches(commit.Refspec) setNonEmptyEnvVar(params, "CI_COMMIT_SOURCE_BRANCH", sourceBranch) setNonEmptyEnvVar(params, "CI_COMMIT_TARGET_BRANCH", targetBranch) @@ -128,6 +129,7 @@ func (m *Metadata) Environ() map[string]string { setNonEmptyEnvVar(params, "CI_PREV_PIPELINE_NUMBER", strconv.FormatInt(prevPipeline.Number, 10)) setNonEmptyEnvVar(params, "CI_PREV_PIPELINE_PARENT", strconv.FormatInt(prevPipeline.Parent, 10)) setNonEmptyEnvVar(params, "CI_PREV_PIPELINE_EVENT", prevPipeline.Event) + setNonEmptyEnvVar(params, "CI_PREV_PIPELINE_EVENT_REASON", strings.Join(prevPipeline.EventReason, ",")) setNonEmptyEnvVar(params, "CI_PREV_PIPELINE_URL", m.getPipelineWebURL(prevPipeline, 0)) setNonEmptyEnvVar(params, "CI_PREV_PIPELINE_FORGE_URL", prevPipeline.ForgeURL) setNonEmptyEnvVar(params, "CI_PREV_COMMIT_URL", prevPipeline.ForgeURL) // why commit url? @@ -149,7 +151,7 @@ func (m *Metadata) Environ() map[string]string { setNonEmptyEnvVar(params, "CI_PREV_COMMIT_AUTHOR", prevCommit.Author.Name) setNonEmptyEnvVar(params, "CI_PREV_COMMIT_AUTHOR_EMAIL", prevCommit.Author.Email) setNonEmptyEnvVar(params, "CI_PREV_COMMIT_AUTHOR_AVATAR", prevCommit.Author.Avatar) - if prevPipeline.Event == EventPull || prevPipeline.Event == EventPullClosed { + if EventIsPull(prevPipeline.Event) { prevSourceBranch, prevTargetBranch := getSourceTargetBranches(prevCommit.Refspec) setNonEmptyEnvVar(params, "CI_PREV_COMMIT_SOURCE_BRANCH", prevSourceBranch) setNonEmptyEnvVar(params, "CI_PREV_COMMIT_TARGET_BRANCH", prevTargetBranch) diff --git a/pipeline/frontend/metadata/types.go b/pipeline/frontend/metadata/types.go index ca08e5591ab..ef550315f87 100644 --- a/pipeline/frontend/metadata/types.go +++ b/pipeline/frontend/metadata/types.go @@ -43,20 +43,21 @@ type ( // Pipeline defines runtime metadata for a pipeline. Pipeline struct { - Number int64 `json:"number,omitempty"` - Created int64 `json:"created,omitempty"` - Started int64 `json:"started,omitempty"` - Finished int64 `json:"finished,omitempty"` - Status string `json:"status,omitempty"` - Event string `json:"event,omitempty"` - ForgeURL string `json:"forge_url,omitempty"` - DeployTo string `json:"target,omitempty"` - DeployTask string `json:"task,omitempty"` - Commit Commit `json:"commit,omitempty"` - Parent int64 `json:"parent,omitempty"` - Cron string `json:"cron,omitempty"` - Author string `json:"author,omitempty"` - Avatar string `json:"avatar,omitempty"` + Number int64 `json:"number,omitempty"` + Created int64 `json:"created,omitempty"` + Started int64 `json:"started,omitempty"` + Finished int64 `json:"finished,omitempty"` + Status string `json:"status,omitempty"` + Event string `json:"event,omitempty"` + EventReason []string `json:"event_reason,omitempty"` + ForgeURL string `json:"forge_url,omitempty"` + DeployTo string `json:"target,omitempty"` + DeployTask string `json:"task,omitempty"` + Commit Commit `json:"commit,omitempty"` + Parent int64 `json:"parent,omitempty"` + Cron string `json:"cron,omitempty"` + Author string `json:"author,omitempty"` + Avatar string `json:"avatar,omitempty"` } // Commit defines runtime metadata for a commit. diff --git a/pipeline/frontend/yaml/compiler/compiler.go b/pipeline/frontend/yaml/compiler/compiler.go index fab26122cfd..612ac540985 100644 --- a/pipeline/frontend/yaml/compiler/compiler.go +++ b/pipeline/frontend/yaml/compiler/compiler.go @@ -70,8 +70,8 @@ func (s *Secret) Match(event string) bool { return true } // treat all pull events the same way - if event == "pull_request_closed" { - event = "pull_request" + if metadata.EventIsPull(event) { + event = metadata.EventPull } // one match is enough return slices.Contains(s.Events, event) diff --git a/pipeline/frontend/yaml/compiler/compiler_test.go b/pipeline/frontend/yaml/compiler/compiler_test.go index 7599e37059a..d770f178c5b 100644 --- a/pipeline/frontend/yaml/compiler/compiler_test.go +++ b/pipeline/frontend/yaml/compiler/compiler_test.go @@ -467,6 +467,12 @@ func TestSecretMatch(t *testing.T) { event: "pull_request_closed", match: true, }, + { + name: "pull metadata change should match pull", + secret: Secret{Events: []string{"pull_request"}}, + event: "pull_request_metadata", + match: true, + }, } for _, tc := range tcl { diff --git a/pipeline/frontend/yaml/constraint/constraint.go b/pipeline/frontend/yaml/constraint/constraint.go index 1dee7477adf..0b8d9de1254 100644 --- a/pipeline/frontend/yaml/constraint/constraint.go +++ b/pipeline/frontend/yaml/constraint/constraint.go @@ -169,7 +169,7 @@ func (c *Constraint) Match(m metadata.Metadata, global bool, env map[string]stri c.Instance.Match(m.Sys.Host) // changed files filter apply only for pull-request and push events - if m.Curr.Event == metadata.EventPull || m.Curr.Event == metadata.EventPullClosed || m.Curr.Event == metadata.EventPush { + if metadata.EventIsPull(m.Curr.Event) || m.Curr.Event == metadata.EventPush { match = match && c.Path.Match(m.Curr.Commit.ChangedFiles, m.Curr.Commit.Message) } diff --git a/pipeline/frontend/yaml/linter/schema/.woodpecker/test-pipeline-when.yaml b/pipeline/frontend/yaml/linter/schema/.woodpecker/test-pipeline-when.yaml index 36446a4f93d..e94ba3d1c60 100644 --- a/pipeline/frontend/yaml/linter/schema/.woodpecker/test-pipeline-when.yaml +++ b/pipeline/frontend/yaml/linter/schema/.woodpecker/test-pipeline-when.yaml @@ -13,6 +13,9 @@ when: - event: exclude: pull_request_closed evaluate: 'CI_COMMIT_AUTHOR == "woodpecker-ci"' + - event: + exclude: pull_request_metadata + evaluate: 'CI_COMMIT_AUTHOR == "woodpecker-ci"' steps: echo: diff --git a/pipeline/frontend/yaml/linter/schema/.woodpecker/test-when.yaml b/pipeline/frontend/yaml/linter/schema/.woodpecker/test-when.yaml index a8235b65e10..93b46219264 100644 --- a/pipeline/frontend/yaml/linter/schema/.woodpecker/test-when.yaml +++ b/pipeline/frontend/yaml/linter/schema/.woodpecker/test-when.yaml @@ -33,6 +33,7 @@ steps: - push - pull_request - pull_request_closed + - pull_request_metadata - tag - deployment - release diff --git a/pipeline/frontend/yaml/linter/schema/schema.json b/pipeline/frontend/yaml/linter/schema/schema.json index 5f02d6af161..51e1bed7ce2 100644 --- a/pipeline/frontend/yaml/linter/schema/schema.json +++ b/pipeline/frontend/yaml/linter/schema/schema.json @@ -503,7 +503,17 @@ } }, "event_enum": { - "enum": ["push", "pull_request", "pull_request_closed", "tag", "deployment", "cron", "manual", "release"] + "enum": [ + "push", + "pull_request", + "pull_request_closed", + "pull_request_metadata", + "tag", + "deployment", + "cron", + "manual", + "release" + ] }, "event_constraint_list": { "oneOf": [ diff --git a/server/api/hook.go b/server/api/hook.go index d11ea5fa450..cd43f5acde6 100644 --- a/server/api/hook.go +++ b/server/api/hook.go @@ -327,7 +327,7 @@ func PostHook(c *gin.Context) { // 5. Check if pull requests are allowed for this repo // - if (pipelineFromForge.Event == model.EventPull || pipelineFromForge.Event == model.EventPullClosed) && !repo.AllowPull { + if pipelineFromForge.IsPullRequest() && !repo.AllowPull { log.Debug().Str("repo", repo.FullName).Msg("ignoring hook: pull requests are disabled for this repo in woodpecker") c.Status(http.StatusNoContent) return diff --git a/server/forge/common/event_normalize.go b/server/forge/common/event_normalize.go new file mode 100644 index 00000000000..c030cd1c36b --- /dev/null +++ b/server/forge/common/event_normalize.go @@ -0,0 +1,13 @@ +package common + +func NormalizeEventReason(in string) string { + switch in { + case "labels_cleared": + return "label_cleared" + case "labels_updated": + return "label_updated" + case "labels_added": + return "label_added" + } + return in +} diff --git a/server/forge/forgejo/fixtures/HookPullRequestAssigneeCleared.json b/server/forge/forgejo/fixtures/HookPullRequestAssigneeCleared.json new file mode 100644 index 00000000000..4710d61a084 --- /dev/null +++ b/server/forge/forgejo/fixtures/HookPullRequestAssigneeCleared.json @@ -0,0 +1,155 @@ +{ + "action": "unassigned", + "number": 1, + "pull_request": { + "id": 701944, + "url": "https://codeberg.org/test_it/test_ci_thing/pulls/1", + "number": 1, + "user": { + "id": 2628, + "login": "6543", + "full_name": "", + "email": "6543@obermui.de", + "avatar_url": "https://codeberg.org/avatars/09a234c768cb9bca78f6b2f82d6af173", + "html_url": "https://codeberg.org/6543", + "visibility": "public" + }, + "title": "Some ned more AAAA", + "body": "", + "labels": [ + { + "id": 494011, + "name": "Kind/Documentation", + "color": "37474f", + "url": "https://codeberg.org/api/v1/repos/test_it/test_ci_thing/labels/494011" + }, + { + "id": 494002, + "name": "Kind/Enhancement", + "color": "84b6eb", + "url": "https://codeberg.org/api/v1/repos/test_it/test_ci_thing/labels/494002" + } + ], + "milestone": { + "id": 22669, + "title": "mile v2" + }, + "assignee": null, + "assignees": null, + "additions": 1, + "deletions": 0, + "changed_files": 1, + "html_url": "https://codeberg.org/test_it/test_ci_thing/pulls/1", + "mergeable": true, + "merged": false, + "merged_at": null, + "merge_commit_sha": null, + "merged_by": null, + "base": { + "label": "main", + "ref": "main", + "sha": "67012991d6c69b1c58378346fca366b864d8d1a1", + "repo_id": 138564, + "repo": { + "id": 138564, + "owner": { + "id": 90470, + "login": "test_it", + "full_name": "", + "email": "", + "avatar_url": "https://codeberg.org/avatars/bb6f3159a98a869b43f20b350542f8fb", + "html_url": "https://codeberg.org/test_it", + "visibility": "public" + }, + "name": "test_ci_thing", + "full_name": "test_it/test_ci_thing", + "private": false, + "fork": false, + "html_url": "https://codeberg.org/test_it/test_ci_thing", + "url": "https://codeberg.org/api/v1/repos/test_it/test_ci_thing", + "ssh_url": "ssh://git@codeberg.org/test_it/test_ci_thing.git", + "clone_url": "https://codeberg.org/test_it/test_ci_thing.git", + "default_branch": "main", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "has_pull_requests": true, + "avatar_url": "" + } + }, + "head": { + "label": "6543-patch-1", + "ref": "6543-patch-1", + "sha": "36b5813240a9d2daa29b05046d56a53e18f39a3e", + "repo_id": 138564, + "repo": { + "id": 138564, + "owner": { + "id": 90470, + "login": "test_it", + "full_name": "", + "email": "", + "avatar_url": "https://codeberg.org/avatars/bb6f3159a98a869b43f20b350542f8fb", + "html_url": "https://codeberg.org/test_it", + "visibility": "public" + }, + "name": "test_ci_thing", + "full_name": "test_it/test_ci_thing", + "private": false, + "fork": false, + "html_url": "https://codeberg.org/test_it/test_ci_thing", + "url": "https://codeberg.org/api/v1/repos/test_it/test_ci_thing", + "ssh_url": "ssh://git@codeberg.org/test_it/test_ci_thing.git", + "clone_url": "https://codeberg.org/test_it/test_ci_thing.git", + "default_branch": "main", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "has_pull_requests": true, + "avatar_url": "" + } + }, + "merge_base": "67012991d6c69b1c58378346fca366b864d8d1a1" + }, + "repository": { + "id": 138564, + "owner": { + "id": 90470, + "login": "test_it", + "full_name": "", + "email": "", + "avatar_url": "https://codeberg.org/avatars/bb6f3159a98a869b43f20b350542f8fb", + "html_url": "https://codeberg.org/test_it", + "visibility": "public" + }, + "name": "test_ci_thing", + "full_name": "test_it/test_ci_thing", + "private": false, + "fork": false, + "html_url": "https://codeberg.org/test_it/test_ci_thing", + "url": "https://codeberg.org/api/v1/repos/test_it/test_ci_thing", + "ssh_url": "ssh://git@codeberg.org/test_it/test_ci_thing.git", + "clone_url": "https://codeberg.org/test_it/test_ci_thing.git", + "default_branch": "main", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "has_pull_requests": true, + "avatar_url": "" + }, + "sender": { + "id": 2628, + "login": "6543", + "full_name": "", + "email": "6543@noreply.codeberg.org", + "avatar_url": "https://codeberg.org/avatars/09a234c768cb9bca78f6b2f82d6af173", + "html_url": "https://codeberg.org/6543", + "visibility": "public" + } +} diff --git a/server/forge/forgejo/fixtures/HookPullRequestAssigneesAdded.json b/server/forge/forgejo/fixtures/HookPullRequestAssigneesAdded.json new file mode 100644 index 00000000000..1f205e1201e --- /dev/null +++ b/server/forge/forgejo/fixtures/HookPullRequestAssigneesAdded.json @@ -0,0 +1,157 @@ +{ + "action": "assigned", + "number": 1, + "pull_request": { + "id": 701944, + "url": "https://codeberg.org/test_it/test_ci_thing/pulls/1", + "number": 1, + "user": { + "id": 2628, + "login": "6543", + "full_name": "", + "email": "6543@obermui.de", + "avatar_url": "https://codeberg.org/avatars/09a234c768cb9bca78f6b2f82d6af173", + "html_url": "https://codeberg.org/6543", + "visibility": "public" + }, + "title": "Some ned more AAAA", + "body": "", + "labels": [], + "milestone": null, + "assignee": { + "id": 2628, + "login": "6543", + "full_name": "", + "email": "6543@noreply.codeberg.org", + "avatar_url": "https://codeberg.org/avatars/09a234c768cb9bca78f6b2f82d6af173", + "html_url": "https://codeberg.org/6543", + "visibility": "public" + }, + "assignees": [ + { + "id": 2628, + "login": "6543", + "full_name": "", + "email": "6543@noreply.codeberg.org", + "avatar_url": "https://codeberg.org/avatars/09a234c768cb9bca78f6b2f82d6af173", + "html_url": "https://codeberg.org/6543", + "visibility": "public" + } + ], + "additions": 1, + "deletions": 0, + "changed_files": 1, + "html_url": "https://codeberg.org/test_it/test_ci_thing/pulls/1", + "mergeable": true, + "merged": false, + "merged_at": null, + "merge_commit_sha": null, + "merged_by": null, + "base": { + "label": "main", + "ref": "main", + "sha": "67012991d6c69b1c58378346fca366b864d8d1a1", + "repo_id": 138564, + "repo": { + "id": 138564, + "owner": { + "id": 90470, + "login": "test_it", + "full_name": "", + "email": "", + "avatar_url": "https://codeberg.org/avatars/bb6f3159a98a869b43f20b350542f8fb", + "html_url": "https://codeberg.org/test_it", + "visibility": "public" + }, + "name": "test_ci_thing", + "full_name": "test_it/test_ci_thing", + "private": false, + "fork": false, + "html_url": "https://codeberg.org/test_it/test_ci_thing", + "url": "https://codeberg.org/api/v1/repos/test_it/test_ci_thing", + "ssh_url": "ssh://git@codeberg.org/test_it/test_ci_thing.git", + "clone_url": "https://codeberg.org/test_it/test_ci_thing.git", + "default_branch": "main", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "has_pull_requests": true, + "avatar_url": "" + } + }, + "head": { + "label": "6543-patch-1", + "ref": "6543-patch-1", + "sha": "36b5813240a9d2daa29b05046d56a53e18f39a3e", + "repo_id": 138564, + "repo": { + "id": 138564, + "owner": { + "id": 90470, + "login": "test_it", + "full_name": "", + "email": "", + "avatar_url": "https://codeberg.org/avatars/bb6f3159a98a869b43f20b350542f8fb", + "html_url": "https://codeberg.org/test_it", + "visibility": "public" + }, + "name": "test_ci_thing", + "full_name": "test_it/test_ci_thing", + "private": false, + "fork": false, + "html_url": "https://codeberg.org/test_it/test_ci_thing", + "url": "https://codeberg.org/api/v1/repos/test_it/test_ci_thing", + "ssh_url": "ssh://git@codeberg.org/test_it/test_ci_thing.git", + "clone_url": "https://codeberg.org/test_it/test_ci_thing.git", + "default_branch": "main", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "has_pull_requests": true, + "avatar_url": "" + } + }, + "merge_base": "67012991d6c69b1c58378346fca366b864d8d1a1" + }, + "repository": { + "id": 138564, + "owner": { + "id": 90470, + "login": "test_it", + "full_name": "", + "email": "", + "avatar_url": "https://codeberg.org/avatars/bb6f3159a98a869b43f20b350542f8fb", + "html_url": "https://codeberg.org/test_it", + "visibility": "public" + }, + "name": "test_ci_thing", + "full_name": "test_it/test_ci_thing", + "private": false, + "fork": false, + "html_url": "https://codeberg.org/test_it/test_ci_thing", + "url": "https://codeberg.org/api/v1/repos/test_it/test_ci_thing", + "ssh_url": "ssh://git@codeberg.org/test_it/test_ci_thing.git", + "clone_url": "https://codeberg.org/test_it/test_ci_thing.git", + "default_branch": "main", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "has_pull_requests": true, + "avatar_url": "" + }, + "sender": { + "id": 2628, + "login": "6543", + "full_name": "", + "email": "6543@noreply.codeberg.org", + "avatar_url": "https://codeberg.org/avatars/09a234c768cb9bca78f6b2f82d6af173", + "html_url": "https://codeberg.org/6543", + "visibility": "public" + } +} diff --git a/server/forge/forgejo/fixtures/HookPullRequestEdited.json b/server/forge/forgejo/fixtures/HookPullRequestEdited.json new file mode 100644 index 00000000000..73f4cf51510 --- /dev/null +++ b/server/forge/forgejo/fixtures/HookPullRequestEdited.json @@ -0,0 +1,131 @@ +{ + "action": "edited", + "number": 1, + "pull_request": { + "id": 62112, + "url": "https://forgejo.com/anbraten/test-repo/pulls/1", + "number": 1, + "user": { + "id": 26907, + "login": "anbraten", + "full_name": "", + "email": "anbraten@forgejo.com", + "avatar_url": "https://seccdn.libravatar.org/avatar/fc9b6fe77c6b732a02925a62a81f05a0?d=identicon", + "visibility": "public" + }, + "title": "Adjust file", + "body": "", + "labels": [], + "milestone": null, + "assignee": null, + "assignees": null, + "html_url": "https://forgejo.com/anbraten/test-repo/pulls/1", + "mergeable": true, + "merged": false, + "merged_at": null, + "merge_commit_sha": null, + "merged_by": null, + "base": { + "label": "main", + "ref": "main", + "sha": "068aee163ffd44eef28a7f9ebd43e2c01774f0fa", + "repo_id": 46534, + "repo": { + "id": 46534, + "owner": { + "id": 26907, + "login": "anbraten", + "full_name": "", + "email": "anbraten@noreply.forgejo.com", + "avatar_url": "https://seccdn.libravatar.org/avatar/fc9b6fe77c6b732a02925a62a81f05a0?d=identicon", + "visibility": "public" + }, + "name": "test-repo", + "full_name": "anbraten/test-repo", + "private": false, + "fork": false, + "html_url": "https://forgejo.com/anbraten/test-repo", + "url": "https://forgejo.com/api/v1/repos/anbraten/test-repo", + "ssh_url": "git@forgejo.com:anbraten/test-repo.git", + "clone_url": "https://forgejo.com/anbraten/test-repo.git", + "default_branch": "main", + "permissions": { + "admin": false, + "push": false, + "pull": true + }, + "has_pull_requests": true, + "avatar_url": "" + } + }, + "head": { + "label": "anbraten-patch-1", + "ref": "anbraten-patch-1", + "sha": "d555a5dd07f4d0148a58d4686ec381502ae6a2d4", + "repo_id": 46534, + "repo": { + "id": 46534, + "owner": { + "id": 26907, + "login": "anbraten", + "full_name": "", + "email": "anbraten@noreply.forgejo.com", + "avatar_url": "https://seccdn.libravatar.org/avatar/fc9b6fe77c6b732a02925a62a81f05a0?d=identicon", + "visibility": "public" + }, + "name": "test-repo", + "full_name": "anbraten/test-repo", + "private": false, + "fork": false, + "html_url": "https://forgejo.com/anbraten/test-repo", + "url": "https://forgejo.com/api/v1/repos/anbraten/test-repo", + "ssh_url": "git@forgejo.com:anbraten/test-repo.git", + "clone_url": "https://forgejo.com/anbraten/test-repo.git", + "default_branch": "main", + "permissions": { + "admin": false, + "push": false, + "pull": true + }, + "has_pull_requests": true, + "avatar_url": "" + } + }, + "merge_base": "068aee163ffd44eef28a7f9ebd43e2c01774f0fa" + }, + "repository": { + "id": 46534, + "owner": { + "id": 26907, + "login": "anbraten", + "full_name": "", + "email": "anbraten@repo.forgejo.com", + "avatar_url": "https://seccdn.libravatar.org/avatar/fc9b6fe77c6b732a02925a62a81f05a0?d=identicon", + "visibility": "public" + }, + "name": "test-repo", + "full_name": "anbraten/test-repo", + "private": false, + "fork": false, + "html_url": "https://forgejo.com/anbraten/test-repo", + "url": "https://forgejo.com/api/v1/repos/anbraten/test-repo", + "ssh_url": "git@forgejo.com:anbraten/test-repo.git", + "clone_url": "https://forgejo.com/anbraten/test-repo.git", + "default_branch": "main", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "has_pull_requests": true, + "avatar_url": "" + }, + "sender": { + "id": 26907, + "login": "anbraten", + "full_name": "", + "email": "anbraten@sender.forgejo.com", + "avatar_url": "https://seccdn.libravatar.org/avatar/fc9b6fe77c6b732a02925a62a81f05a0?d=identicon", + "visibility": "public" + } +} diff --git a/server/forge/forgejo/fixtures/HookPullRequestLabelAdded.json b/server/forge/forgejo/fixtures/HookPullRequestLabelAdded.json new file mode 100644 index 00000000000..64c329b2370 --- /dev/null +++ b/server/forge/forgejo/fixtures/HookPullRequestLabelAdded.json @@ -0,0 +1,173 @@ +{ + "action": "label_updated", + "number": 1, + "pull_request": { + "id": 701944, + "url": "https://codeberg.org/test_it/test_ci_thing/pulls/1", + "number": 1, + "user": { + "id": 2628, + "login": "6543", + "full_name": "", + "email": "6543@obermui.de", + "avatar_url": "https://codeberg.org/avatars/09a234c768cb9bca78f6b2f82d6af173", + "html_url": "https://codeberg.org/6543", + "visibility": "public" + }, + "title": "Some ned more AAAA", + "body": "", + "labels": [ + { + "id": 494011, + "name": "Kind/Documentation", + "color": "37474f", + "url": "https://codeberg.org/api/v1/repos/test_it/test_ci_thing/labels/494011" + }, + { + "id": 494002, + "name": "Kind/Enhancement", + "color": "84b6eb", + "url": "https://codeberg.org/api/v1/repos/test_it/test_ci_thing/labels/494002" + } + ], + "milestone": { + "id": 22669, + "title": "mile v2" + }, + "assignee": { + "id": 2628, + "login": "6543", + "full_name": "", + "email": "6543@noreply.codeberg.org", + "avatar_url": "https://codeberg.org/avatars/09a234c768cb9bca78f6b2f82d6af173", + "html_url": "https://codeberg.org/6543", + "visibility": "public" + }, + "assignees": [ + { + "id": 2628, + "login": "6543", + "full_name": "", + "email": "6543@noreply.codeberg.org", + "avatar_url": "https://codeberg.org/avatars/09a234c768cb9bca78f6b2f82d6af173", + "html_url": "https://codeberg.org/6543", + "visibility": "public" + } + ], + "additions": 1, + "deletions": 0, + "changed_files": 1, + "html_url": "https://codeberg.org/test_it/test_ci_thing/pulls/1", + "mergeable": true, + "merged": false, + "merged_at": null, + "merge_commit_sha": null, + "merged_by": null, + "base": { + "label": "main", + "ref": "main", + "sha": "67012991d6c69b1c58378346fca366b864d8d1a1", + "repo_id": 138564, + "repo": { + "id": 138564, + "owner": { + "id": 90470, + "login": "test_it", + "full_name": "", + "email": "", + "avatar_url": "https://codeberg.org/avatars/bb6f3159a98a869b43f20b350542f8fb", + "html_url": "https://codeberg.org/test_it", + "visibility": "public" + }, + "name": "test_ci_thing", + "full_name": "test_it/test_ci_thing", + "private": false, + "fork": false, + "html_url": "https://codeberg.org/test_it/test_ci_thing", + "url": "https://codeberg.org/api/v1/repos/test_it/test_ci_thing", + "ssh_url": "ssh://git@codeberg.org/test_it/test_ci_thing.git", + "clone_url": "https://codeberg.org/test_it/test_ci_thing.git", + "default_branch": "main", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "has_pull_requests": true, + "avatar_url": "" + } + }, + "head": { + "label": "6543-patch-1", + "ref": "6543-patch-1", + "sha": "36b5813240a9d2daa29b05046d56a53e18f39a3e", + "repo_id": 138564, + "repo": { + "id": 138564, + "owner": { + "id": 90470, + "login": "test_it", + "full_name": "", + "email": "", + "avatar_url": "https://codeberg.org/avatars/bb6f3159a98a869b43f20b350542f8fb", + "html_url": "https://codeberg.org/test_it", + "visibility": "public" + }, + "name": "test_ci_thing", + "full_name": "test_it/test_ci_thing", + "private": false, + "fork": false, + "html_url": "https://codeberg.org/test_it/test_ci_thing", + "url": "https://codeberg.org/api/v1/repos/test_it/test_ci_thing", + "ssh_url": "ssh://git@codeberg.org/test_it/test_ci_thing.git", + "clone_url": "https://codeberg.org/test_it/test_ci_thing.git", + "default_branch": "main", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "has_pull_requests": true, + "avatar_url": "" + } + }, + "merge_base": "67012991d6c69b1c58378346fca366b864d8d1a1" + }, + "repository": { + "id": 138564, + "owner": { + "id": 90470, + "login": "test_it", + "full_name": "", + "email": "", + "avatar_url": "https://codeberg.org/avatars/bb6f3159a98a869b43f20b350542f8fb", + "html_url": "https://codeberg.org/test_it", + "visibility": "public" + }, + "name": "test_ci_thing", + "full_name": "test_it/test_ci_thing", + "private": false, + "fork": false, + "html_url": "https://codeberg.org/test_it/test_ci_thing", + "url": "https://codeberg.org/api/v1/repos/test_it/test_ci_thing", + "ssh_url": "ssh://git@codeberg.org/test_it/test_ci_thing.git", + "clone_url": "https://codeberg.org/test_it/test_ci_thing.git", + "default_branch": "main", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "has_pull_requests": true, + "avatar_url": "" + }, + "sender": { + "id": 2628, + "login": "6543", + "full_name": "", + "email": "6543@noreply.codeberg.org", + "avatar_url": "https://codeberg.org/avatars/09a234c768cb9bca78f6b2f82d6af173", + "html_url": "https://codeberg.org/6543", + "visibility": "public" + } +} diff --git a/server/forge/forgejo/fixtures/HookPullRequestLabelsCleared.json b/server/forge/forgejo/fixtures/HookPullRequestLabelsCleared.json new file mode 100644 index 00000000000..932c97e5b83 --- /dev/null +++ b/server/forge/forgejo/fixtures/HookPullRequestLabelsCleared.json @@ -0,0 +1,155 @@ +{ + "action": "label_cleared", + "number": 1, + "pull_request": { + "id": 701944, + "url": "https://codeberg.org/test_it/test_ci_thing/pulls/1", + "number": 1, + "user": { + "id": 2628, + "login": "6543", + "full_name": "", + "email": "6543@obermui.de", + "avatar_url": "https://codeberg.org/avatars/09a234c768cb9bca78f6b2f82d6af173", + "html_url": "https://codeberg.org/6543", + "visibility": "public" + }, + "title": "Some ned more AAAA", + "body": "", + "labels": [ + { + "id": 494002, + "name": "Kind/Enhancement", + "color": "84b6eb", + "url": "https://codeberg.org/api/v1/repos/test_it/test_ci_thing/labels/494002" + }, + { + "id": 494008, + "name": "Kind/Testing", + "color": "795548", + "url": "https://codeberg.org/api/v1/repos/test_it/test_ci_thing/labels/494008" + } + ], + "milestone": { + "id": 22666, + "title": "mile v1" + }, + "assignee": null, + "assignees": null, + "additions": 1, + "deletions": 0, + "changed_files": 1, + "html_url": "https://codeberg.org/test_it/test_ci_thing/pulls/1", + "mergeable": true, + "merged": false, + "merged_at": null, + "merge_commit_sha": null, + "merged_by": null, + "base": { + "label": "main", + "ref": "main", + "sha": "67012991d6c69b1c58378346fca366b864d8d1a1", + "repo_id": 138564, + "repo": { + "id": 138564, + "owner": { + "id": 90470, + "login": "test_it", + "full_name": "", + "email": "", + "avatar_url": "https://codeberg.org/avatars/bb6f3159a98a869b43f20b350542f8fb", + "html_url": "https://codeberg.org/test_it", + "visibility": "public" + }, + "name": "test_ci_thing", + "full_name": "test_it/test_ci_thing", + "private": false, + "fork": false, + "html_url": "https://codeberg.org/test_it/test_ci_thing", + "url": "https://codeberg.org/api/v1/repos/test_it/test_ci_thing", + "ssh_url": "ssh://git@codeberg.org/test_it/test_ci_thing.git", + "clone_url": "https://codeberg.org/test_it/test_ci_thing.git", + "default_branch": "main", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "has_pull_requests": true, + "avatar_url": "" + } + }, + "head": { + "label": "6543-patch-1", + "ref": "6543-patch-1", + "sha": "36b5813240a9d2daa29b05046d56a53e18f39a3e", + "repo_id": 138564, + "repo": { + "id": 138564, + "owner": { + "id": 90470, + "login": "test_it", + "full_name": "", + "email": "", + "avatar_url": "https://codeberg.org/avatars/bb6f3159a98a869b43f20b350542f8fb", + "html_url": "https://codeberg.org/test_it", + "visibility": "public" + }, + "name": "test_ci_thing", + "full_name": "test_it/test_ci_thing", + "private": false, + "fork": false, + "html_url": "https://codeberg.org/test_it/test_ci_thing", + "url": "https://codeberg.org/api/v1/repos/test_it/test_ci_thing", + "ssh_url": "ssh://git@codeberg.org/test_it/test_ci_thing.git", + "clone_url": "https://codeberg.org/test_it/test_ci_thing.git", + "default_branch": "main", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "has_pull_requests": true, + "avatar_url": "" + } + }, + "merge_base": "67012991d6c69b1c58378346fca366b864d8d1a1" + }, + "repository": { + "id": 138564, + "owner": { + "id": 90470, + "login": "test_it", + "full_name": "", + "email": "", + "avatar_url": "https://codeberg.org/avatars/bb6f3159a98a869b43f20b350542f8fb", + "html_url": "https://codeberg.org/test_it", + "visibility": "public" + }, + "name": "test_ci_thing", + "full_name": "test_it/test_ci_thing", + "private": false, + "fork": false, + "html_url": "https://codeberg.org/test_it/test_ci_thing", + "url": "https://codeberg.org/api/v1/repos/test_it/test_ci_thing", + "ssh_url": "ssh://git@codeberg.org/test_it/test_ci_thing.git", + "clone_url": "https://codeberg.org/test_it/test_ci_thing.git", + "default_branch": "main", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "has_pull_requests": true, + "avatar_url": "" + }, + "sender": { + "id": 2628, + "login": "6543", + "full_name": "", + "email": "6543@noreply.codeberg.org", + "avatar_url": "https://codeberg.org/avatars/09a234c768cb9bca78f6b2f82d6af173", + "html_url": "https://codeberg.org/6543", + "visibility": "public" + } +} diff --git a/server/forge/forgejo/fixtures/HookPullRequestLabelsUpdated.json b/server/forge/forgejo/fixtures/HookPullRequestLabelsUpdated.json new file mode 100644 index 00000000000..3aa3638e4ae --- /dev/null +++ b/server/forge/forgejo/fixtures/HookPullRequestLabelsUpdated.json @@ -0,0 +1,155 @@ +{ + "action": "label_updated", + "number": 1, + "pull_request": { + "id": 701944, + "url": "https://codeberg.org/test_it/test_ci_thing/pulls/1", + "number": 1, + "user": { + "id": 2628, + "login": "6543", + "full_name": "", + "email": "6543@obermui.de", + "avatar_url": "https://codeberg.org/avatars/09a234c768cb9bca78f6b2f82d6af173", + "html_url": "https://codeberg.org/6543", + "visibility": "public" + }, + "title": "Some ned more AAAA", + "body": "", + "labels": [ + { + "id": 494002, + "name": "Kind/Enhancement", + "color": "84b6eb", + "url": "https://codeberg.org/api/v1/repos/test_it/test_ci_thing/labels/494002" + }, + { + "id": 494008, + "name": "Kind/Testing", + "color": "795548", + "url": "https://codeberg.org/api/v1/repos/test_it/test_ci_thing/labels/494008" + } + ], + "milestone": { + "id": 22666, + "title": "mile v1" + }, + "assignee": null, + "assignees": null, + "additions": 1, + "deletions": 0, + "changed_files": 1, + "html_url": "https://codeberg.org/test_it/test_ci_thing/pulls/1", + "mergeable": true, + "merged": false, + "merged_at": null, + "merge_commit_sha": null, + "merged_by": null, + "base": { + "label": "main", + "ref": "main", + "sha": "67012991d6c69b1c58378346fca366b864d8d1a1", + "repo_id": 138564, + "repo": { + "id": 138564, + "owner": { + "id": 90470, + "login": "test_it", + "full_name": "", + "email": "", + "avatar_url": "https://codeberg.org/avatars/bb6f3159a98a869b43f20b350542f8fb", + "html_url": "https://codeberg.org/test_it", + "visibility": "public" + }, + "name": "test_ci_thing", + "full_name": "test_it/test_ci_thing", + "private": false, + "fork": false, + "html_url": "https://codeberg.org/test_it/test_ci_thing", + "url": "https://codeberg.org/api/v1/repos/test_it/test_ci_thing", + "ssh_url": "ssh://git@codeberg.org/test_it/test_ci_thing.git", + "clone_url": "https://codeberg.org/test_it/test_ci_thing.git", + "default_branch": "main", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "has_pull_requests": true, + "avatar_url": "" + } + }, + "head": { + "label": "6543-patch-1", + "ref": "6543-patch-1", + "sha": "36b5813240a9d2daa29b05046d56a53e18f39a3e", + "repo_id": 138564, + "repo": { + "id": 138564, + "owner": { + "id": 90470, + "login": "test_it", + "full_name": "", + "email": "", + "avatar_url": "https://codeberg.org/avatars/bb6f3159a98a869b43f20b350542f8fb", + "html_url": "https://codeberg.org/test_it", + "visibility": "public" + }, + "name": "test_ci_thing", + "full_name": "test_it/test_ci_thing", + "private": false, + "fork": false, + "html_url": "https://codeberg.org/test_it/test_ci_thing", + "url": "https://codeberg.org/api/v1/repos/test_it/test_ci_thing", + "ssh_url": "ssh://git@codeberg.org/test_it/test_ci_thing.git", + "clone_url": "https://codeberg.org/test_it/test_ci_thing.git", + "default_branch": "main", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "has_pull_requests": true, + "avatar_url": "" + } + }, + "merge_base": "67012991d6c69b1c58378346fca366b864d8d1a1" + }, + "repository": { + "id": 138564, + "owner": { + "id": 90470, + "login": "test_it", + "full_name": "", + "email": "", + "avatar_url": "https://codeberg.org/avatars/bb6f3159a98a869b43f20b350542f8fb", + "html_url": "https://codeberg.org/test_it", + "visibility": "public" + }, + "name": "test_ci_thing", + "full_name": "test_it/test_ci_thing", + "private": false, + "fork": false, + "html_url": "https://codeberg.org/test_it/test_ci_thing", + "url": "https://codeberg.org/api/v1/repos/test_it/test_ci_thing", + "ssh_url": "ssh://git@codeberg.org/test_it/test_ci_thing.git", + "clone_url": "https://codeberg.org/test_it/test_ci_thing.git", + "default_branch": "main", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "has_pull_requests": true, + "avatar_url": "" + }, + "sender": { + "id": 2628, + "login": "6543", + "full_name": "", + "email": "6543@noreply.codeberg.org", + "avatar_url": "https://codeberg.org/avatars/09a234c768cb9bca78f6b2f82d6af173", + "html_url": "https://codeberg.org/6543", + "visibility": "public" + } +} diff --git a/server/forge/forgejo/fixtures/HookPullRequestMilestoneAdded.json b/server/forge/forgejo/fixtures/HookPullRequestMilestoneAdded.json new file mode 100644 index 00000000000..158e1a889a0 --- /dev/null +++ b/server/forge/forgejo/fixtures/HookPullRequestMilestoneAdded.json @@ -0,0 +1,160 @@ +{ + "action": "milestoned", + "number": 1, + "pull_request": { + "id": 701944, + "url": "https://codeberg.org/test_it/test_ci_thing/pulls/1", + "number": 1, + "user": { + "id": 2628, + "login": "6543", + "full_name": "", + "email": "6543@obermui.de", + "avatar_url": "https://codeberg.org/avatars/09a234c768cb9bca78f6b2f82d6af173", + "html_url": "https://codeberg.org/6543", + "visibility": "public" + }, + "title": "Some ned more AAAA", + "body": "", + "labels": [], + "milestone": { + "id": 22669, + "title": "mile v2" + }, + "assignee": { + "id": 2628, + "login": "6543", + "full_name": "", + "email": "6543@noreply.codeberg.org", + "avatar_url": "https://codeberg.org/avatars/09a234c768cb9bca78f6b2f82d6af173", + "html_url": "https://codeberg.org/6543", + "visibility": "public" + }, + "assignees": [ + { + "id": 2628, + "login": "6543", + "full_name": "", + "email": "6543@noreply.codeberg.org", + "avatar_url": "https://codeberg.org/avatars/09a234c768cb9bca78f6b2f82d6af173", + "html_url": "https://codeberg.org/6543", + "visibility": "public" + } + ], + "additions": 1, + "deletions": 0, + "changed_files": 1, + "html_url": "https://codeberg.org/test_it/test_ci_thing/pulls/1", + "mergeable": true, + "merged": false, + "merged_at": null, + "merge_commit_sha": null, + "merged_by": null, + "base": { + "label": "main", + "ref": "main", + "sha": "67012991d6c69b1c58378346fca366b864d8d1a1", + "repo_id": 138564, + "repo": { + "id": 138564, + "owner": { + "id": 90470, + "login": "test_it", + "full_name": "", + "email": "", + "avatar_url": "https://codeberg.org/avatars/bb6f3159a98a869b43f20b350542f8fb", + "html_url": "https://codeberg.org/test_it", + "visibility": "public" + }, + "name": "test_ci_thing", + "full_name": "test_it/test_ci_thing", + "private": false, + "fork": false, + "html_url": "https://codeberg.org/test_it/test_ci_thing", + "url": "https://codeberg.org/api/v1/repos/test_it/test_ci_thing", + "ssh_url": "ssh://git@codeberg.org/test_it/test_ci_thing.git", + "clone_url": "https://codeberg.org/test_it/test_ci_thing.git", + "default_branch": "main", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "has_pull_requests": true, + "avatar_url": "" + } + }, + "head": { + "label": "6543-patch-1", + "ref": "6543-patch-1", + "sha": "36b5813240a9d2daa29b05046d56a53e18f39a3e", + "repo_id": 138564, + "repo": { + "id": 138564, + "owner": { + "id": 90470, + "login": "test_it", + "full_name": "", + "email": "", + "avatar_url": "https://codeberg.org/avatars/bb6f3159a98a869b43f20b350542f8fb", + "html_url": "https://codeberg.org/test_it", + "visibility": "public" + }, + "name": "test_ci_thing", + "full_name": "test_it/test_ci_thing", + "private": false, + "fork": false, + "html_url": "https://codeberg.org/test_it/test_ci_thing", + "url": "https://codeberg.org/api/v1/repos/test_it/test_ci_thing", + "ssh_url": "ssh://git@codeberg.org/test_it/test_ci_thing.git", + "clone_url": "https://codeberg.org/test_it/test_ci_thing.git", + "default_branch": "main", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "has_pull_requests": true, + "avatar_url": "" + } + }, + "merge_base": "67012991d6c69b1c58378346fca366b864d8d1a1" + }, + "repository": { + "id": 138564, + "owner": { + "id": 90470, + "login": "test_it", + "full_name": "", + "email": "", + "avatar_url": "https://codeberg.org/avatars/bb6f3159a98a869b43f20b350542f8fb", + "html_url": "https://codeberg.org/test_it", + "visibility": "public" + }, + "name": "test_ci_thing", + "full_name": "test_it/test_ci_thing", + "private": false, + "fork": false, + "html_url": "https://codeberg.org/test_it/test_ci_thing", + "url": "https://codeberg.org/api/v1/repos/test_it/test_ci_thing", + "ssh_url": "ssh://git@codeberg.org/test_it/test_ci_thing.git", + "clone_url": "https://codeberg.org/test_it/test_ci_thing.git", + "default_branch": "main", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "has_pull_requests": true, + "avatar_url": "" + }, + "sender": { + "id": 2628, + "login": "6543", + "full_name": "", + "email": "6543@noreply.codeberg.org", + "avatar_url": "https://codeberg.org/avatars/09a234c768cb9bca78f6b2f82d6af173", + "html_url": "https://codeberg.org/6543", + "visibility": "public" + } +} diff --git a/server/forge/forgejo/fixtures/HookPullRequestMilestoneChanged.json b/server/forge/forgejo/fixtures/HookPullRequestMilestoneChanged.json new file mode 100644 index 00000000000..d57390be5b8 --- /dev/null +++ b/server/forge/forgejo/fixtures/HookPullRequestMilestoneChanged.json @@ -0,0 +1,155 @@ +{ + "action": "milestoned", + "number": 1, + "pull_request": { + "id": 701944, + "url": "https://codeberg.org/test_it/test_ci_thing/pulls/1", + "number": 1, + "user": { + "id": 2628, + "login": "6543", + "full_name": "", + "email": "6543@obermui.de", + "avatar_url": "https://codeberg.org/avatars/09a234c768cb9bca78f6b2f82d6af173", + "html_url": "https://codeberg.org/6543", + "visibility": "public" + }, + "title": "Some ned more AAAA", + "body": "", + "labels": [ + { + "id": 494011, + "name": "Kind/Documentation", + "color": "37474f", + "url": "https://codeberg.org/api/v1/repos/test_it/test_ci_thing/labels/494011" + }, + { + "id": 494002, + "name": "Kind/Enhancement", + "color": "84b6eb", + "url": "https://codeberg.org/api/v1/repos/test_it/test_ci_thing/labels/494002" + } + ], + "milestone": { + "id": 22669, + "title": "mile v2" + }, + "assignee": null, + "assignees": null, + "additions": 1, + "deletions": 0, + "changed_files": 1, + "html_url": "https://codeberg.org/test_it/test_ci_thing/pulls/1", + "mergeable": true, + "merged": false, + "merged_at": null, + "merge_commit_sha": null, + "merged_by": null, + "base": { + "label": "main", + "ref": "main", + "sha": "67012991d6c69b1c58378346fca366b864d8d1a1", + "repo_id": 138564, + "repo": { + "id": 138564, + "owner": { + "id": 90470, + "login": "test_it", + "full_name": "", + "email": "", + "avatar_url": "https://codeberg.org/avatars/bb6f3159a98a869b43f20b350542f8fb", + "html_url": "https://codeberg.org/test_it", + "visibility": "public" + }, + "name": "test_ci_thing", + "full_name": "test_it/test_ci_thing", + "private": false, + "fork": false, + "html_url": "https://codeberg.org/test_it/test_ci_thing", + "url": "https://codeberg.org/api/v1/repos/test_it/test_ci_thing", + "ssh_url": "ssh://git@codeberg.org/test_it/test_ci_thing.git", + "clone_url": "https://codeberg.org/test_it/test_ci_thing.git", + "default_branch": "main", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "has_pull_requests": true, + "avatar_url": "" + } + }, + "head": { + "label": "6543-patch-1", + "ref": "6543-patch-1", + "sha": "36b5813240a9d2daa29b05046d56a53e18f39a3e", + "repo_id": 138564, + "repo": { + "id": 138564, + "owner": { + "id": 90470, + "login": "test_it", + "full_name": "", + "email": "", + "avatar_url": "https://codeberg.org/avatars/bb6f3159a98a869b43f20b350542f8fb", + "html_url": "https://codeberg.org/test_it", + "visibility": "public" + }, + "name": "test_ci_thing", + "full_name": "test_it/test_ci_thing", + "private": false, + "fork": false, + "html_url": "https://codeberg.org/test_it/test_ci_thing", + "url": "https://codeberg.org/api/v1/repos/test_it/test_ci_thing", + "ssh_url": "ssh://git@codeberg.org/test_it/test_ci_thing.git", + "clone_url": "https://codeberg.org/test_it/test_ci_thing.git", + "default_branch": "main", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "has_pull_requests": true, + "avatar_url": "" + } + }, + "merge_base": "67012991d6c69b1c58378346fca366b864d8d1a1" + }, + "repository": { + "id": 138564, + "owner": { + "id": 90470, + "login": "test_it", + "full_name": "", + "email": "", + "avatar_url": "https://codeberg.org/avatars/bb6f3159a98a869b43f20b350542f8fb", + "html_url": "https://codeberg.org/test_it", + "visibility": "public" + }, + "name": "test_ci_thing", + "full_name": "test_it/test_ci_thing", + "private": false, + "fork": false, + "html_url": "https://codeberg.org/test_it/test_ci_thing", + "url": "https://codeberg.org/api/v1/repos/test_it/test_ci_thing", + "ssh_url": "ssh://git@codeberg.org/test_it/test_ci_thing.git", + "clone_url": "https://codeberg.org/test_it/test_ci_thing.git", + "default_branch": "main", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "has_pull_requests": true, + "avatar_url": "" + }, + "sender": { + "id": 2628, + "login": "6543", + "full_name": "", + "email": "6543@noreply.codeberg.org", + "avatar_url": "https://codeberg.org/avatars/09a234c768cb9bca78f6b2f82d6af173", + "html_url": "https://codeberg.org/6543", + "visibility": "public" + } +} diff --git a/server/forge/forgejo/fixtures/HookPullRequestMilestoneCleared.json b/server/forge/forgejo/fixtures/HookPullRequestMilestoneCleared.json new file mode 100644 index 00000000000..d1253472688 --- /dev/null +++ b/server/forge/forgejo/fixtures/HookPullRequestMilestoneCleared.json @@ -0,0 +1,139 @@ +{ + "action": "demilestoned", + "number": 1, + "pull_request": { + "id": 701944, + "url": "https://codeberg.org/test_it/test_ci_thing/pulls/1", + "number": 1, + "user": { + "id": 2628, + "login": "6543", + "full_name": "", + "email": "6543@obermui.de", + "avatar_url": "https://codeberg.org/avatars/09a234c768cb9bca78f6b2f82d6af173", + "html_url": "https://codeberg.org/6543", + "visibility": "public" + }, + "title": "Some ned more AAAA", + "body": "", + "labels": [], + "milestone": null, + "assignee": null, + "assignees": null, + "additions": 1, + "deletions": 0, + "changed_files": 1, + "html_url": "https://codeberg.org/test_it/test_ci_thing/pulls/1", + "mergeable": true, + "merged": false, + "merged_at": null, + "merge_commit_sha": null, + "merged_by": null, + "base": { + "label": "main", + "ref": "main", + "sha": "67012991d6c69b1c58378346fca366b864d8d1a1", + "repo_id": 138564, + "repo": { + "id": 138564, + "owner": { + "id": 90470, + "login": "test_it", + "full_name": "", + "email": "", + "avatar_url": "https://codeberg.org/avatars/bb6f3159a98a869b43f20b350542f8fb", + "html_url": "https://codeberg.org/test_it", + "visibility": "public" + }, + "name": "test_ci_thing", + "full_name": "test_it/test_ci_thing", + "private": false, + "fork": false, + "html_url": "https://codeberg.org/test_it/test_ci_thing", + "url": "https://codeberg.org/api/v1/repos/test_it/test_ci_thing", + "ssh_url": "ssh://git@codeberg.org/test_it/test_ci_thing.git", + "clone_url": "https://codeberg.org/test_it/test_ci_thing.git", + "default_branch": "main", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "has_pull_requests": true, + "avatar_url": "" + } + }, + "head": { + "label": "6543-patch-1", + "ref": "6543-patch-1", + "sha": "36b5813240a9d2daa29b05046d56a53e18f39a3e", + "repo_id": 138564, + "repo": { + "id": 138564, + "owner": { + "id": 90470, + "login": "test_it", + "full_name": "", + "email": "", + "avatar_url": "https://codeberg.org/avatars/bb6f3159a98a869b43f20b350542f8fb", + "html_url": "https://codeberg.org/test_it", + "visibility": "public" + }, + "name": "test_ci_thing", + "full_name": "test_it/test_ci_thing", + "private": false, + "fork": false, + "html_url": "https://codeberg.org/test_it/test_ci_thing", + "url": "https://codeberg.org/api/v1/repos/test_it/test_ci_thing", + "ssh_url": "ssh://git@codeberg.org/test_it/test_ci_thing.git", + "clone_url": "https://codeberg.org/test_it/test_ci_thing.git", + "default_branch": "main", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "has_pull_requests": true, + "avatar_url": "" + } + }, + "merge_base": "67012991d6c69b1c58378346fca366b864d8d1a1" + }, + "repository": { + "id": 138564, + "owner": { + "id": 90470, + "login": "test_it", + "full_name": "", + "email": "", + "avatar_url": "https://codeberg.org/avatars/bb6f3159a98a869b43f20b350542f8fb", + "html_url": "https://codeberg.org/test_it", + "visibility": "public" + }, + "name": "test_ci_thing", + "full_name": "test_it/test_ci_thing", + "private": false, + "fork": false, + "html_url": "https://codeberg.org/test_it/test_ci_thing", + "url": "https://codeberg.org/api/v1/repos/test_it/test_ci_thing", + "ssh_url": "ssh://git@codeberg.org/test_it/test_ci_thing.git", + "clone_url": "https://codeberg.org/test_it/test_ci_thing.git", + "default_branch": "main", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "has_pull_requests": true, + "avatar_url": "" + }, + "sender": { + "id": 2628, + "login": "6543", + "full_name": "", + "email": "6543@noreply.codeberg.org", + "avatar_url": "https://codeberg.org/avatars/09a234c768cb9bca78f6b2f82d6af173", + "html_url": "https://codeberg.org/6543", + "visibility": "public" + } +} diff --git a/server/forge/forgejo/fixtures/hooks.go b/server/forge/forgejo/fixtures/hooks.go index fa5975dd6f1..52efc180d0d 100644 --- a/server/forge/forgejo/fixtures/hooks.go +++ b/server/forge/forgejo/fixtures/hooks.go @@ -50,8 +50,35 @@ var HookPullRequestMerged string //go:embed HookPullRequestClosed.json var HookPullRequestClosed string +//go:embed HookPullRequestEdited.json +var HookPullRequestEdited string + //go:embed HookRelease.json var HookRelease string +//go:embed HookPullRequestAssigneesAdded.json +var HookPullRequestAssigneesAdded string + +//go:embed HookPullRequestMilestoneAdded.json +var HookPullRequestMilestoneAdded string + +//go:embed HookPullRequestLabelAdded.json +var HookPullRequestLabelAdded string + +//go:embed HookPullRequestAssigneeCleared.json +var HookPullRequestAssigneeCleared string + +//go:embed HookPullRequestMilestoneChanged.json +var HookPullRequestMilestoneChanged string + +//go:embed HookPullRequestLabelsUpdated.json +var HookPullRequestLabelsUpdated string + +//go:embed HookPullRequestLabelsCleared.json +var HookPullRequestLabelsCleared string + +//go:embed HookPullRequestMilestoneCleared.json +var HookPullRequestMilestoneCleared string + //go:embed HookPullRequestReopened.json var HookPullRequestReopened string diff --git a/server/forge/forgejo/forgejo.go b/server/forge/forgejo/forgejo.go index 2599f5b16a3..7f276f13afe 100644 --- a/server/forge/forgejo/forgejo.go +++ b/server/forge/forgejo/forgejo.go @@ -501,7 +501,7 @@ func (c *Forgejo) Hook(ctx context.Context, r *http.Request) (*model.Repo, *mode pipeline.Commit = sha } - if pipeline != nil && (pipeline.Event == model.EventPull || pipeline.Event == model.EventPullClosed) && len(pipeline.ChangedFiles) == 0 { + if pipeline != nil && pipeline.IsPullRequest() && len(pipeline.ChangedFiles) == 0 { index, err := strconv.ParseInt(strings.Split(pipeline.Ref, "/")[2], 10, 64) if err != nil { return nil, nil, err diff --git a/server/forge/forgejo/helper.go b/server/forge/forgejo/helper.go index 7b20e35d8cc..8a8affa0f7d 100644 --- a/server/forge/forgejo/helper.go +++ b/server/forge/forgejo/helper.go @@ -149,8 +149,17 @@ func pipelineFromPullRequest(hook *pullRequestHook) *model.Pipeline { ) event := model.EventPull - if hook.Action == actionClose { + switch hook.Action { + case actionClose: event = model.EventPullClosed + case actionEdited, + actionLabelUpdate, + actionLabelCleared, + actionMilestoned, + actionDeMilestoned, + actionAssigned, + actionUnAssigned: + event = model.EventPullMetadata } pipeline := &model.Pipeline{ @@ -174,6 +183,10 @@ func pipelineFromPullRequest(hook *pullRequestHook) *model.Pipeline { FromFork: hook.PullRequest.Head.RepoID != hook.PullRequest.Base.RepoID, } + if pipeline.Event == model.EventPullMetadata { + pipeline.EventReason = []string{hook.Action} + } + return pipeline } diff --git a/server/forge/forgejo/parse.go b/server/forge/forgejo/parse.go index 8bf927dcba5..3bc16f3408c 100644 --- a/server/forge/forgejo/parse.go +++ b/server/forge/forgejo/parse.go @@ -17,10 +17,12 @@ package forgejo import ( "io" "net/http" + "slices" "strings" "github.com/rs/zerolog/log" + "go.woodpecker-ci.org/woodpecker/v3/server/forge/common" "go.woodpecker-ci.org/woodpecker/v3/server/forge/types" "go.woodpecker-ci.org/woodpecker/v3/server/model" ) @@ -32,15 +34,40 @@ const ( hookPullRequest = "pull_request" hookRelease = "release" - actionOpen = "opened" - actionSync = "synchronized" - actionClose = "closed" - actionReopen = "reopened" + actionOpen = "opened" + actionSync = "synchronized" + actionClose = "closed" + actionEdited = "edited" + actionLabelUpdate = "label_updated" + actionLabelCleared = "label_cleared" + actionMilestoned = "milestoned" + actionDeMilestoned = "demilestoned" + actionAssigned = "assigned" + actionUnAssigned = "unassigned" + actionReopen = "reopened" refBranch = "branch" refTag = "tag" ) +var actionList = []string{ + actionOpen, + actionSync, + actionClose, + actionEdited, + actionLabelUpdate, + actionMilestoned, + actionDeMilestoned, + actionLabelCleared, + actionAssigned, + actionUnAssigned, + actionReopen, +} + +func supportedAction(action string) bool { + return slices.Contains(actionList, action) +} + // parseHook parses a Forgejo hook from an http.Request and returns // Repo and Pipeline detail. If a hook type is unsupported nil values are returned. func parseHook(r *http.Request) (*model.Repo, *model.Pipeline, error) { @@ -111,17 +138,27 @@ func parsePullRequestHook(payload io.Reader) (*model.Repo, *model.Pipeline, erro return nil, nil, err } - // Don't trigger pipelines for non-code changes ... - if pr.Action != actionOpen && - pr.Action != actionSync && - pr.Action != actionClose && - pr.Action != actionReopen { - log.Debug().Msgf("pull_request action is '%s' and no open or sync", pr.Action) + // Only trigger pipelines for supported event types + if !supportedAction(pr.Action) { + log.Debug().Msgf("pull_request action is '%s'. Only '%s' are supported", pr.Action, strings.Join(actionList, "', '")) return nil, nil, nil } repo = toRepo(pr.Repo) pipeline = pipelineFromPullRequest(pr) + + // all other actions return the state of labels after the actions where done ... so we should too + if pr.Action == actionLabelCleared { + pipeline.PullRequestLabels = []string{} + } + if pr.Action == actionDeMilestoned { + pipeline.PullRequestMilestone = "" + } + + for i := range pipeline.EventReason { + pipeline.EventReason[i] = common.NormalizeEventReason(pipeline.EventReason[i]) + } + return repo, pipeline, err } diff --git a/server/forge/forgejo/parse_test.go b/server/forge/forgejo/parse_test.go index 94cb8391fd0..5ea9265730f 100644 --- a/server/forge/forgejo/parse_test.go +++ b/server/forge/forgejo/parse_test.go @@ -293,6 +293,44 @@ func TestForgejoParser(t *testing.T) { }, }, }, + { + name: "pull-request events should handle a PR edited hook when PR got edited", + data: fixtures.HookPullRequestEdited, + event: "pull_request", + repo: &model.Repo{ + ForgeRemoteID: "46534", + Owner: "anbraten", + Name: "test-repo", + FullName: "anbraten/test-repo", + Avatar: "https://seccdn.libravatar.org/avatar/fc9b6fe77c6b732a02925a62a81f05a0?d=identicon", + ForgeURL: "https://forgejo.com/anbraten/test-repo", + Clone: "https://forgejo.com/anbraten/test-repo.git", + CloneSSH: "git@forgejo.com:anbraten/test-repo.git", + Branch: "main", + PREnabled: true, + Perm: &model.Perm{ + Pull: true, + Push: true, + Admin: true, + }, + }, + pipe: &model.Pipeline{ + Author: "anbraten", + Event: "pull_request_metadata", + EventReason: []string{"edited"}, + Commit: "d555a5dd07f4d0148a58d4686ec381502ae6a2d4", + Branch: "main", + Ref: "refs/pull/1/head", + Refspec: "anbraten-patch-1:main", + Title: "Adjust file", + Message: "Adjust file", + Sender: "anbraten", + Avatar: "https://seccdn.libravatar.org/avatar/fc9b6fe77c6b732a02925a62a81f05a0?d=identicon", + Email: "anbraten@sender.forgejo.com", + ForgeURL: "https://forgejo.com/anbraten/test-repo/pulls/1", + PullRequestLabels: []string{}, + }, + }, { name: "pull-request events should handle a PR closed hook when PR got closed", data: fixtures.HookPullRequestClosed, @@ -401,6 +439,324 @@ func TestForgejoParser(t *testing.T) { ForgeURL: "https://git.xxx/anbraten/demo/releases/tag/0.0.5", }, }, + { + name: "pull-request events should handle a PR assignees added hook when assignees are added", + data: fixtures.HookPullRequestAssigneesAdded, + event: "pull_request", + repo: &model.Repo{ + ForgeRemoteID: "138564", + Owner: "test_it", + Name: "test_ci_thing", + FullName: "test_it/test_ci_thing", + Avatar: "https://codeberg.org/avatars/bb6f3159a98a869b43f20b350542f8fb", + ForgeURL: "https://codeberg.org/test_it/test_ci_thing", + Clone: "https://codeberg.org/test_it/test_ci_thing.git", + CloneSSH: "ssh://git@codeberg.org/test_it/test_ci_thing.git", + Branch: "main", + PREnabled: true, + Perm: &model.Perm{ + Pull: true, + Push: true, + Admin: true, + }, + }, + pipe: &model.Pipeline{ + Author: "6543", + Event: "pull_request_metadata", + EventReason: []string{"assigned"}, + Commit: "36b5813240a9d2daa29b05046d56a53e18f39a3e", + Branch: "main", + Ref: "refs/pull/1/head", + Refspec: "6543-patch-1:main", + Title: "Some ned more AAAA", + Message: "Some ned more AAAA", + Sender: "6543", + Avatar: "https://codeberg.org/avatars/09a234c768cb9bca78f6b2f82d6af173", + Email: "6543@noreply.codeberg.org", + ForgeURL: "https://codeberg.org/test_it/test_ci_thing/pulls/1", + PullRequestLabels: []string{}, + ChangedFiles: nil, + }, + }, + { + name: "pull-request events should handle a PR milestone added hook when milestone is added", + data: fixtures.HookPullRequestMilestoneAdded, + event: "pull_request", + repo: &model.Repo{ + ForgeRemoteID: "138564", + Owner: "test_it", + Name: "test_ci_thing", + FullName: "test_it/test_ci_thing", + Avatar: "https://codeberg.org/avatars/bb6f3159a98a869b43f20b350542f8fb", + ForgeURL: "https://codeberg.org/test_it/test_ci_thing", + Clone: "https://codeberg.org/test_it/test_ci_thing.git", + CloneSSH: "ssh://git@codeberg.org/test_it/test_ci_thing.git", + Branch: "main", + PREnabled: true, + Perm: &model.Perm{ + Pull: true, + Push: true, + Admin: true, + }, + }, + pipe: &model.Pipeline{ + Author: "6543", + Event: "pull_request_metadata", + EventReason: []string{"milestoned"}, + Commit: "36b5813240a9d2daa29b05046d56a53e18f39a3e", + Branch: "main", + Ref: "refs/pull/1/head", + Refspec: "6543-patch-1:main", + Title: "Some ned more AAAA", + Message: "Some ned more AAAA", + Sender: "6543", + Avatar: "https://codeberg.org/avatars/09a234c768cb9bca78f6b2f82d6af173", + Email: "6543@noreply.codeberg.org", + ForgeURL: "https://codeberg.org/test_it/test_ci_thing/pulls/1", + PullRequestLabels: []string{}, + PullRequestMilestone: "mile v2", + ChangedFiles: nil, + }, + }, + { + name: "pull-request events should handle a PR label updated hook when labels are updated", + data: fixtures.HookPullRequestLabelAdded, + event: "pull_request", + repo: &model.Repo{ + ForgeRemoteID: "138564", + Owner: "test_it", + Name: "test_ci_thing", + FullName: "test_it/test_ci_thing", + Avatar: "https://codeberg.org/avatars/bb6f3159a98a869b43f20b350542f8fb", + ForgeURL: "https://codeberg.org/test_it/test_ci_thing", + Clone: "https://codeberg.org/test_it/test_ci_thing.git", + CloneSSH: "ssh://git@codeberg.org/test_it/test_ci_thing.git", + Branch: "main", + PREnabled: true, + Perm: &model.Perm{ + Pull: true, + Push: true, + Admin: true, + }, + }, + pipe: &model.Pipeline{ + Author: "6543", + Event: "pull_request_metadata", + EventReason: []string{"label_updated"}, + Commit: "36b5813240a9d2daa29b05046d56a53e18f39a3e", + Branch: "main", + Ref: "refs/pull/1/head", + Refspec: "6543-patch-1:main", + Title: "Some ned more AAAA", + Message: "Some ned more AAAA", + Sender: "6543", + Avatar: "https://codeberg.org/avatars/09a234c768cb9bca78f6b2f82d6af173", + Email: "6543@noreply.codeberg.org", + ForgeURL: "https://codeberg.org/test_it/test_ci_thing/pulls/1", + PullRequestLabels: []string{"Kind/Documentation", "Kind/Enhancement"}, + PullRequestMilestone: "mile v2", + ChangedFiles: nil, + }, + }, + { + name: "pull-request events should handle a PR assignee cleared hook when assignee is removed", + data: fixtures.HookPullRequestAssigneeCleared, + event: "pull_request", + repo: &model.Repo{ + ForgeRemoteID: "138564", + Owner: "test_it", + Name: "test_ci_thing", + FullName: "test_it/test_ci_thing", + Avatar: "https://codeberg.org/avatars/bb6f3159a98a869b43f20b350542f8fb", + ForgeURL: "https://codeberg.org/test_it/test_ci_thing", + Clone: "https://codeberg.org/test_it/test_ci_thing.git", + CloneSSH: "ssh://git@codeberg.org/test_it/test_ci_thing.git", + Branch: "main", + PREnabled: true, + Perm: &model.Perm{ + Pull: true, + Push: true, + Admin: true, + }, + }, + pipe: &model.Pipeline{ + Author: "6543", + Event: "pull_request_metadata", + EventReason: []string{"unassigned"}, + Commit: "36b5813240a9d2daa29b05046d56a53e18f39a3e", + Branch: "main", + Ref: "refs/pull/1/head", + Refspec: "6543-patch-1:main", + Title: "Some ned more AAAA", + Message: "Some ned more AAAA", + Sender: "6543", + Avatar: "https://codeberg.org/avatars/09a234c768cb9bca78f6b2f82d6af173", + Email: "6543@noreply.codeberg.org", + ForgeURL: "https://codeberg.org/test_it/test_ci_thing/pulls/1", + PullRequestLabels: []string{"Kind/Documentation", "Kind/Enhancement"}, + PullRequestMilestone: "mile v2", + ChangedFiles: nil, + }, + }, + { + name: "pull-request events should handle a PR milestone changed hook when milestone is changed", + data: fixtures.HookPullRequestMilestoneChanged, + event: "pull_request", + repo: &model.Repo{ + ForgeRemoteID: "138564", + Owner: "test_it", + Name: "test_ci_thing", + FullName: "test_it/test_ci_thing", + Avatar: "https://codeberg.org/avatars/bb6f3159a98a869b43f20b350542f8fb", + ForgeURL: "https://codeberg.org/test_it/test_ci_thing", + Clone: "https://codeberg.org/test_it/test_ci_thing.git", + CloneSSH: "ssh://git@codeberg.org/test_it/test_ci_thing.git", + Branch: "main", + PREnabled: true, + Perm: &model.Perm{ + Pull: true, + Push: true, + Admin: true, + }, + }, + pipe: &model.Pipeline{ + Author: "6543", + Event: "pull_request_metadata", + EventReason: []string{"milestoned"}, + Commit: "36b5813240a9d2daa29b05046d56a53e18f39a3e", + Branch: "main", + Ref: "refs/pull/1/head", + Refspec: "6543-patch-1:main", + Title: "Some ned more AAAA", + Message: "Some ned more AAAA", + Sender: "6543", + Avatar: "https://codeberg.org/avatars/09a234c768cb9bca78f6b2f82d6af173", + Email: "6543@noreply.codeberg.org", + ForgeURL: "https://codeberg.org/test_it/test_ci_thing/pulls/1", + PullRequestLabels: []string{"Kind/Documentation", "Kind/Enhancement"}, + PullRequestMilestone: "mile v2", + ChangedFiles: nil, + }, + }, + { + name: "pull-request events should handle a PR labels updated hook when labels are updated", + data: fixtures.HookPullRequestLabelsUpdated, + event: "pull_request", + repo: &model.Repo{ + ForgeRemoteID: "138564", + Owner: "test_it", + Name: "test_ci_thing", + FullName: "test_it/test_ci_thing", + Avatar: "https://codeberg.org/avatars/bb6f3159a98a869b43f20b350542f8fb", + ForgeURL: "https://codeberg.org/test_it/test_ci_thing", + Clone: "https://codeberg.org/test_it/test_ci_thing.git", + CloneSSH: "ssh://git@codeberg.org/test_it/test_ci_thing.git", + Branch: "main", + PREnabled: true, + Perm: &model.Perm{ + Pull: true, + Push: true, + Admin: true, + }, + }, + pipe: &model.Pipeline{ + Author: "6543", + Event: "pull_request_metadata", + EventReason: []string{"label_updated"}, + Commit: "36b5813240a9d2daa29b05046d56a53e18f39a3e", + Branch: "main", + Ref: "refs/pull/1/head", + Refspec: "6543-patch-1:main", + Title: "Some ned more AAAA", + Message: "Some ned more AAAA", + Sender: "6543", + Avatar: "https://codeberg.org/avatars/09a234c768cb9bca78f6b2f82d6af173", + Email: "6543@noreply.codeberg.org", + ForgeURL: "https://codeberg.org/test_it/test_ci_thing/pulls/1", + PullRequestLabels: []string{"Kind/Enhancement", "Kind/Testing"}, + PullRequestMilestone: "mile v1", + ChangedFiles: nil, + }, + }, + { + name: "pull-request events should handle a PR labels cleared hook when labels are cleared", + data: fixtures.HookPullRequestLabelsCleared, + event: "pull_request", + repo: &model.Repo{ + ForgeRemoteID: "138564", + Owner: "test_it", + Name: "test_ci_thing", + FullName: "test_it/test_ci_thing", + Avatar: "https://codeberg.org/avatars/bb6f3159a98a869b43f20b350542f8fb", + ForgeURL: "https://codeberg.org/test_it/test_ci_thing", + Clone: "https://codeberg.org/test_it/test_ci_thing.git", + CloneSSH: "ssh://git@codeberg.org/test_it/test_ci_thing.git", + Branch: "main", + PREnabled: true, + Perm: &model.Perm{ + Pull: true, + Push: true, + Admin: true, + }, + }, + pipe: &model.Pipeline{ + Author: "6543", + Event: "pull_request_metadata", + EventReason: []string{"label_cleared"}, + Commit: "36b5813240a9d2daa29b05046d56a53e18f39a3e", + Branch: "main", + Ref: "refs/pull/1/head", + Refspec: "6543-patch-1:main", + Title: "Some ned more AAAA", + Message: "Some ned more AAAA", + Sender: "6543", + Avatar: "https://codeberg.org/avatars/09a234c768cb9bca78f6b2f82d6af173", + Email: "6543@noreply.codeberg.org", + ForgeURL: "https://codeberg.org/test_it/test_ci_thing/pulls/1", + PullRequestLabels: []string{}, + PullRequestMilestone: "mile v1", + ChangedFiles: nil, + }, + }, + { + name: "pull-request events should handle a PR milestone cleared hook when milestone is removed", + data: fixtures.HookPullRequestMilestoneCleared, + event: "pull_request", + repo: &model.Repo{ + ForgeRemoteID: "138564", + Owner: "test_it", + Name: "test_ci_thing", + FullName: "test_it/test_ci_thing", + Avatar: "https://codeberg.org/avatars/bb6f3159a98a869b43f20b350542f8fb", + ForgeURL: "https://codeberg.org/test_it/test_ci_thing", + Clone: "https://codeberg.org/test_it/test_ci_thing.git", + CloneSSH: "ssh://git@codeberg.org/test_it/test_ci_thing.git", + Branch: "main", + PREnabled: true, + Perm: &model.Perm{ + Pull: true, + Push: true, + Admin: true, + }, + }, + pipe: &model.Pipeline{ + Author: "6543", + Event: "pull_request_metadata", + EventReason: []string{"demilestoned"}, + Commit: "36b5813240a9d2daa29b05046d56a53e18f39a3e", + Branch: "main", + Ref: "refs/pull/1/head", + Refspec: "6543-patch-1:main", + Title: "Some ned more AAAA", + Message: "Some ned more AAAA", + Sender: "6543", + Avatar: "https://codeberg.org/avatars/09a234c768cb9bca78f6b2f82d6af173", + Email: "6543@noreply.codeberg.org", + ForgeURL: "https://codeberg.org/test_it/test_ci_thing/pulls/1", + PullRequestLabels: []string{}, + ChangedFiles: nil, + }, + }, } for _, tc := range tests { diff --git a/server/forge/gitea/fixtures/HookPullRequestAddLabel.json b/server/forge/gitea/fixtures/HookPullRequestAddLabel.json new file mode 100644 index 00000000000..b7cce2a5ce2 --- /dev/null +++ b/server/forge/gitea/fixtures/HookPullRequestAddLabel.json @@ -0,0 +1,184 @@ +{ + "action": "label_updated", + "number": 7, + "pull_request": { + "id": 3779, + "url": "https://gitea.com/a_nice_user/hello_world_ci/pulls/7", + "number": 7, + "user": { + "id": 21, + "login": "jony", + "full_name": "Jony", + "email": "jony@noreply.example.org", + "avatar_url": "https://gitea.com/avatars/81027235e996f5e3ef6257152357b85d94171a2e", + "html_url": "https://gitea.com/jony", + "created": "2018-01-25T14:38:19+01:00", + "visibility": "public", + "username": "jony" + }, + "title": "somepull", + "body": "wow aaa new pulll body", + "labels": [ + { + "id": 285, + "name": "bug", + "exclusive": false, + "is_archived": false, + "color": "ee0701", + "description": "Something is not working", + "url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci/labels/285" + }, + { + "id": 297, + "name": "help wanted", + "exclusive": false, + "is_archived": false, + "color": "128a0c", + "description": "Need some help", + "url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci/labels/297" + } + ], + "milestone": null, + "assignees": null, + "requested_reviewers": [ + { + "id": 8765, + "login": "a_nice_user", + "full_name": "Nice User", + "email": "a_nice_user@noreply.example.org", + "avatar_url": "https://gitea.com/avatars/ae32f5573b27f9840942a522d59032b104a2dd15", + "html_url": "https://gitea.com/a_nice_user", + "created": "2023-05-23T15:17:35+02:00", + "visibility": "public", + "username": "a_nice_user" + } + ], + "state": "open", + "additions": 1, + "deletions": 0, + "changed_files": 1, + "html_url": "https://gitea.com/a_nice_user/hello_world_ci/pulls/7", + "diff_url": "https://gitea.com/a_nice_user/hello_world_ci/pulls/7.diff", + "patch_url": "https://gitea.com/a_nice_user/hello_world_ci/pulls/7.patch", + "base": { + "label": "main", + "ref": "main", + "sha": "a40211c506550ebd79633d84e913dafa184c6d56", + "repo_id": 1234, + "repo": { + "id": 1234, + "owner": { + "id": 8765, + "login": "a_nice_user", + "full_name": "Nice User", + "email": "a_nice_user@me.mail", + "avatar_url": "https://gitea.com/avatars/ae32f5573b27f9840942a522d59032b104a2dd15", + "html_url": "https://gitea.com/a_nice_user", + "created": "2023-05-23T15:17:35+02:00", + "visibility": "public", + "username": "a_nice_user" + }, + "name": "hello_world_ci", + "full_name": "a_nice_user/hello_world_ci", + "private": false, + "languages_url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci/languages", + "html_url": "https://gitea.com/a_nice_user/hello_world_ci", + "url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci", + "link": "", + "ssh_url": "ssh://git@gitea.com:3344/a_nice_user/hello_world_ci.git", + "clone_url": "https://gitea.com/a_nice_user/hello_world_ci.git", + "default_branch": "main", + "permissions": { + "admin": false, + "push": false, + "pull": true + }, + "object_format_name": "sha1" + } + }, + "head": { + "label": "jony-patch-1", + "ref": "jony-patch-1", + "sha": "07977177c2cd7d46bad37b8472a9d50e7acb9d1f", + "repo_id": 1234, + "repo": { + "id": 1234, + "owner": { + "id": 8765, + "login": "a_nice_user", + "full_name": "Nice User", + "email": "a_nice_user@me.mail", + "avatar_url": "https://gitea.com/avatars/ae32f5573b27f9840942a522d59032b104a2dd15", + "html_url": "https://gitea.com/a_nice_user", + "created": "2023-05-23T15:17:35+02:00", + "visibility": "public", + "username": "a_nice_user" + }, + "name": "hello_world_ci", + "full_name": "a_nice_user/hello_world_ci", + "private": false, + "languages_url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci/languages", + "html_url": "https://gitea.com/a_nice_user/hello_world_ci", + "url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci", + "link": "", + "ssh_url": "ssh://git@gitea.com:3344/a_nice_user/hello_world_ci.git", + "clone_url": "https://gitea.com/a_nice_user/hello_world_ci.git", + "default_branch": "main", + "permissions": { + "admin": false, + "push": false, + "pull": true + }, + "object_format_name": "sha1" + } + }, + "merge_base": "a40211c506550ebd79633d84e913dafa184c6d56", + "due_date": null, + "closed_at": null, + "pin_order": 0 + }, + "requested_reviewer": null, + "repository": { + "id": 1234, + "owner": { + "id": 8765, + "login": "a_nice_user", + "full_name": "Nice User", + "email": "a_nice_user@me.mail", + "avatar_url": "https://gitea.com/avatars/ae32f5573b27f9840942a522d59032b104a2dd15", + "html_url": "https://gitea.com/a_nice_user", + "created": "2023-05-23T15:17:35+02:00", + "visibility": "public", + "username": "a_nice_user" + }, + "name": "hello_world_ci", + "full_name": "a_nice_user/hello_world_ci", + "private": false, + "has_pull_requests": true, + "languages_url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci/languages", + "html_url": "https://gitea.com/a_nice_user/hello_world_ci", + "url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci", + "link": "", + "ssh_url": "ssh://git@gitea.com:3344/a_nice_user/hello_world_ci.git", + "clone_url": "https://gitea.com/a_nice_user/hello_world_ci.git", + "default_branch": "main", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "object_format_name": "sha1" + }, + "sender": { + "id": 8765, + "login": "a_nice_user", + "full_name": "Nice User", + "email": "a_nice_user@noreply.example.org", + "avatar_url": "https://gitea.com/avatars/ae32f5573b27f9840942a522d59032b104a2dd15", + "html_url": "https://gitea.com/a_nice_user", + "created": "2023-05-23T15:17:35+02:00", + "visibility": "public", + "username": "a_nice_user" + }, + "review": null +} diff --git a/server/forge/gitea/fixtures/HookPullRequestAddMile.json b/server/forge/gitea/fixtures/HookPullRequestAddMile.json new file mode 100644 index 00000000000..4e67395f35e --- /dev/null +++ b/server/forge/gitea/fixtures/HookPullRequestAddMile.json @@ -0,0 +1,192 @@ +{ + "action": "milestoned", + "number": 7, + "pull_request": { + "id": 3779, + "url": "https://gitea.com/a_nice_user/hello_world_ci/pulls/7", + "number": 7, + "user": { + "id": 21, + "login": "jony", + "full_name": "Jony", + "email": "jony@noreply.example.org", + "avatar_url": "https://gitea.com/avatars/81027235e996f5e3ef6257152357b85d94171a2e", + "html_url": "https://gitea.com/jony", + "created": "2018-01-25T14:38:19+01:00", + "visibility": "public", + "username": "jony" + }, + "title": "somepull", + "body": "wow aaa new pulll body", + "labels": [ + { + "id": 285, + "name": "bug", + "exclusive": false, + "is_archived": false, + "color": "ee0701", + "description": "Something is not working", + "url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci/labels/285" + }, + { + "id": 297, + "name": "help wanted", + "exclusive": false, + "is_archived": false, + "color": "128a0c", + "description": "Need some help", + "url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci/labels/297" + } + ], + "milestone": { + "id": 277, + "title": "new mile", + "state": "open", + "open_issues": 1, + "closed_issues": 0, + "closed_at": null, + "due_on": null + }, + "assignees": null, + "requested_reviewers": [ + { + "id": 8765, + "login": "a_nice_user", + "full_name": "Nice User", + "email": "a_nice_user@noreply.example.org", + "avatar_url": "https://gitea.com/avatars/ae32f5573b27f9840942a522d59032b104a2dd15", + "html_url": "https://gitea.com/a_nice_user", + "created": "2023-05-23T15:17:35+02:00", + "visibility": "public", + "username": "a_nice_user" + } + ], + "state": "open", + "additions": 1, + "deletions": 0, + "changed_files": 1, + "html_url": "https://gitea.com/a_nice_user/hello_world_ci/pulls/7", + "diff_url": "https://gitea.com/a_nice_user/hello_world_ci/pulls/7.diff", + "patch_url": "https://gitea.com/a_nice_user/hello_world_ci/pulls/7.patch", + "base": { + "label": "main", + "ref": "main", + "sha": "a40211c506550ebd79633d84e913dafa184c6d56", + "repo_id": 1234, + "repo": { + "id": 1234, + "owner": { + "id": 8765, + "login": "a_nice_user", + "full_name": "Nice User", + "email": "a_nice_user@me.mail", + "avatar_url": "https://gitea.com/avatars/ae32f5573b27f9840942a522d59032b104a2dd15", + "html_url": "https://gitea.com/a_nice_user", + "created": "2023-05-23T15:17:35+02:00", + "visibility": "public", + "username": "a_nice_user" + }, + "name": "hello_world_ci", + "full_name": "a_nice_user/hello_world_ci", + "private": false, + "languages_url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci/languages", + "html_url": "https://gitea.com/a_nice_user/hello_world_ci", + "url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci", + "link": "", + "ssh_url": "ssh://git@gitea.com:3344/a_nice_user/hello_world_ci.git", + "clone_url": "https://gitea.com/a_nice_user/hello_world_ci.git", + "default_branch": "main", + "permissions": { + "admin": false, + "push": false, + "pull": true + }, + "object_format_name": "sha1" + } + }, + "head": { + "label": "jony-patch-1", + "ref": "jony-patch-1", + "sha": "07977177c2cd7d46bad37b8472a9d50e7acb9d1f", + "repo_id": 1234, + "repo": { + "id": 1234, + "owner": { + "id": 8765, + "login": "a_nice_user", + "full_name": "Nice User", + "email": "a_nice_user@me.mail", + "avatar_url": "https://gitea.com/avatars/ae32f5573b27f9840942a522d59032b104a2dd15", + "html_url": "https://gitea.com/a_nice_user", + "created": "2023-05-23T15:17:35+02:00", + "visibility": "public", + "username": "a_nice_user" + }, + "name": "hello_world_ci", + "full_name": "a_nice_user/hello_world_ci", + "private": false, + "languages_url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci/languages", + "html_url": "https://gitea.com/a_nice_user/hello_world_ci", + "url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci", + "link": "", + "ssh_url": "ssh://git@gitea.com:3344/a_nice_user/hello_world_ci.git", + "clone_url": "https://gitea.com/a_nice_user/hello_world_ci.git", + "default_branch": "main", + "permissions": { + "admin": false, + "push": false, + "pull": true + }, + "object_format_name": "sha1" + } + }, + "merge_base": "a40211c506550ebd79633d84e913dafa184c6d56", + "due_date": null, + "closed_at": null, + "pin_order": 0 + }, + "requested_reviewer": null, + "repository": { + "id": 1234, + "owner": { + "id": 8765, + "login": "a_nice_user", + "full_name": "Nice User", + "email": "a_nice_user@me.mail", + "avatar_url": "https://gitea.com/avatars/ae32f5573b27f9840942a522d59032b104a2dd15", + "html_url": "https://gitea.com/a_nice_user", + "created": "2023-05-23T15:17:35+02:00", + "visibility": "public", + "username": "a_nice_user" + }, + "name": "hello_world_ci", + "full_name": "a_nice_user/hello_world_ci", + "private": false, + "has_pull_requests": true, + "languages_url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci/languages", + "html_url": "https://gitea.com/a_nice_user/hello_world_ci", + "url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci", + "link": "", + "ssh_url": "ssh://git@gitea.com:3344/a_nice_user/hello_world_ci.git", + "clone_url": "https://gitea.com/a_nice_user/hello_world_ci.git", + "default_branch": "main", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "object_format_name": "sha1" + }, + "sender": { + "id": 8765, + "login": "a_nice_user", + "full_name": "Nice User", + "email": "a_nice_user@noreply.example.org", + "avatar_url": "https://gitea.com/avatars/ae32f5573b27f9840942a522d59032b104a2dd15", + "html_url": "https://gitea.com/a_nice_user", + "created": "2023-05-23T15:17:35+02:00", + "visibility": "public", + "username": "a_nice_user" + }, + "review": null +} diff --git a/server/forge/gitea/fixtures/HookPullRequestAddReviewRequest.json b/server/forge/gitea/fixtures/HookPullRequestAddReviewRequest.json new file mode 100644 index 00000000000..3f139e253ee --- /dev/null +++ b/server/forge/gitea/fixtures/HookPullRequestAddReviewRequest.json @@ -0,0 +1,175 @@ +{ + "action": "review_requested", + "number": 7, + "pull_request": { + "id": 3779, + "url": "https://gitea.com/a_nice_user/hello_world_ci/pulls/7", + "number": 7, + "user": { + "id": 21, + "login": "jony", + "full_name": "Jony", + "email": "jony@noreply.example.org", + "avatar_url": "https://gitea.com/avatars/81027235e996f5e3ef6257152357b85d94171a2e", + "html_url": "https://gitea.com/jony", + "created": "2018-01-25T14:38:19+01:00", + "visibility": "public", + "username": "jony" + }, + "title": "somepull", + "body": "wow aaa new pulll body", + "labels": [], + "milestone": null, + "assignees": null, + "requested_reviewers": [ + { + "id": 8765, + "login": "a_nice_user", + "full_name": "Nice User", + "email": "a_nice_user@noreply.example.org", + "avatar_url": "https://gitea.com/avatars/ae32f5573b27f9840942a522d59032b104a2dd15", + "html_url": "https://gitea.com/a_nice_user", + "created": "2023-05-23T15:17:35+02:00", + "visibility": "public", + "username": "a_nice_user" + } + ], + "state": "open", + "additions": 1, + "deletions": 0, + "changed_files": 1, + "html_url": "https://gitea.com/a_nice_user/hello_world_ci/pulls/7", + "diff_url": "https://gitea.com/a_nice_user/hello_world_ci/pulls/7.diff", + "patch_url": "https://gitea.com/a_nice_user/hello_world_ci/pulls/7.patch", + "base": { + "label": "main", + "ref": "main", + "sha": "a40211c506550ebd79633d84e913dafa184c6d56", + "repo_id": 1234, + "repo": { + "id": 1234, + "owner": { + "id": 8765, + "login": "a_nice_user", + "full_name": "Nice User", + "email": "a_nice_user@me.mail", + "avatar_url": "https://gitea.com/avatars/ae32f5573b27f9840942a522d59032b104a2dd15", + "html_url": "https://gitea.com/a_nice_user", + "created": "2023-05-23T15:17:35+02:00", + "visibility": "public", + "username": "a_nice_user" + }, + "name": "hello_world_ci", + "full_name": "a_nice_user/hello_world_ci", + "private": false, + "languages_url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci/languages", + "html_url": "https://gitea.com/a_nice_user/hello_world_ci", + "url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci", + "link": "", + "ssh_url": "ssh://git@gitea.com:3344/a_nice_user/hello_world_ci.git", + "clone_url": "https://gitea.com/a_nice_user/hello_world_ci.git", + "default_branch": "main", + "permissions": { + "admin": false, + "push": false, + "pull": true + }, + "object_format_name": "sha1" + } + }, + "head": { + "label": "jony-patch-1", + "ref": "jony-patch-1", + "sha": "07977177c2cd7d46bad37b8472a9d50e7acb9d1f", + "repo_id": 1234, + "repo": { + "id": 1234, + "owner": { + "id": 8765, + "login": "a_nice_user", + "full_name": "Nice User", + "email": "a_nice_user@me.mail", + "avatar_url": "https://gitea.com/avatars/ae32f5573b27f9840942a522d59032b104a2dd15", + "html_url": "https://gitea.com/a_nice_user", + "created": "2023-05-23T15:17:35+02:00", + "visibility": "public", + "username": "a_nice_user" + }, + "name": "hello_world_ci", + "full_name": "a_nice_user/hello_world_ci", + "private": false, + "languages_url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci/languages", + "html_url": "https://gitea.com/a_nice_user/hello_world_ci", + "url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci", + "link": "", + "ssh_url": "ssh://git@gitea.com:3344/a_nice_user/hello_world_ci.git", + "clone_url": "https://gitea.com/a_nice_user/hello_world_ci.git", + "default_branch": "main", + "permissions": { + "admin": false, + "push": false, + "pull": true + }, + "object_format_name": "sha1" + } + }, + "merge_base": "a40211c506550ebd79633d84e913dafa184c6d56", + "due_date": null, + "closed_at": null, + "pin_order": 0 + }, + "requested_reviewer": { + "id": 8765, + "login": "a_nice_user", + "full_name": "Nice User", + "email": "a_nice_user@noreply.example.org", + "avatar_url": "https://gitea.com/avatars/ae32f5573b27f9840942a522d59032b104a2dd15", + "html_url": "https://gitea.com/a_nice_user", + "created": "2023-05-23T15:17:35+02:00", + "visibility": "public", + "username": "a_nice_user" + }, + "repository": { + "id": 1234, + "owner": { + "id": 8765, + "login": "a_nice_user", + "full_name": "Nice User", + "email": "a_nice_user@me.mail", + "avatar_url": "https://gitea.com/avatars/ae32f5573b27f9840942a522d59032b104a2dd15", + "html_url": "https://gitea.com/a_nice_user", + "created": "2023-05-23T15:17:35+02:00", + "visibility": "public", + "username": "a_nice_user" + }, + "name": "hello_world_ci", + "full_name": "a_nice_user/hello_world_ci", + "private": false, + "has_pull_requests": true, + "languages_url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci/languages", + "html_url": "https://gitea.com/a_nice_user/hello_world_ci", + "url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci", + "link": "", + "ssh_url": "ssh://git@gitea.com:3344/a_nice_user/hello_world_ci.git", + "clone_url": "https://gitea.com/a_nice_user/hello_world_ci.git", + "default_branch": "main", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "object_format_name": "sha1" + }, + "sender": { + "id": 8765, + "login": "a_nice_user", + "full_name": "Nice User", + "email": "a_nice_user@noreply.example.org", + "avatar_url": "https://gitea.com/avatars/ae32f5573b27f9840942a522d59032b104a2dd15", + "html_url": "https://gitea.com/a_nice_user", + "created": "2023-05-23T15:17:35+02:00", + "visibility": "public", + "username": "a_nice_user" + }, + "review": null +} diff --git a/server/forge/gitea/fixtures/HookPullRequestAssigneesAdded.json b/server/forge/gitea/fixtures/HookPullRequestAssigneesAdded.json new file mode 100644 index 00000000000..374222f4219 --- /dev/null +++ b/server/forge/gitea/fixtures/HookPullRequestAssigneesAdded.json @@ -0,0 +1,193 @@ +{ + "action": "assigned", + "number": 7, + "pull_request": { + "id": 3779, + "url": "https://gitea.com/a_nice_user/hello_world_ci/pulls/7", + "number": 7, + "user": { + "id": 1, + "login": "jony", + "full_name": "Jony", + "email": "jony@noreply.example.org", + "avatar_url": "https://gitea.com/avatars/81027235e996f5e3ef6257152357b85d94171a2e", + "html_url": "https://gitea.com/jony", + "visibility": "public", + "username": "jony" + }, + "title": "somepull", + "body": "wow aaa new pulll body", + "labels": [ + { + "id": 285, + "name": "bug", + "exclusive": false, + "color": "ee0701", + "description": "Something is not working", + "url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci/labels/285" + } + ], + "milestone": null, + "assignee": { + "id": 6, + "login": "lilly", + "full_name": "Lilly Apple", + "email": "lilly@noreply.example.org", + "avatar_url": "https://gitea.com/avatars/a02de81c8ee997fc0aff3c6ebe18841903a75fd6", + "html_url": "https://gitea.com/lilly", + "visibility": "public", + "username": "lilly" + }, + "assignees": [ + { + "id": 6, + "login": "lilly", + "full_name": "Lilly Apple", + "email": "lilly@noreply.example.org", + "avatar_url": "https://gitea.com/avatars/a02de81c8ee997fc0aff3c6ebe18841903a75fd6", + "html_url": "https://gitea.com/lilly", + "visibility": "public", + "username": "lilly" + } + ], + "requested_reviewers": [ + { + "id": 349, + "login": "a_nice_user", + "full_name": "Nice User", + "email": "a_nice_user@noreply.example.org", + "avatar_url": "https://gitea.com/avatars/ae32f5573b27f9840942a522d59032b104a2dd15", + "html_url": "https://gitea.com/a_nice_user", + "visibility": "public", + "username": "a_nice_user" + } + ], + "state": "open", + "draft": false, + "is_locked": false, + "comments": 0, + "review_comments": 0, + "additions": 1, + "deletions": 0, + "changed_files": 1, + "html_url": "https://gitea.com/a_nice_user/hello_world_ci/pulls/7", + "diff_url": "https://gitea.com/a_nice_user/hello_world_ci/pulls/7.diff", + "patch_url": "https://gitea.com/a_nice_user/hello_world_ci/pulls/7.patch", + "mergeable": true, + "merged": false, + "merged_at": null, + "merge_commit_sha": null, + "merged_by": null, + "allow_maintainer_edit": false, + "base": { + "label": "main", + "ref": "main", + "sha": "a40211c506550ebd79633d84e913dafa184c6d56", + "repo_id": 1234, + "repo": { + "id": 1234, + "owner": { + "id": 349, + "login": "a_nice_user", + "full_name": "Nice User", + "email": "a_nice_user@noreply.example.org", + "avatar_url": "https://gitea.com/avatars/ae32f5573b27f9840942a522d59032b104a2dd15", + "html_url": "https://gitea.com/a_nice_user", + "visibility": "public", + "username": "a_nice_user" + }, + "name": "hello_world_ci", + "full_name": "a_nice_user/hello_world_ci", + "private": false, + "html_url": "https://gitea.com/a_nice_user/hello_world_ci", + "url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci", + "ssh_url": "ssh://git@gitea.com:3344/a_nice_user/hello_world_ci.git", + "clone_url": "https://gitea.com/a_nice_user/hello_world_ci.git", + "default_branch": "main", + "permissions": { + "admin": false, + "push": false, + "pull": true + }, + "has_pull_requests": true, + "object_format_name": "sha1" + } + }, + "head": { + "label": "jony-patch-1", + "ref": "jony-patch-1", + "sha": "07977177c2cd7d46bad37b8472a9d50e7acb9d1f", + "repo_id": 1234, + "repo": { + "id": 1234, + "owner": { + "id": 349, + "login": "a_nice_user", + "full_name": "Nice User", + "email": "a_nice_user@noreply.example.org", + "avatar_url": "https://gitea.com/avatars/ae32f5573b27f9840942a522d59032b104a2dd15", + "html_url": "https://gitea.com/a_nice_user", + "visibility": "public", + "username": "a_nice_user" + }, + "name": "hello_world_ci", + "full_name": "a_nice_user/hello_world_ci", + "private": false, + "html_url": "https://gitea.com/a_nice_user/hello_world_ci", + "url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci", + "ssh_url": "ssh://git@gitea.com:3344/a_nice_user/hello_world_ci.git", + "clone_url": "https://gitea.com/a_nice_user/hello_world_ci.git", + "default_branch": "main", + "permissions": { + "admin": false, + "push": false, + "pull": true + }, + "has_pull_requests": true, + "object_format_name": "sha1" + } + }, + "merge_base": "a40211c506550ebd79633d84e913dafa184c6d56" + }, + "requested_reviewer": null, + "repository": { + "id": 1234, + "owner": { + "id": 349, + "login": "a_nice_user", + "full_name": "Nice User", + "email": "a_nice_user@noreply.example.org", + "avatar_url": "https://gitea.com/avatars/ae32f5573b27f9840942a522d59032b104a2dd15", + "html_url": "https://gitea.com/a_nice_user", + "visibility": "public", + "username": "a_nice_user" + }, + "name": "hello_world_ci", + "full_name": "a_nice_user/hello_world_ci", + "private": false, + "html_url": "https://gitea.com/a_nice_user/hello_world_ci", + "url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci", + "ssh_url": "ssh://git@gitea.com:3344/a_nice_user/hello_world_ci.git", + "clone_url": "https://gitea.com/a_nice_user/hello_world_ci.git", + "default_branch": "main", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "has_pull_requests": true, + "object_format_name": "sha1" + }, + "sender": { + "id": 349, + "login": "a_nice_user", + "full_name": "Nice User", + "email": "a_nice_user@noreply.example.org", + "avatar_url": "https://gitea.com/avatars/ae32f5573b27f9840942a522d59032b104a2dd15", + "html_url": "https://gitea.com/a_nice_user", + "visibility": "public", + "username": "a_nice_user" + }, + "commit_id": "", + "review": null +} diff --git a/server/forge/gitea/fixtures/HookPullRequestAssigneesRemoved.json b/server/forge/gitea/fixtures/HookPullRequestAssigneesRemoved.json new file mode 100644 index 00000000000..637bfdca4fb --- /dev/null +++ b/server/forge/gitea/fixtures/HookPullRequestAssigneesRemoved.json @@ -0,0 +1,167 @@ +{ + "action": "unassigned", + "number": 7, + "pull_request": { + "id": 3779, + "url": "https://gitea.com/a_nice_user/hello_world_ci/pulls/7", + "number": 7, + "user": { + "id": 1, + "login": "jony", + "full_name": "Jony", + "email": "jony@noreply.example.org", + "avatar_url": "https://gitea.com/avatars/81027235e996f5e3ef6257152357b85d94171a2e", + "html_url": "https://gitea.com/jony", + "visibility": "public", + "username": "jony" + }, + "title": "somepull", + "body": "wow aaa new pulll body", + "labels": [ + { + "id": 285, + "name": "bug", + "exclusive": false, + "color": "ee0701", + "description": "Something is not working", + "url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci/labels/285" + } + ], + "milestone": null, + "assignee": null, + "assignees": null, + "requested_reviewers": [ + { + "id": 349, + "login": "a_nice_user", + "full_name": "Nice User", + "email": "a_nice_user@noreply.example.org", + "avatar_url": "https://gitea.com/avatars/ae32f5573b27f9840942a522d59032b104a2dd15", + "html_url": "https://gitea.com/a_nice_user", + "visibility": "public", + "username": "a_nice_user" + } + ], + "state": "open", + "additions": 1, + "deletions": 0, + "changed_files": 1, + "html_url": "https://gitea.com/a_nice_user/hello_world_ci/pulls/7", + "diff_url": "https://gitea.com/a_nice_user/hello_world_ci/pulls/7.diff", + "patch_url": "https://gitea.com/a_nice_user/hello_world_ci/pulls/7.patch", + "mergeable": true, + "base": { + "label": "main", + "ref": "main", + "sha": "a40211c506550ebd79633d84e913dafa184c6d56", + "repo_id": 1234, + "repo": { + "id": 1234, + "owner": { + "id": 349, + "login": "a_nice_user", + "full_name": "Nice User", + "email": "a_nice_user@noreply.example.org", + "avatar_url": "https://gitea.com/avatars/ae32f5573b27f9840942a522d59032b104a2dd15", + "html_url": "https://gitea.com/a_nice_user", + "visibility": "public", + "username": "a_nice_user" + }, + "name": "hello_world_ci", + "full_name": "a_nice_user/hello_world_ci", + "private": false, + "html_url": "https://gitea.com/a_nice_user/hello_world_ci", + "url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci", + "ssh_url": "ssh://git@gitea.com:3344/a_nice_user/hello_world_ci.git", + "clone_url": "https://gitea.com/a_nice_user/hello_world_ci.git", + "default_branch": "main", + "permissions": { + "admin": false, + "push": false, + "pull": true + }, + "has_pull_requests": true, + "avatar_url": "", + "object_format_name": "sha1" + } + }, + "head": { + "label": "jony-patch-1", + "ref": "jony-patch-1", + "sha": "07977177c2cd7d46bad37b8472a9d50e7acb9d1f", + "repo_id": 1234, + "repo": { + "id": 1234, + "owner": { + "id": 349, + "login": "a_nice_user", + "full_name": "Nice User", + "email": "a_nice_user@noreply.example.org", + "avatar_url": "https://gitea.com/avatars/ae32f5573b27f9840942a522d59032b104a2dd15", + "html_url": "https://gitea.com/a_nice_user", + "visibility": "public", + "username": "a_nice_user" + }, + "name": "hello_world_ci", + "full_name": "a_nice_user/hello_world_ci", + "private": false, + "html_url": "https://gitea.com/a_nice_user/hello_world_ci", + "url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci", + "ssh_url": "ssh://git@gitea.com:3344/a_nice_user/hello_world_ci.git", + "clone_url": "https://gitea.com/a_nice_user/hello_world_ci.git", + "default_branch": "main", + "permissions": { + "admin": false, + "push": false, + "pull": true + }, + "has_pull_requests": true, + "avatar_url": "", + "object_format_name": "sha1" + } + }, + "merge_base": "a40211c506550ebd79633d84e913dafa184c6d56" + }, + "requested_reviewer": null, + "repository": { + "id": 1234, + "owner": { + "id": 349, + "login": "a_nice_user", + "full_name": "Nice User", + "email": "a_nice_user@noreply.example.org", + "avatar_url": "https://gitea.com/avatars/ae32f5573b27f9840942a522d59032b104a2dd15", + "html_url": "https://gitea.com/a_nice_user", + "visibility": "public", + "username": "a_nice_user" + }, + "name": "hello_world_ci", + "full_name": "a_nice_user/hello_world_ci", + "private": false, + "html_url": "https://gitea.com/a_nice_user/hello_world_ci", + "url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci", + "ssh_url": "ssh://git@gitea.com:3344/a_nice_user/hello_world_ci.git", + "clone_url": "https://gitea.com/a_nice_user/hello_world_ci.git", + "default_branch": "main", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "has_pull_requests": true, + "avatar_url": "", + "object_format_name": "sha1" + }, + "sender": { + "id": 349, + "login": "a_nice_user", + "full_name": "Nice User", + "email": "a_nice_user@noreply.example.org", + "avatar_url": "https://gitea.com/avatars/ae32f5573b27f9840942a522d59032b104a2dd15", + "html_url": "https://gitea.com/a_nice_user", + "visibility": "public", + "username": "a_nice_user" + }, + "commit_id": "", + "review": null +} diff --git a/server/forge/gitea/fixtures/HookPullRequestChangeBody.json b/server/forge/gitea/fixtures/HookPullRequestChangeBody.json new file mode 100644 index 00000000000..30aedafd942 --- /dev/null +++ b/server/forge/gitea/fixtures/HookPullRequestChangeBody.json @@ -0,0 +1,158 @@ +{ + "action": "edited", + "number": 7, + "changes": { + "body": { + "from": "" + } + }, + "pull_request": { + "id": 3779, + "url": "https://gitea.com/a_nice_user/hello_world_ci/pulls/7", + "number": 7, + "user": { + "id": 21, + "login": "jony", + "full_name": "Jony", + "email": "jony@noreply.example.org", + "avatar_url": "https://gitea.com/avatars/81027235e996f5e3ef6257152357b85d94171a2e", + "html_url": "https://gitea.com/jony", + "created": "2018-01-25T14:38:19+01:00", + "visibility": "public", + "username": "jony" + }, + "title": "somepull", + "body": "wow aaa new pulll body", + "labels": [], + "milestone": null, + "assignees": null, + "requested_reviewers": null, + "state": "open", + "additions": 1, + "deletions": 0, + "changed_files": 1, + "html_url": "https://gitea.com/a_nice_user/hello_world_ci/pulls/7", + "diff_url": "https://gitea.com/a_nice_user/hello_world_ci/pulls/7.diff", + "patch_url": "https://gitea.com/a_nice_user/hello_world_ci/pulls/7.patch", + "base": { + "label": "main", + "ref": "main", + "sha": "a40211c506550ebd79633d84e913dafa184c6d56", + "repo_id": 1234, + "repo": { + "id": 1234, + "owner": { + "id": 8765, + "login": "a_nice_user", + "full_name": "Nice User", + "email": "a_nice_user@me.mail", + "avatar_url": "https://gitea.com/avatars/ae32f5573b27f9840942a522d59032b104a2dd15", + "html_url": "https://gitea.com/a_nice_user", + "created": "2023-05-23T15:17:35+02:00", + "visibility": "public", + "username": "a_nice_user" + }, + "name": "hello_world_ci", + "full_name": "a_nice_user/hello_world_ci", + "private": false, + "languages_url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci/languages", + "html_url": "https://gitea.com/a_nice_user/hello_world_ci", + "url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci", + "link": "", + "ssh_url": "ssh://git@gitea.com:3344/a_nice_user/hello_world_ci.git", + "clone_url": "https://gitea.com/a_nice_user/hello_world_ci.git", + "default_branch": "main", + "permissions": { + "admin": false, + "push": false, + "pull": true + }, + "object_format_name": "sha1" + } + }, + "head": { + "label": "jony-patch-1", + "ref": "jony-patch-1", + "sha": "07977177c2cd7d46bad37b8472a9d50e7acb9d1f", + "repo_id": 1234, + "repo": { + "id": 1234, + "owner": { + "id": 8765, + "login": "a_nice_user", + "full_name": "Nice User", + "email": "a_nice_user@me.mail", + "avatar_url": "https://gitea.com/avatars/ae32f5573b27f9840942a522d59032b104a2dd15", + "html_url": "https://gitea.com/a_nice_user", + "created": "2023-05-23T15:17:35+02:00", + "visibility": "public", + "username": "a_nice_user" + }, + "name": "hello_world_ci", + "full_name": "a_nice_user/hello_world_ci", + "private": false, + "languages_url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci/languages", + "html_url": "https://gitea.com/a_nice_user/hello_world_ci", + "url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci", + "link": "", + "ssh_url": "ssh://git@gitea.com:3344/a_nice_user/hello_world_ci.git", + "clone_url": "https://gitea.com/a_nice_user/hello_world_ci.git", + "default_branch": "main", + "permissions": { + "admin": false, + "push": false, + "pull": true + }, + "object_format_name": "sha1" + } + }, + "merge_base": "a40211c506550ebd79633d84e913dafa184c6d56", + "due_date": null, + "closed_at": null, + "pin_order": 0 + }, + "requested_reviewer": null, + "repository": { + "id": 1234, + "owner": { + "id": 8765, + "login": "a_nice_user", + "full_name": "Nice User", + "email": "a_nice_user@me.mail", + "avatar_url": "https://gitea.com/avatars/ae32f5573b27f9840942a522d59032b104a2dd15", + "html_url": "https://gitea.com/a_nice_user", + "created": "2023-05-23T15:17:35+02:00", + "visibility": "public", + "username": "a_nice_user" + }, + "name": "hello_world_ci", + "full_name": "a_nice_user/hello_world_ci", + "private": false, + "has_pull_requests": true, + "languages_url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci/languages", + "html_url": "https://gitea.com/a_nice_user/hello_world_ci", + "url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci", + "link": "", + "ssh_url": "ssh://git@gitea.com:3344/a_nice_user/hello_world_ci.git", + "clone_url": "https://gitea.com/a_nice_user/hello_world_ci.git", + "default_branch": "main", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "object_format_name": "sha1" + }, + "sender": { + "id": 8765, + "login": "a_nice_user", + "full_name": "Nice User", + "email": "a_nice_user@noreply.example.org", + "avatar_url": "https://gitea.com/avatars/ae32f5573b27f9840942a522d59032b104a2dd15", + "html_url": "https://gitea.com/a_nice_user", + "created": "2023-05-23T15:17:35+02:00", + "visibility": "public", + "username": "a_nice_user" + }, + "review": null +} diff --git a/server/forge/gitea/fixtures/HookPullRequestChangeLabel.json b/server/forge/gitea/fixtures/HookPullRequestChangeLabel.json new file mode 100644 index 00000000000..9b1deb49984 --- /dev/null +++ b/server/forge/gitea/fixtures/HookPullRequestChangeLabel.json @@ -0,0 +1,175 @@ +{ + "action": "label_updated", + "number": 7, + "pull_request": { + "id": 3779, + "url": "https://gitea.com/a_nice_user/hello_world_ci/pulls/7", + "number": 7, + "user": { + "id": 21, + "login": "jony", + "full_name": "Jony", + "email": "jony@noreply.example.org", + "avatar_url": "https://gitea.com/avatars/81027235e996f5e3ef6257152357b85d94171a2e", + "html_url": "https://gitea.com/jony", + "created": "2018-01-25T14:38:19+01:00", + "visibility": "public", + "username": "jony" + }, + "title": "somepull", + "body": "wow aaa new pulll body", + "labels": [ + { + "id": 285, + "name": "bug", + "exclusive": false, + "is_archived": false, + "color": "ee0701", + "description": "Something is not working", + "url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci/labels/285" + } + ], + "milestone": null, + "assignees": null, + "requested_reviewers": [ + { + "id": 8765, + "login": "a_nice_user", + "full_name": "Nice User", + "email": "a_nice_user@noreply.example.org", + "avatar_url": "https://gitea.com/avatars/ae32f5573b27f9840942a522d59032b104a2dd15", + "html_url": "https://gitea.com/a_nice_user", + "created": "2023-05-23T15:17:35+02:00", + "visibility": "public", + "username": "a_nice_user" + } + ], + "state": "open", + "additions": 1, + "deletions": 0, + "changed_files": 1, + "html_url": "https://gitea.com/a_nice_user/hello_world_ci/pulls/7", + "diff_url": "https://gitea.com/a_nice_user/hello_world_ci/pulls/7.diff", + "patch_url": "https://gitea.com/a_nice_user/hello_world_ci/pulls/7.patch", + "base": { + "label": "main", + "ref": "main", + "sha": "a40211c506550ebd79633d84e913dafa184c6d56", + "repo_id": 1234, + "repo": { + "id": 1234, + "owner": { + "id": 8765, + "login": "a_nice_user", + "full_name": "Nice User", + "email": "a_nice_user@me.mail", + "avatar_url": "https://gitea.com/avatars/ae32f5573b27f9840942a522d59032b104a2dd15", + "html_url": "https://gitea.com/a_nice_user", + "created": "2023-05-23T15:17:35+02:00", + "visibility": "public", + "username": "a_nice_user" + }, + "name": "hello_world_ci", + "full_name": "a_nice_user/hello_world_ci", + "private": false, + "languages_url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci/languages", + "html_url": "https://gitea.com/a_nice_user/hello_world_ci", + "url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci", + "link": "", + "ssh_url": "ssh://git@gitea.com:3344/a_nice_user/hello_world_ci.git", + "clone_url": "https://gitea.com/a_nice_user/hello_world_ci.git", + "default_branch": "main", + "permissions": { + "admin": false, + "push": false, + "pull": true + }, + "object_format_name": "sha1" + } + }, + "head": { + "label": "jony-patch-1", + "ref": "jony-patch-1", + "sha": "07977177c2cd7d46bad37b8472a9d50e7acb9d1f", + "repo_id": 1234, + "repo": { + "id": 1234, + "owner": { + "id": 8765, + "login": "a_nice_user", + "full_name": "Nice User", + "email": "a_nice_user@me.mail", + "avatar_url": "https://gitea.com/avatars/ae32f5573b27f9840942a522d59032b104a2dd15", + "html_url": "https://gitea.com/a_nice_user", + "created": "2023-05-23T15:17:35+02:00", + "visibility": "public", + "username": "a_nice_user" + }, + "name": "hello_world_ci", + "full_name": "a_nice_user/hello_world_ci", + "private": false, + "languages_url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci/languages", + "html_url": "https://gitea.com/a_nice_user/hello_world_ci", + "url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci", + "link": "", + "ssh_url": "ssh://git@gitea.com:3344/a_nice_user/hello_world_ci.git", + "clone_url": "https://gitea.com/a_nice_user/hello_world_ci.git", + "default_branch": "main", + "permissions": { + "admin": false, + "push": false, + "pull": true + }, + "object_format_name": "sha1" + } + }, + "merge_base": "a40211c506550ebd79633d84e913dafa184c6d56", + "due_date": null, + "closed_at": null, + "pin_order": 0 + }, + "requested_reviewer": null, + "repository": { + "id": 1234, + "owner": { + "id": 8765, + "login": "a_nice_user", + "full_name": "Nice User", + "email": "a_nice_user@me.mail", + "avatar_url": "https://gitea.com/avatars/ae32f5573b27f9840942a522d59032b104a2dd15", + "html_url": "https://gitea.com/a_nice_user", + "created": "2023-05-23T15:17:35+02:00", + "visibility": "public", + "username": "a_nice_user" + }, + "name": "hello_world_ci", + "full_name": "a_nice_user/hello_world_ci", + "private": false, + "has_pull_requests": true, + "languages_url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci/languages", + "html_url": "https://gitea.com/a_nice_user/hello_world_ci", + "url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci", + "link": "", + "ssh_url": "ssh://git@gitea.com:3344/a_nice_user/hello_world_ci.git", + "clone_url": "https://gitea.com/a_nice_user/hello_world_ci.git", + "default_branch": "main", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "object_format_name": "sha1" + }, + "sender": { + "id": 8765, + "login": "a_nice_user", + "full_name": "Nice User", + "email": "a_nice_user@noreply.example.org", + "avatar_url": "https://gitea.com/avatars/ae32f5573b27f9840942a522d59032b104a2dd15", + "html_url": "https://gitea.com/a_nice_user", + "created": "2023-05-23T15:17:35+02:00", + "visibility": "public", + "username": "a_nice_user" + }, + "review": null +} diff --git a/server/forge/gitea/fixtures/HookPullRequestChangeMile.json b/server/forge/gitea/fixtures/HookPullRequestChangeMile.json new file mode 100644 index 00000000000..45ce989537e --- /dev/null +++ b/server/forge/gitea/fixtures/HookPullRequestChangeMile.json @@ -0,0 +1,192 @@ +{ + "action": "milestoned", + "number": 7, + "pull_request": { + "id": 3779, + "url": "https://gitea.com/a_nice_user/hello_world_ci/pulls/7", + "number": 7, + "user": { + "id": 21, + "login": "jony", + "full_name": "Jony", + "email": "jony@noreply.example.org", + "avatar_url": "https://gitea.com/avatars/81027235e996f5e3ef6257152357b85d94171a2e", + "html_url": "https://gitea.com/jony", + "created": "2018-01-25T14:38:19+01:00", + "visibility": "public", + "username": "jony" + }, + "title": "somepull", + "body": "wow aaa new pulll body", + "labels": [ + { + "id": 285, + "name": "bug", + "exclusive": false, + "is_archived": false, + "color": "ee0701", + "description": "Something is not working", + "url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci/labels/285" + }, + { + "id": 297, + "name": "help wanted", + "exclusive": false, + "is_archived": false, + "color": "128a0c", + "description": "Need some help", + "url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci/labels/297" + } + ], + "milestone": { + "id": 273, + "title": "closed mile", + "state": "closed", + "open_issues": 1, + "closed_issues": 0, + "closed_at": "2025-05-28T03:13:46+02:00", + "due_on": null + }, + "assignees": null, + "requested_reviewers": [ + { + "id": 8765, + "login": "a_nice_user", + "full_name": "Nice User", + "email": "a_nice_user@noreply.example.org", + "avatar_url": "https://gitea.com/avatars/ae32f5573b27f9840942a522d59032b104a2dd15", + "html_url": "https://gitea.com/a_nice_user", + "created": "2023-05-23T15:17:35+02:00", + "visibility": "public", + "username": "a_nice_user" + } + ], + "state": "open", + "additions": 1, + "deletions": 0, + "changed_files": 1, + "html_url": "https://gitea.com/a_nice_user/hello_world_ci/pulls/7", + "diff_url": "https://gitea.com/a_nice_user/hello_world_ci/pulls/7.diff", + "patch_url": "https://gitea.com/a_nice_user/hello_world_ci/pulls/7.patch", + "base": { + "label": "main", + "ref": "main", + "sha": "a40211c506550ebd79633d84e913dafa184c6d56", + "repo_id": 1234, + "repo": { + "id": 1234, + "owner": { + "id": 8765, + "login": "a_nice_user", + "full_name": "Nice User", + "email": "a_nice_user@me.mail", + "avatar_url": "https://gitea.com/avatars/ae32f5573b27f9840942a522d59032b104a2dd15", + "html_url": "https://gitea.com/a_nice_user", + "created": "2023-05-23T15:17:35+02:00", + "visibility": "public", + "username": "a_nice_user" + }, + "name": "hello_world_ci", + "full_name": "a_nice_user/hello_world_ci", + "private": false, + "languages_url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci/languages", + "html_url": "https://gitea.com/a_nice_user/hello_world_ci", + "url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci", + "link": "", + "ssh_url": "ssh://git@gitea.com:3344/a_nice_user/hello_world_ci.git", + "clone_url": "https://gitea.com/a_nice_user/hello_world_ci.git", + "default_branch": "main", + "permissions": { + "admin": false, + "push": false, + "pull": true + }, + "object_format_name": "sha1" + } + }, + "head": { + "label": "jony-patch-1", + "ref": "jony-patch-1", + "sha": "07977177c2cd7d46bad37b8472a9d50e7acb9d1f", + "repo_id": 1234, + "repo": { + "id": 1234, + "owner": { + "id": 8765, + "login": "a_nice_user", + "full_name": "Nice User", + "email": "a_nice_user@me.mail", + "avatar_url": "https://gitea.com/avatars/ae32f5573b27f9840942a522d59032b104a2dd15", + "html_url": "https://gitea.com/a_nice_user", + "created": "2023-05-23T15:17:35+02:00", + "visibility": "public", + "username": "a_nice_user" + }, + "name": "hello_world_ci", + "full_name": "a_nice_user/hello_world_ci", + "private": false, + "languages_url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci/languages", + "html_url": "https://gitea.com/a_nice_user/hello_world_ci", + "url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci", + "link": "", + "ssh_url": "ssh://git@gitea.com:3344/a_nice_user/hello_world_ci.git", + "clone_url": "https://gitea.com/a_nice_user/hello_world_ci.git", + "default_branch": "main", + "permissions": { + "admin": false, + "push": false, + "pull": true + }, + "object_format_name": "sha1" + } + }, + "merge_base": "a40211c506550ebd79633d84e913dafa184c6d56", + "due_date": null, + "closed_at": null, + "pin_order": 0 + }, + "requested_reviewer": null, + "repository": { + "id": 1234, + "owner": { + "id": 8765, + "login": "a_nice_user", + "full_name": "Nice User", + "email": "a_nice_user@me.mail", + "avatar_url": "https://gitea.com/avatars/ae32f5573b27f9840942a522d59032b104a2dd15", + "html_url": "https://gitea.com/a_nice_user", + "created": "2023-05-23T15:17:35+02:00", + "visibility": "public", + "username": "a_nice_user" + }, + "name": "hello_world_ci", + "full_name": "a_nice_user/hello_world_ci", + "private": false, + "has_pull_requests": true, + "languages_url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci/languages", + "html_url": "https://gitea.com/a_nice_user/hello_world_ci", + "url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci", + "link": "", + "ssh_url": "ssh://git@gitea.com:3344/a_nice_user/hello_world_ci.git", + "clone_url": "https://gitea.com/a_nice_user/hello_world_ci.git", + "default_branch": "main", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "object_format_name": "sha1" + }, + "sender": { + "id": 8765, + "login": "a_nice_user", + "full_name": "Nice User", + "email": "a_nice_user@noreply.example.org", + "avatar_url": "https://gitea.com/avatars/ae32f5573b27f9840942a522d59032b104a2dd15", + "html_url": "https://gitea.com/a_nice_user", + "created": "2023-05-23T15:17:35+02:00", + "visibility": "public", + "username": "a_nice_user" + }, + "review": null +} diff --git a/server/forge/gitea/fixtures/HookPullRequestChangeTitle.json b/server/forge/gitea/fixtures/HookPullRequestChangeTitle.json new file mode 100644 index 00000000000..c591c3e60c1 --- /dev/null +++ b/server/forge/gitea/fixtures/HookPullRequestChangeTitle.json @@ -0,0 +1,159 @@ +{ + "action": "edited", + "number": 7, + "changes": { + "title": { + "from": "Update .woodpecker.yml" + } + }, + "pull_request": { + "id": 3779, + "url": "https://gitea.com/a_nice_user/hello_world_ci/pulls/7", + "number": 7, + "user": { + "id": 21, + "login": "jony", + "full_name": "Jony", + "email": "jony@noreply.example.org", + "avatar_url": "https://gitea.com/avatars/81027235e996f5e3ef6257152357b85d94171a2e", + "html_url": "https://gitea.com/jony", + "last_login": "0001-01-01T00:00:00Z", + "created": "2018-01-25T14:38:19+01:00", + "visibility": "public", + "username": "jony" + }, + "title": "Edit pull title :D", + "body": "", + "labels": [], + "milestone": null, + "assignees": null, + "requested_reviewers": null, + "state": "open", + "additions": 1, + "deletions": 0, + "changed_files": 1, + "html_url": "https://gitea.com/a_nice_user/hello_world_ci/pulls/7", + "diff_url": "https://gitea.com/a_nice_user/hello_world_ci/pulls/7.diff", + "patch_url": "https://gitea.com/a_nice_user/hello_world_ci/pulls/7.patch", + "base": { + "label": "main", + "ref": "main", + "sha": "a40211c506550ebd79633d84e913dafa184c6d56", + "repo_id": 1234, + "repo": { + "id": 1234, + "owner": { + "id": 8765, + "login": "a_nice_user", + "full_name": "Nice User", + "email": "a_nice_user@me.mail", + "avatar_url": "https://gitea.com/avatars/ae32f5573b27f9840942a522d59032b104a2dd15", + "html_url": "https://gitea.com/a_nice_user", + "created": "2023-05-23T15:17:35+02:00", + "visibility": "public", + "username": "a_nice_user" + }, + "name": "hello_world_ci", + "full_name": "a_nice_user/hello_world_ci", + "private": false, + "languages_url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci/languages", + "html_url": "https://gitea.com/a_nice_user/hello_world_ci", + "url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci", + "link": "", + "ssh_url": "ssh://git@gitea.com:3344/a_nice_user/hello_world_ci.git", + "clone_url": "https://gitea.com/a_nice_user/hello_world_ci.git", + "default_branch": "main", + "permissions": { + "admin": false, + "push": false, + "pull": true + }, + "object_format_name": "sha1" + } + }, + "head": { + "label": "jony-patch-1", + "ref": "jony-patch-1", + "sha": "07977177c2cd7d46bad37b8472a9d50e7acb9d1f", + "repo_id": 1234, + "repo": { + "id": 1234, + "owner": { + "id": 8765, + "login": "a_nice_user", + "full_name": "Nice User", + "email": "a_nice_user@me.mail", + "avatar_url": "https://gitea.com/avatars/ae32f5573b27f9840942a522d59032b104a2dd15", + "html_url": "https://gitea.com/a_nice_user", + "created": "2023-05-23T15:17:35+02:00", + "visibility": "public", + "username": "a_nice_user" + }, + "name": "hello_world_ci", + "full_name": "a_nice_user/hello_world_ci", + "private": false, + "languages_url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci/languages", + "html_url": "https://gitea.com/a_nice_user/hello_world_ci", + "url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci", + "link": "", + "ssh_url": "ssh://git@gitea.com:3344/a_nice_user/hello_world_ci.git", + "clone_url": "https://gitea.com/a_nice_user/hello_world_ci.git", + "default_branch": "main", + "permissions": { + "admin": false, + "push": false, + "pull": true + }, + "object_format_name": "sha1" + } + }, + "merge_base": "a40211c506550ebd79633d84e913dafa184c6d56", + "due_date": null, + "closed_at": null, + "pin_order": 0 + }, + "requested_reviewer": null, + "repository": { + "id": 1234, + "owner": { + "id": 8765, + "login": "a_nice_user", + "full_name": "Nice User", + "email": "a_nice_user@me.mail", + "avatar_url": "https://gitea.com/avatars/ae32f5573b27f9840942a522d59032b104a2dd15", + "html_url": "https://gitea.com/a_nice_user", + "created": "2023-05-23T15:17:35+02:00", + "visibility": "public", + "username": "a_nice_user" + }, + "name": "hello_world_ci", + "full_name": "a_nice_user/hello_world_ci", + "private": false, + "has_pull_requests": true, + "languages_url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci/languages", + "html_url": "https://gitea.com/a_nice_user/hello_world_ci", + "url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci", + "link": "", + "ssh_url": "ssh://git@gitea.com:3344/a_nice_user/hello_world_ci.git", + "clone_url": "https://gitea.com/a_nice_user/hello_world_ci.git", + "default_branch": "main", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "object_format_name": "sha1" + }, + "sender": { + "id": 8765, + "login": "a_nice_user", + "full_name": "Nice User", + "email": "a_nice_user@noreply.example.org", + "avatar_url": "https://gitea.com/avatars/ae32f5573b27f9840942a522d59032b104a2dd15", + "html_url": "https://gitea.com/a_nice_user", + "created": "2023-05-23T15:17:35+02:00", + "visibility": "public", + "username": "a_nice_user" + }, + "review": null +} diff --git a/server/forge/gitea/fixtures/HookPullRequestRemoveLabel.json b/server/forge/gitea/fixtures/HookPullRequestRemoveLabel.json new file mode 100644 index 00000000000..1e3d2cec296 --- /dev/null +++ b/server/forge/gitea/fixtures/HookPullRequestRemoveLabel.json @@ -0,0 +1,184 @@ +{ + "action": "label_cleared", + "number": 7, + "pull_request": { + "id": 3779, + "url": "https://gitea.com/a_nice_user/hello_world_ci/pulls/7", + "number": 7, + "user": { + "id": 21, + "login": "jony", + "full_name": "Jony", + "email": "jony@noreply.example.org", + "avatar_url": "https://gitea.com/avatars/81027235e996f5e3ef6257152357b85d94171a2e", + "html_url": "https://gitea.com/jony", + "created": "2018-01-25T14:38:19+01:00", + "visibility": "public", + "username": "jony" + }, + "title": "somepull", + "body": "wow aaa new pulll body", + "labels": [ + { + "id": 285, + "name": "bug", + "exclusive": false, + "is_archived": false, + "color": "ee0701", + "description": "Something is not working", + "url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci/labels/285" + }, + { + "id": 297, + "name": "help wanted", + "exclusive": false, + "is_archived": false, + "color": "128a0c", + "description": "Need some help", + "url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci/labels/297" + } + ], + "milestone": null, + "assignees": null, + "requested_reviewers": [ + { + "id": 8765, + "login": "a_nice_user", + "full_name": "Nice User", + "email": "a_nice_user@noreply.example.org", + "avatar_url": "https://gitea.com/avatars/ae32f5573b27f9840942a522d59032b104a2dd15", + "html_url": "https://gitea.com/a_nice_user", + "created": "2023-05-23T15:17:35+02:00", + "visibility": "public", + "username": "a_nice_user" + } + ], + "state": "open", + "additions": 1, + "deletions": 0, + "changed_files": 1, + "html_url": "https://gitea.com/a_nice_user/hello_world_ci/pulls/7", + "diff_url": "https://gitea.com/a_nice_user/hello_world_ci/pulls/7.diff", + "patch_url": "https://gitea.com/a_nice_user/hello_world_ci/pulls/7.patch", + "base": { + "label": "main", + "ref": "main", + "sha": "a40211c506550ebd79633d84e913dafa184c6d56", + "repo_id": 1234, + "repo": { + "id": 1234, + "owner": { + "id": 8765, + "login": "a_nice_user", + "full_name": "Nice User", + "email": "a_nice_user@me.mail", + "avatar_url": "https://gitea.com/avatars/ae32f5573b27f9840942a522d59032b104a2dd15", + "html_url": "https://gitea.com/a_nice_user", + "created": "2023-05-23T15:17:35+02:00", + "visibility": "public", + "username": "a_nice_user" + }, + "name": "hello_world_ci", + "full_name": "a_nice_user/hello_world_ci", + "private": false, + "languages_url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci/languages", + "html_url": "https://gitea.com/a_nice_user/hello_world_ci", + "url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci", + "link": "", + "ssh_url": "ssh://git@gitea.com:3344/a_nice_user/hello_world_ci.git", + "clone_url": "https://gitea.com/a_nice_user/hello_world_ci.git", + "default_branch": "main", + "permissions": { + "admin": false, + "push": false, + "pull": true + }, + "object_format_name": "sha1" + } + }, + "head": { + "label": "jony-patch-1", + "ref": "jony-patch-1", + "sha": "07977177c2cd7d46bad37b8472a9d50e7acb9d1f", + "repo_id": 1234, + "repo": { + "id": 1234, + "owner": { + "id": 8765, + "login": "a_nice_user", + "full_name": "Nice User", + "email": "a_nice_user@me.mail", + "avatar_url": "https://gitea.com/avatars/ae32f5573b27f9840942a522d59032b104a2dd15", + "html_url": "https://gitea.com/a_nice_user", + "created": "2023-05-23T15:17:35+02:00", + "visibility": "public", + "username": "a_nice_user" + }, + "name": "hello_world_ci", + "full_name": "a_nice_user/hello_world_ci", + "private": false, + "languages_url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci/languages", + "html_url": "https://gitea.com/a_nice_user/hello_world_ci", + "url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci", + "link": "", + "ssh_url": "ssh://git@gitea.com:3344/a_nice_user/hello_world_ci.git", + "clone_url": "https://gitea.com/a_nice_user/hello_world_ci.git", + "default_branch": "main", + "permissions": { + "admin": false, + "push": false, + "pull": true + }, + "object_format_name": "sha1" + } + }, + "merge_base": "a40211c506550ebd79633d84e913dafa184c6d56", + "due_date": null, + "closed_at": null, + "pin_order": 0 + }, + "requested_reviewer": null, + "repository": { + "id": 1234, + "owner": { + "id": 8765, + "login": "a_nice_user", + "full_name": "Nice User", + "email": "a_nice_user@me.mail", + "avatar_url": "https://gitea.com/avatars/ae32f5573b27f9840942a522d59032b104a2dd15", + "html_url": "https://gitea.com/a_nice_user", + "created": "2023-05-23T15:17:35+02:00", + "visibility": "public", + "username": "a_nice_user" + }, + "name": "hello_world_ci", + "full_name": "a_nice_user/hello_world_ci", + "private": false, + "has_pull_requests": true, + "languages_url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci/languages", + "html_url": "https://gitea.com/a_nice_user/hello_world_ci", + "url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci", + "link": "", + "ssh_url": "ssh://git@gitea.com:3344/a_nice_user/hello_world_ci.git", + "clone_url": "https://gitea.com/a_nice_user/hello_world_ci.git", + "default_branch": "main", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "object_format_name": "sha1" + }, + "sender": { + "id": 8765, + "login": "a_nice_user", + "full_name": "Nice User", + "email": "a_nice_user@noreply.example.org", + "avatar_url": "https://gitea.com/avatars/ae32f5573b27f9840942a522d59032b104a2dd15", + "html_url": "https://gitea.com/a_nice_user", + "created": "2023-05-23T15:17:35+02:00", + "visibility": "public", + "username": "a_nice_user" + }, + "review": null +} diff --git a/server/forge/gitea/fixtures/HookPullRequestRemoveMile.json b/server/forge/gitea/fixtures/HookPullRequestRemoveMile.json new file mode 100644 index 00000000000..d3f94304172 --- /dev/null +++ b/server/forge/gitea/fixtures/HookPullRequestRemoveMile.json @@ -0,0 +1,192 @@ +{ + "action": "demilestoned", + "number": 7, + "pull_request": { + "id": 3779, + "url": "https://gitea.com/a_nice_user/hello_world_ci/pulls/7", + "number": 7, + "user": { + "id": 21, + "login": "jony", + "full_name": "Jony", + "email": "jony@noreply.example.org", + "avatar_url": "https://gitea.com/avatars/81027235e996f5e3ef6257152357b85d94171a2e", + "html_url": "https://gitea.com/jony", + "created": "2018-01-25T14:38:19+01:00", + "visibility": "public", + "username": "jony" + }, + "title": "somepull", + "body": "wow aaa new pulll body", + "labels": [ + { + "id": 285, + "name": "bug", + "exclusive": false, + "is_archived": false, + "color": "ee0701", + "description": "Something is not working", + "url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci/labels/285" + }, + { + "id": 297, + "name": "help wanted", + "exclusive": false, + "is_archived": false, + "color": "128a0c", + "description": "Need some help", + "url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci/labels/297" + } + ], + "milestone": { + "id": 273, + "title": "closed mile", + "state": "closed", + "open_issues": 1, + "closed_issues": 0, + "closed_at": "2025-05-28T03:13:46+02:00", + "due_on": null + }, + "assignees": null, + "requested_reviewers": [ + { + "id": 8765, + "login": "a_nice_user", + "full_name": "Nice User", + "email": "a_nice_user@noreply.example.org", + "avatar_url": "https://gitea.com/avatars/ae32f5573b27f9840942a522d59032b104a2dd15", + "html_url": "https://gitea.com/a_nice_user", + "created": "2023-05-23T15:17:35+02:00", + "visibility": "public", + "username": "a_nice_user" + } + ], + "state": "open", + "additions": 1, + "deletions": 0, + "changed_files": 1, + "html_url": "https://gitea.com/a_nice_user/hello_world_ci/pulls/7", + "diff_url": "https://gitea.com/a_nice_user/hello_world_ci/pulls/7.diff", + "patch_url": "https://gitea.com/a_nice_user/hello_world_ci/pulls/7.patch", + "base": { + "label": "main", + "ref": "main", + "sha": "a40211c506550ebd79633d84e913dafa184c6d56", + "repo_id": 1234, + "repo": { + "id": 1234, + "owner": { + "id": 8765, + "login": "a_nice_user", + "full_name": "Nice User", + "email": "a_nice_user@me.mail", + "avatar_url": "https://gitea.com/avatars/ae32f5573b27f9840942a522d59032b104a2dd15", + "html_url": "https://gitea.com/a_nice_user", + "created": "2023-05-23T15:17:35+02:00", + "visibility": "public", + "username": "a_nice_user" + }, + "name": "hello_world_ci", + "full_name": "a_nice_user/hello_world_ci", + "private": false, + "languages_url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci/languages", + "html_url": "https://gitea.com/a_nice_user/hello_world_ci", + "url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci", + "link": "", + "ssh_url": "ssh://git@gitea.com:3344/a_nice_user/hello_world_ci.git", + "clone_url": "https://gitea.com/a_nice_user/hello_world_ci.git", + "default_branch": "main", + "permissions": { + "admin": false, + "push": false, + "pull": true + }, + "object_format_name": "sha1" + } + }, + "head": { + "label": "jony-patch-1", + "ref": "jony-patch-1", + "sha": "07977177c2cd7d46bad37b8472a9d50e7acb9d1f", + "repo_id": 1234, + "repo": { + "id": 1234, + "owner": { + "id": 8765, + "login": "a_nice_user", + "full_name": "Nice User", + "email": "a_nice_user@me.mail", + "avatar_url": "https://gitea.com/avatars/ae32f5573b27f9840942a522d59032b104a2dd15", + "html_url": "https://gitea.com/a_nice_user", + "created": "2023-05-23T15:17:35+02:00", + "visibility": "public", + "username": "a_nice_user" + }, + "name": "hello_world_ci", + "full_name": "a_nice_user/hello_world_ci", + "private": false, + "languages_url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci/languages", + "html_url": "https://gitea.com/a_nice_user/hello_world_ci", + "url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci", + "link": "", + "ssh_url": "ssh://git@gitea.com:3344/a_nice_user/hello_world_ci.git", + "clone_url": "https://gitea.com/a_nice_user/hello_world_ci.git", + "default_branch": "main", + "permissions": { + "admin": false, + "push": false, + "pull": true + }, + "object_format_name": "sha1" + } + }, + "merge_base": "a40211c506550ebd79633d84e913dafa184c6d56", + "due_date": null, + "closed_at": null, + "pin_order": 0 + }, + "requested_reviewer": null, + "repository": { + "id": 1234, + "owner": { + "id": 8765, + "login": "a_nice_user", + "full_name": "Nice User", + "email": "a_nice_user@me.mail", + "avatar_url": "https://gitea.com/avatars/ae32f5573b27f9840942a522d59032b104a2dd15", + "html_url": "https://gitea.com/a_nice_user", + "created": "2023-05-23T15:17:35+02:00", + "visibility": "public", + "username": "a_nice_user" + }, + "name": "hello_world_ci", + "full_name": "a_nice_user/hello_world_ci", + "private": false, + "has_pull_requests": true, + "languages_url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci/languages", + "html_url": "https://gitea.com/a_nice_user/hello_world_ci", + "url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci", + "link": "", + "ssh_url": "ssh://git@gitea.com:3344/a_nice_user/hello_world_ci.git", + "clone_url": "https://gitea.com/a_nice_user/hello_world_ci.git", + "default_branch": "main", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "object_format_name": "sha1" + }, + "sender": { + "id": 8765, + "login": "a_nice_user", + "full_name": "Nice User", + "email": "a_nice_user@noreply.example.org", + "avatar_url": "https://gitea.com/avatars/ae32f5573b27f9840942a522d59032b104a2dd15", + "html_url": "https://gitea.com/a_nice_user", + "created": "2023-05-23T15:17:35+02:00", + "visibility": "public", + "username": "a_nice_user" + }, + "review": null +} diff --git a/server/forge/gitea/fixtures/HookPullRequestReviewAck.json b/server/forge/gitea/fixtures/HookPullRequestReviewAck.json new file mode 100644 index 00000000000..8e3899e2bd0 --- /dev/null +++ b/server/forge/gitea/fixtures/HookPullRequestReviewAck.json @@ -0,0 +1,158 @@ +{ + "action": "reviewed", + "number": 7, + "pull_request": { + "id": 3779, + "url": "https://gitea.com/a_nice_user/hello_world_ci/pulls/7", + "number": 7, + "user": { + "id": 1, + "login": "jony", + "full_name": "Jony", + "email": "jony@noreply.example.org", + "avatar_url": "https://gitea.com/avatars/81027235e996f5e3ef6257152357b85d94171a2e", + "html_url": "https://gitea.com/jony", + "description": "", + "visibility": "public", + "username": "jony" + }, + "title": "somepull", + "body": "wow aaa new pulll body", + "labels": [], + "milestone": null, + "assignees": null, + "requested_reviewers": [ + { + "id": 349, + "login": "a_nice_user", + "full_name": "Nice User", + "email": "a_nice_user@noreply.example.org", + "avatar_url": "https://gitea.com/avatars/ae32f5573b27f9840942a522d59032b104a2dd15", + "html_url": "https://gitea.com/a_nice_user", + "visibility": "public", + "username": "a_nice_user" + } + ], + "state": "open", + "comments": 0, + "review_comments": 1, + "additions": 1, + "deletions": 0, + "changed_files": 1, + "html_url": "https://gitea.com/a_nice_user/hello_world_ci/pulls/7", + "diff_url": "https://gitea.com/a_nice_user/hello_world_ci/pulls/7.diff", + "patch_url": "https://gitea.com/a_nice_user/hello_world_ci/pulls/7.patch", + "base": { + "label": "main", + "ref": "main", + "sha": "a40211c506550ebd79633d84e913dafa184c6d56", + "repo_id": 1234, + "repo": { + "id": 1234, + "owner": { + "id": 349, + "login": "a_nice_user", + "full_name": "Nice User", + "email": "a_nice_user@me.mail", + "avatar_url": "https://gitea.com/avatars/ae32f5573b27f9840942a522d59032b104a2dd15", + "html_url": "https://gitea.com/a_nice_user", + "visibility": "public", + "username": "a_nice_user" + }, + "name": "hello_world_ci", + "full_name": "a_nice_user/hello_world_ci", + "description": "", + "html_url": "https://gitea.com/a_nice_user/hello_world_ci", + "url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci", + "ssh_url": "ssh://git@gitea.com:3344/a_nice_user/hello_world_ci.git", + "clone_url": "https://gitea.com/a_nice_user/hello_world_ci.git", + "default_branch": "main", + "permissions": { + "admin": false, + "push": false, + "pull": true + }, + "has_pull_requests": true, + "object_format_name": "sha1" + } + }, + "head": { + "label": "jony-patch-1", + "ref": "jony-patch-1", + "sha": "07977177c2cd7d46bad37b8472a9d50e7acb9d1f", + "repo_id": 1234, + "repo": { + "id": 1234, + "owner": { + "id": 349, + "login": "a_nice_user", + "full_name": "Nice User", + "email": "a_nice_user@me.mail", + "avatar_url": "https://gitea.com/avatars/ae32f5573b27f9840942a522d59032b104a2dd15", + "html_url": "https://gitea.com/a_nice_user", + "visibility": "public", + "username": "a_nice_user" + }, + "name": "hello_world_ci", + "full_name": "a_nice_user/hello_world_ci", + "description": "", + "html_url": "https://gitea.com/a_nice_user/hello_world_ci", + "url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci", + "ssh_url": "ssh://git@gitea.com:3344/a_nice_user/hello_world_ci.git", + "clone_url": "https://gitea.com/a_nice_user/hello_world_ci.git", + "default_branch": "main", + "permissions": { + "admin": false, + "push": false, + "pull": true + }, + "has_pull_requests": true, + "object_format_name": "sha1" + } + } + }, + "requested_reviewer": null, + "repository": { + "id": 1234, + "owner": { + "id": 349, + "login": "a_nice_user", + "full_name": "Nice User", + "email": "a_nice_user@me.mail", + "avatar_url": "https://gitea.com/avatars/ae32f5573b27f9840942a522d59032b104a2dd15", + "html_url": "https://gitea.com/a_nice_user", + "visibility": "public", + "username": "a_nice_user" + }, + "name": "hello_world_ci", + "full_name": "a_nice_user/hello_world_ci", + "description": "", + "html_url": "https://gitea.com/a_nice_user/hello_world_ci", + "url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci", + "ssh_url": "ssh://git@gitea.com:3344/a_nice_user/hello_world_ci.git", + "clone_url": "https://gitea.com/a_nice_user/hello_world_ci.git", + "default_branch": "main", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "has_pull_requests": true, + "object_format_name": "sha1" + }, + "sender": { + "id": 349, + "login": "a_nice_user", + "full_name": "Nice User", + "email": "a_nice_user@noreply.example.org", + "avatar_url": "https://gitea.com/avatars/ae32f5573b27f9840942a522d59032b104a2dd15", + "html_url": "https://gitea.com/a_nice_user", + "visibility": "public", + "username": "a_nice_user" + }, + "commit_id": "", + "review": { + "type": "pull_request_review_approved", + "content": "juhu thats a great idea" + } +} diff --git a/server/forge/gitea/fixtures/HookPullRequestReviewComment.json b/server/forge/gitea/fixtures/HookPullRequestReviewComment.json new file mode 100644 index 00000000000..f5c86c17150 --- /dev/null +++ b/server/forge/gitea/fixtures/HookPullRequestReviewComment.json @@ -0,0 +1,158 @@ +{ + "action": "reviewed", + "number": 7, + "pull_request": { + "id": 3779, + "url": "https://gitea.com/a_nice_user/hello_world_ci/pulls/7", + "number": 7, + "user": { + "id": 1, + "login": "jony", + "full_name": "Jony", + "email": "jony@noreply.example.org", + "avatar_url": "https://gitea.com/avatars/81027235e996f5e3ef6257152357b85d94171a2e", + "html_url": "https://gitea.com/jony", + "description": "", + "visibility": "public", + "username": "jony" + }, + "title": "somepull", + "body": "wow aaa new pulll body", + "labels": [], + "milestone": null, + "assignees": null, + "requested_reviewers": [ + { + "id": 349, + "login": "a_nice_user", + "full_name": "Nice User", + "email": "a_nice_user@noreply.example.org", + "avatar_url": "https://gitea.com/avatars/ae32f5573b27f9840942a522d59032b104a2dd15", + "html_url": "https://gitea.com/a_nice_user", + "visibility": "public", + "username": "a_nice_user" + } + ], + "state": "open", + "comments": 0, + "review_comments": 3, + "additions": 1, + "deletions": 0, + "changed_files": 1, + "html_url": "https://gitea.com/a_nice_user/hello_world_ci/pulls/7", + "diff_url": "https://gitea.com/a_nice_user/hello_world_ci/pulls/7.diff", + "patch_url": "https://gitea.com/a_nice_user/hello_world_ci/pulls/7.patch", + "base": { + "label": "main", + "ref": "main", + "sha": "a40211c506550ebd79633d84e913dafa184c6d56", + "repo_id": 1234, + "repo": { + "id": 1234, + "owner": { + "id": 349, + "login": "a_nice_user", + "full_name": "Nice User", + "email": "a_nice_user@me.mail", + "avatar_url": "https://gitea.com/avatars/ae32f5573b27f9840942a522d59032b104a2dd15", + "html_url": "https://gitea.com/a_nice_user", + "visibility": "public", + "username": "a_nice_user" + }, + "name": "hello_world_ci", + "full_name": "a_nice_user/hello_world_ci", + "description": "", + "html_url": "https://gitea.com/a_nice_user/hello_world_ci", + "url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci", + "ssh_url": "ssh://git@gitea.com:3344/a_nice_user/hello_world_ci.git", + "clone_url": "https://gitea.com/a_nice_user/hello_world_ci.git", + "default_branch": "main", + "permissions": { + "admin": false, + "push": false, + "pull": true + }, + "has_pull_requests": true, + "object_format_name": "sha1" + } + }, + "head": { + "label": "jony-patch-1", + "ref": "jony-patch-1", + "sha": "07977177c2cd7d46bad37b8472a9d50e7acb9d1f", + "repo_id": 1234, + "repo": { + "id": 1234, + "owner": { + "id": 349, + "login": "a_nice_user", + "full_name": "Nice User", + "email": "a_nice_user@me.mail", + "avatar_url": "https://gitea.com/avatars/ae32f5573b27f9840942a522d59032b104a2dd15", + "html_url": "https://gitea.com/a_nice_user", + "visibility": "public", + "username": "a_nice_user" + }, + "name": "hello_world_ci", + "full_name": "a_nice_user/hello_world_ci", + "description": "", + "html_url": "https://gitea.com/a_nice_user/hello_world_ci", + "url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci", + "ssh_url": "ssh://git@gitea.com:3344/a_nice_user/hello_world_ci.git", + "clone_url": "https://gitea.com/a_nice_user/hello_world_ci.git", + "default_branch": "main", + "permissions": { + "admin": false, + "push": false, + "pull": true + }, + "has_pull_requests": true, + "object_format_name": "sha1" + } + } + }, + "requested_reviewer": null, + "repository": { + "id": 1234, + "owner": { + "id": 349, + "login": "a_nice_user", + "full_name": "Nice User", + "email": "a_nice_user@me.mail", + "avatar_url": "https://gitea.com/avatars/ae32f5573b27f9840942a522d59032b104a2dd15", + "html_url": "https://gitea.com/a_nice_user", + "visibility": "public", + "username": "a_nice_user" + }, + "name": "hello_world_ci", + "full_name": "a_nice_user/hello_world_ci", + "description": "", + "html_url": "https://gitea.com/a_nice_user/hello_world_ci", + "url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci", + "ssh_url": "ssh://git@gitea.com:3344/a_nice_user/hello_world_ci.git", + "clone_url": "https://gitea.com/a_nice_user/hello_world_ci.git", + "default_branch": "main", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "has_pull_requests": true, + "object_format_name": "sha1" + }, + "sender": { + "id": 349, + "login": "a_nice_user", + "full_name": "Nice User", + "email": "a_nice_user@noreply.example.org", + "avatar_url": "https://gitea.com/avatars/ae32f5573b27f9840942a522d59032b104a2dd15", + "html_url": "https://gitea.com/a_nice_user", + "visibility": "public", + "username": "a_nice_user" + }, + "commit_id": "", + "review": { + "type": "pull_request_review_comment", + "content": "and somethimes you have to comment" + } +} diff --git a/server/forge/gitea/fixtures/HookPullRequestReviewDeny.json b/server/forge/gitea/fixtures/HookPullRequestReviewDeny.json new file mode 100644 index 00000000000..d3edb679942 --- /dev/null +++ b/server/forge/gitea/fixtures/HookPullRequestReviewDeny.json @@ -0,0 +1,164 @@ +{ + "action": "reviewed", + "number": 7, + "pull_request": { + "id": 3779, + "url": "https://gitea.com/a_nice_user/hello_world_ci/pulls/7", + "number": 7, + "user": { + "id": 1, + "login": "jony", + "full_name": "Jony", + "email": "jony@noreply.example.org", + "avatar_url": "https://gitea.com/avatars/81027235e996f5e3ef6257152357b85d94171a2e", + "html_url": "https://gitea.com/jony", + "description": "", + "visibility": "public", + "username": "jony" + }, + "title": "somepull", + "body": "wow aaa new pulll body", + "labels": [], + "milestone": null, + "assignee": null, + "assignees": null, + "requested_reviewers": [ + { + "id": 349, + "login": "a_nice_user", + "full_name": "Nice User", + "email": "a_nice_user@noreply.example.org", + "avatar_url": "https://gitea.com/avatars/ae32f5573b27f9840942a522d59032b104a2dd15", + "html_url": "https://gitea.com/a_nice_user", + "visibility": "public", + "username": "a_nice_user" + } + ], + "state": "open", + "draft": false, + "is_locked": false, + "comments": 0, + "review_comments": 2, + "additions": 1, + "deletions": 0, + "changed_files": 1, + "html_url": "https://gitea.com/a_nice_user/hello_world_ci/pulls/7", + "diff_url": "https://gitea.com/a_nice_user/hello_world_ci/pulls/7.diff", + "patch_url": "https://gitea.com/a_nice_user/hello_world_ci/pulls/7.patch", + "base": { + "label": "main", + "ref": "main", + "sha": "a40211c506550ebd79633d84e913dafa184c6d56", + "repo_id": 1234, + "repo": { + "id": 1234, + "owner": { + "id": 349, + "login": "a_nice_user", + "full_name": "Nice User", + "email": "a_nice_user@me.mail", + "avatar_url": "https://gitea.com/avatars/ae32f5573b27f9840942a522d59032b104a2dd15", + "html_url": "https://gitea.com/a_nice_user", + "visibility": "public", + "username": "a_nice_user" + }, + "name": "hello_world_ci", + "full_name": "a_nice_user/hello_world_ci", + "description": "", + "html_url": "https://gitea.com/a_nice_user/hello_world_ci", + "url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci", + "ssh_url": "ssh://git@gitea.com:3344/a_nice_user/hello_world_ci.git", + "clone_url": "https://gitea.com/a_nice_user/hello_world_ci.git", + "default_branch": "main", + "permissions": { + "admin": false, + "push": false, + "pull": true + }, + "has_pull_requests": true, + "object_format_name": "sha1" + } + }, + "head": { + "label": "jony-patch-1", + "ref": "jony-patch-1", + "sha": "07977177c2cd7d46bad37b8472a9d50e7acb9d1f", + "repo_id": 1234, + "repo": { + "id": 1234, + "owner": { + "id": 349, + "login": "a_nice_user", + "full_name": "Nice User", + "email": "a_nice_user@me.mail", + "avatar_url": "https://gitea.com/avatars/ae32f5573b27f9840942a522d59032b104a2dd15", + "html_url": "https://gitea.com/a_nice_user", + "visibility": "public", + "username": "a_nice_user" + }, + "name": "hello_world_ci", + "full_name": "a_nice_user/hello_world_ci", + "description": "", + "html_url": "https://gitea.com/a_nice_user/hello_world_ci", + "url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci", + "ssh_url": "ssh://git@gitea.com:3344/a_nice_user/hello_world_ci.git", + "clone_url": "https://gitea.com/a_nice_user/hello_world_ci.git", + "default_branch": "main", + "permissions": { + "admin": false, + "push": false, + "pull": true + }, + "has_pull_requests": true, + "object_format_name": "sha1" + } + }, + "due_date": null, + "closed_at": null, + "pin_order": 0 + }, + "requested_reviewer": null, + "repository": { + "id": 1234, + "owner": { + "id": 349, + "login": "a_nice_user", + "full_name": "Nice User", + "email": "a_nice_user@me.mail", + "avatar_url": "https://gitea.com/avatars/ae32f5573b27f9840942a522d59032b104a2dd15", + "html_url": "https://gitea.com/a_nice_user", + "visibility": "public", + "username": "a_nice_user" + }, + "name": "hello_world_ci", + "full_name": "a_nice_user/hello_world_ci", + "description": "", + "html_url": "https://gitea.com/a_nice_user/hello_world_ci", + "url": "https://gitea.com/api/v1/repos/a_nice_user/hello_world_ci", + "ssh_url": "ssh://git@gitea.com:3344/a_nice_user/hello_world_ci.git", + "clone_url": "https://gitea.com/a_nice_user/hello_world_ci.git", + "default_branch": "main", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "has_pull_requests": true, + "object_format_name": "sha1" + }, + "sender": { + "id": 349, + "login": "a_nice_user", + "full_name": "Nice User", + "email": "a_nice_user@noreply.example.org", + "avatar_url": "https://gitea.com/avatars/ae32f5573b27f9840942a522d59032b104a2dd15", + "html_url": "https://gitea.com/a_nice_user", + "visibility": "public", + "username": "a_nice_user" + }, + "commit_id": "", + "review": { + "type": "pull_request_review_rejected", + "content": "I decided otherwhies :O" + } +} diff --git a/server/forge/gitea/fixtures/hooks.go b/server/forge/gitea/fixtures/hooks.go index 928e2aa5a0a..9927e62e471 100644 --- a/server/forge/gitea/fixtures/hooks.go +++ b/server/forge/gitea/fixtures/hooks.go @@ -50,6 +50,48 @@ var HookPullRequestMerged string //go:embed HookPullRequestClosed.json var HookPullRequestClosed string +//go:embed HookPullRequestChangeTitle.json +var HookPullRequestChangeTitle string + +//go:embed HookPullRequestChangeBody.json +var HookPullRequestChangeBody string + +//go:embed HookPullRequestAddReviewRequest.json +var HookPullRequestAddReviewRequest string + +//go:embed HookPullRequestReviewAck.json +var HookPullRequestReviewAck string + +//go:embed HookPullRequestReviewDeny.json +var HookPullRequestReviewDeny string + +//go:embed HookPullRequestReviewComment.json +var HookPullRequestReviewComment string + +//go:embed HookPullRequestAddLabel.json +var HookPullRequestAddLabel string + +//go:embed HookPullRequestChangeLabel.json +var HookPullRequestChangeLabel string + +//go:embed HookPullRequestRemoveLabel.json +var HookPullRequestRemoveLabel string + +//go:embed HookPullRequestAddMile.json +var HookPullRequestAddMile string + +//go:embed HookPullRequestChangeMile.json +var HookPullRequestChangeMile string + +//go:embed HookPullRequestRemoveMile.json +var HookPullRequestRemoveMile string + +//go:embed HookPullRequestAssigneesAdded.json +var HookPullRequestAssigneesAdded string + +//go:embed HookPullRequestAssigneesRemoved.json +var HookPullRequestAssigneesRemoved string + //go:embed HookRelease.json var HookRelease string diff --git a/server/forge/gitea/gitea.go b/server/forge/gitea/gitea.go index 4a2a564ce2b..b443ce597df 100644 --- a/server/forge/gitea/gitea.go +++ b/server/forge/gitea/gitea.go @@ -508,7 +508,7 @@ func (c *Gitea) Hook(ctx context.Context, r *http.Request) (*model.Repo, *model. pipeline.Commit = sha } - if pipeline != nil && (pipeline.Event == model.EventPull || pipeline.Event == model.EventPullClosed) && len(pipeline.ChangedFiles) == 0 { + if pipeline != nil && pipeline.IsPullRequest() && len(pipeline.ChangedFiles) == 0 { index, err := strconv.ParseInt(strings.Split(pipeline.Ref, "/")[2], 10, 64) if err != nil { return nil, nil, err diff --git a/server/forge/gitea/helper.go b/server/forge/gitea/helper.go index 5e310da8a36..595b5758cde 100644 --- a/server/forge/gitea/helper.go +++ b/server/forge/gitea/helper.go @@ -150,8 +150,17 @@ func pipelineFromPullRequest(hook *pullRequestHook) *model.Pipeline { ) event := model.EventPull - if hook.Action == actionClose { + switch hook.Action { + case actionClose: event = model.EventPullClosed + case actionEdited, + actionLabelUpdate, + actionLabelCleared, + actionMilestoned, + actionDeMilestoned, + actionAssigned, + actionUnAssigned: + event = model.EventPullMetadata } pipeline := &model.Pipeline{ @@ -175,6 +184,10 @@ func pipelineFromPullRequest(hook *pullRequestHook) *model.Pipeline { FromFork: hook.PullRequest.Head.RepoID != hook.PullRequest.Base.RepoID, } + if pipeline.Event == model.EventPullMetadata { + pipeline.EventReason = []string{hook.Action} + } + return pipeline } diff --git a/server/forge/gitea/parse.go b/server/forge/gitea/parse.go index 714d714d97d..ed37a4464be 100644 --- a/server/forge/gitea/parse.go +++ b/server/forge/gitea/parse.go @@ -19,10 +19,12 @@ import ( "fmt" "io" "net/http" + "slices" "strings" "github.com/rs/zerolog/log" + "go.woodpecker-ci.org/woodpecker/v3/server/forge/common" "go.woodpecker-ci.org/woodpecker/v3/server/forge/types" "go.woodpecker-ci.org/woodpecker/v3/server/model" ) @@ -34,15 +36,40 @@ const ( hookPullRequest = "pull_request" hookRelease = "release" - actionOpen = "opened" - actionSync = "synchronized" - actionClose = "closed" - actionReopen = "reopened" + actionOpen = "opened" + actionSync = "synchronized" + actionClose = "closed" + actionEdited = "edited" + actionLabelUpdate = "label_updated" + actionLabelCleared = "label_cleared" + actionMilestoned = "milestoned" + actionDeMilestoned = "demilestoned" + actionAssigned = "assigned" + actionUnAssigned = "unassigned" + actionReopen = "reopened" refBranch = "branch" refTag = "tag" ) +var actionList = []string{ + actionOpen, + actionSync, + actionClose, + actionEdited, + actionLabelUpdate, + actionMilestoned, + actionDeMilestoned, + actionLabelCleared, + actionAssigned, + actionUnAssigned, + actionReopen, +} + +func supportedAction(action string) bool { + return slices.Contains(actionList, action) +} + // parseHook parses a Gitea hook from an http.Request and returns // Repo and Pipeline detail. If a hook type is unsupported nil values are returned. func parseHook(r *http.Request) (*model.Repo, *model.Pipeline, error) { @@ -118,17 +145,27 @@ func parsePullRequestHook(payload io.Reader) (*model.Repo, *model.Pipeline, erro return nil, nil, fmt.Errorf("parsed pull_request webhook does not contain pull_request info") } - // Don't trigger pipelines for non-code changes ... - if pr.Action != actionOpen && - pr.Action != actionSync && - pr.Action != actionClose && - pr.Action != actionReopen { - log.Debug().Msgf("pull_request action is '%s' and no open or sync", pr.Action) + // Only trigger pipelines for supported event types + if !supportedAction(pr.Action) { + log.Debug().Msgf("pull_request action is '%s'. Only '%s' are supported", pr.Action, strings.Join(actionList, "', '")) return nil, nil, nil } repo = toRepo(pr.Repo) pipeline = pipelineFromPullRequest(pr) + + // all other actions return the state of labels after the actions where done ... so we should too + if pr.Action == actionLabelCleared { + pipeline.PullRequestLabels = []string{} + } + if pr.Action == actionDeMilestoned { + pipeline.PullRequestMilestone = "" + } + + for i := range pipeline.EventReason { + pipeline.EventReason[i] = common.NormalizeEventReason(pipeline.EventReason[i]) + } + return repo, pipeline, err } diff --git a/server/forge/gitea/parse_test.go b/server/forge/gitea/parse_test.go index f573a4ab80b..32794f7c79b 100644 --- a/server/forge/gitea/parse_test.go +++ b/server/forge/gitea/parse_test.go @@ -28,6 +28,24 @@ import ( ) func TestGiteaParser(t *testing.T) { + pullMetaWebhookRepo := &model.Repo{ + ForgeRemoteID: "1234", + Owner: "a_nice_user", + Name: "hello_world_ci", + FullName: "a_nice_user/hello_world_ci", + Avatar: "https://gitea.com/avatars/ae32f5573b27f9840942a522d59032b104a2dd15", + ForgeURL: "https://gitea.com/a_nice_user/hello_world_ci", + Clone: "https://gitea.com/a_nice_user/hello_world_ci.git", + CloneSSH: "ssh://git@gitea.com:3344/a_nice_user/hello_world_ci.git", + Branch: "main", + PREnabled: true, + Perm: &model.Perm{ + Pull: true, + Push: true, + Admin: true, + }, + } + tests := []struct { name string data string @@ -331,6 +349,249 @@ func TestGiteaParser(t *testing.T) { PullRequestLabels: []string{}, }, }, + { + name: "pull-request events should handle a PR title change hook", + data: fixtures.HookPullRequestChangeTitle, + event: "pull_request", + repo: pullMetaWebhookRepo, + pipe: &model.Pipeline{ + Author: "jony", + Event: model.EventPullMetadata, + EventReason: []string{"edited"}, + Commit: "07977177c2cd7d46bad37b8472a9d50e7acb9d1f", + Branch: "main", + Ref: "refs/pull/7/head", + Refspec: "jony-patch-1:main", + Title: "Edit pull title :D", + Message: "Edit pull title :D", + Sender: "a_nice_user", + Avatar: "https://gitea.com/avatars/81027235e996f5e3ef6257152357b85d94171a2e", + Email: "a_nice_user@noreply.example.org", + ForgeURL: "https://gitea.com/a_nice_user/hello_world_ci/pulls/7", + PullRequestLabels: []string{}, + }, + }, + { + name: "pull-request events should handle a PR body change hook", + data: fixtures.HookPullRequestChangeBody, + event: "pull_request", + repo: pullMetaWebhookRepo, + pipe: &model.Pipeline{ + Author: "jony", + Event: model.EventPullMetadata, + EventReason: []string{"edited"}, + Commit: "07977177c2cd7d46bad37b8472a9d50e7acb9d1f", + Branch: "main", + Ref: "refs/pull/7/head", + Refspec: "jony-patch-1:main", + Title: "somepull", + Message: "somepull", + Sender: "a_nice_user", + Avatar: "https://gitea.com/avatars/81027235e996f5e3ef6257152357b85d94171a2e", + Email: "a_nice_user@noreply.example.org", + ForgeURL: "https://gitea.com/a_nice_user/hello_world_ci/pulls/7", + PullRequestLabels: []string{}, + }, + }, + { + name: "pull-request events should ignore a PR add review request hook", + data: fixtures.HookPullRequestAddReviewRequest, + err: &types.ErrIgnoreEvent{}, + }, + { + name: "pull-request events should ignore a PR add approval review request hook", + data: fixtures.HookPullRequestReviewAck, + err: &types.ErrIgnoreEvent{}, + }, + { + name: "pull-request events should ignore a PR add reject review request hook", + data: fixtures.HookPullRequestReviewDeny, + err: &types.ErrIgnoreEvent{}, + }, + { + name: "pull-request events should ignore a PR add comment review request hook", + data: fixtures.HookPullRequestReviewComment, + err: &types.ErrIgnoreEvent{}, + }, + { + name: "pull-request events should handle a PR add label hook", + data: fixtures.HookPullRequestAddLabel, + event: "pull_request", // type: pull_request_label + repo: pullMetaWebhookRepo, + pipe: &model.Pipeline{ + Author: "jony", + Event: model.EventPullMetadata, + EventReason: []string{"label_updated"}, + Commit: "07977177c2cd7d46bad37b8472a9d50e7acb9d1f", + Branch: "main", + Ref: "refs/pull/7/head", + Refspec: "jony-patch-1:main", + Title: "somepull", + Message: "somepull", + Sender: "a_nice_user", + Avatar: "https://gitea.com/avatars/81027235e996f5e3ef6257152357b85d94171a2e", + Email: "a_nice_user@noreply.example.org", + ForgeURL: "https://gitea.com/a_nice_user/hello_world_ci/pulls/7", + PullRequestLabels: []string{"bug", "help wanted"}, + }, + }, + { + name: "pull-request events should handle a PR change label hook", + data: fixtures.HookPullRequestChangeLabel, + event: "pull_request", // type: pull_request_label + repo: pullMetaWebhookRepo, + pipe: &model.Pipeline{ + Author: "jony", + Event: model.EventPullMetadata, + EventReason: []string{"label_updated"}, + Commit: "07977177c2cd7d46bad37b8472a9d50e7acb9d1f", + Branch: "main", + Ref: "refs/pull/7/head", + Refspec: "jony-patch-1:main", + Title: "somepull", + Message: "somepull", + Sender: "a_nice_user", + Avatar: "https://gitea.com/avatars/81027235e996f5e3ef6257152357b85d94171a2e", + Email: "a_nice_user@noreply.example.org", + ForgeURL: "https://gitea.com/a_nice_user/hello_world_ci/pulls/7", + PullRequestLabels: []string{"bug"}, + }, + }, + { + name: "pull-request events should handle a PR remove label hook", + data: fixtures.HookPullRequestRemoveLabel, + event: "pull_request", // type: pull_request_label + repo: pullMetaWebhookRepo, + pipe: &model.Pipeline{ + Author: "jony", + Event: model.EventPullMetadata, + EventReason: []string{"label_cleared"}, + Commit: "07977177c2cd7d46bad37b8472a9d50e7acb9d1f", + Branch: "main", + Ref: "refs/pull/7/head", + Refspec: "jony-patch-1:main", + Title: "somepull", + Message: "somepull", + Sender: "a_nice_user", + Avatar: "https://gitea.com/avatars/81027235e996f5e3ef6257152357b85d94171a2e", + Email: "a_nice_user@noreply.example.org", + ForgeURL: "https://gitea.com/a_nice_user/hello_world_ci/pulls/7", + PullRequestLabels: []string{}, + }, + }, + { + name: "pull-request events should handle a PR add milestone hook", + data: fixtures.HookPullRequestAddMile, + event: "pull_request", // type: pull_request_milestone + repo: pullMetaWebhookRepo, + pipe: &model.Pipeline{ + Author: "jony", + Event: model.EventPullMetadata, + EventReason: []string{"milestoned"}, + Commit: "07977177c2cd7d46bad37b8472a9d50e7acb9d1f", + Branch: "main", + Ref: "refs/pull/7/head", + Refspec: "jony-patch-1:main", + Title: "somepull", + Message: "somepull", + Sender: "a_nice_user", + Avatar: "https://gitea.com/avatars/81027235e996f5e3ef6257152357b85d94171a2e", + Email: "a_nice_user@noreply.example.org", + ForgeURL: "https://gitea.com/a_nice_user/hello_world_ci/pulls/7", + PullRequestLabels: []string{"bug", "help wanted"}, + PullRequestMilestone: "new mile", + }, + }, + { + name: "pull-request events should handle a PR change milestone hook", + data: fixtures.HookPullRequestChangeMile, + event: "pull_request", // type: pull_request_milestone + repo: pullMetaWebhookRepo, + pipe: &model.Pipeline{ + Author: "jony", + Event: model.EventPullMetadata, + EventReason: []string{"milestoned"}, + Commit: "07977177c2cd7d46bad37b8472a9d50e7acb9d1f", + Branch: "main", + Ref: "refs/pull/7/head", + Refspec: "jony-patch-1:main", + Title: "somepull", + Message: "somepull", + Sender: "a_nice_user", + Avatar: "https://gitea.com/avatars/81027235e996f5e3ef6257152357b85d94171a2e", + Email: "a_nice_user@noreply.example.org", + ForgeURL: "https://gitea.com/a_nice_user/hello_world_ci/pulls/7", + PullRequestLabels: []string{"bug", "help wanted"}, + PullRequestMilestone: "closed mile", + }, + }, + { + name: "pull-request events should handle a PR remove milestone hook", + data: fixtures.HookPullRequestRemoveMile, + event: "pull_request", // type: pull_request_milestone + repo: pullMetaWebhookRepo, + pipe: &model.Pipeline{ + Author: "jony", + Event: model.EventPullMetadata, + EventReason: []string{"demilestoned"}, + Commit: "07977177c2cd7d46bad37b8472a9d50e7acb9d1f", + Branch: "main", + Ref: "refs/pull/7/head", + Refspec: "jony-patch-1:main", + Title: "somepull", + Message: "somepull", + Sender: "a_nice_user", + Avatar: "https://gitea.com/avatars/81027235e996f5e3ef6257152357b85d94171a2e", + Email: "a_nice_user@noreply.example.org", + ForgeURL: "https://gitea.com/a_nice_user/hello_world_ci/pulls/7", + PullRequestLabels: []string{"bug", "help wanted"}, + PullRequestMilestone: "", + }, + }, + { + name: "pull-request events should handle a PR add assignee hook", + data: fixtures.HookPullRequestAssigneesAdded, + event: "pull_request", // type: pull_request_assign + repo: pullMetaWebhookRepo, + pipe: &model.Pipeline{ + Author: "jony", + Event: model.EventPullMetadata, + EventReason: []string{"assigned"}, + Commit: "07977177c2cd7d46bad37b8472a9d50e7acb9d1f", + Branch: "main", + Ref: "refs/pull/7/head", + Refspec: "jony-patch-1:main", + Title: "somepull", + Message: "somepull", + Sender: "a_nice_user", + Avatar: "https://gitea.com/avatars/81027235e996f5e3ef6257152357b85d94171a2e", + Email: "a_nice_user@noreply.example.org", + ForgeURL: "https://gitea.com/a_nice_user/hello_world_ci/pulls/7", + PullRequestLabels: []string{"bug"}, + }, + }, + { + name: "pull-request events should handle a PR remove assignee hook", + data: fixtures.HookPullRequestAssigneesRemoved, + event: "pull_request", // type: pull_request_assign + repo: pullMetaWebhookRepo, + pipe: &model.Pipeline{ + Author: "jony", + Event: model.EventPullMetadata, + EventReason: []string{"unassigned"}, + Commit: "07977177c2cd7d46bad37b8472a9d50e7acb9d1f", + Branch: "main", + Ref: "refs/pull/7/head", + Refspec: "jony-patch-1:main", + Title: "somepull", + Message: "somepull", + Sender: "a_nice_user", + Avatar: "https://gitea.com/avatars/81027235e996f5e3ef6257152357b85d94171a2e", + Email: "a_nice_user@noreply.example.org", + ForgeURL: "https://gitea.com/a_nice_user/hello_world_ci/pulls/7", + PullRequestLabels: []string{"bug"}, + }, + }, { name: "pull-request events should handle a PR closed hook when PR was merged", data: fixtures.HookPullRequestMerged, diff --git a/server/forge/github/convert_test.go b/server/forge/github/convert_test.go index d1a41cdb476..e90b0df3e26 100644 --- a/server/forge/github/convert_test.go +++ b/server/forge/github/convert_test.go @@ -24,6 +24,10 @@ import ( "go.woodpecker-ci.org/woodpecker/v3/server/model" ) +const ( + stateOpen = "open" +) + func Test_convertStatus(t *testing.T) { assert.Equal(t, statusSuccess, convertStatus(model.StatusSuccess)) assert.Equal(t, statusPending, convertStatus(model.StatusPending)) diff --git a/server/forge/github/fixtures/HookPullRequestAssigneeAdded.json b/server/forge/github/fixtures/HookPullRequestAssigneeAdded.json new file mode 100644 index 00000000000..0bd8ab04e71 --- /dev/null +++ b/server/forge/github/fixtures/HookPullRequestAssigneeAdded.json @@ -0,0 +1,323 @@ +{ + "action": "assigned", + "number": 1, + "pull_request": { + "url": "https://api.github.com/repos/6543/test_ci_tmp/pulls/1", + "id": 2705176047, + "node_id": "PR_kwDOPU9UaM6hPbXv", + "number": 1, + "state": "open", + "locked": false, + "title": "Some ned more AAAA", + "user": { + "login": "6543", + "id": 24977596, + "node_id": "MDQ6VXNlcjI0OTc3NTk2", + "gravatar_id": "", + "url": "https://api.github.com/users/6543", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "body": "yeaaa", + "created_at": "2025-07-29T20:00:54Z", + "updated_at": "2025-07-30T00:05:47Z", + "closed_at": null, + "merged_at": null, + "merge_commit_sha": "b5fafd8b1c043723a38c99775bc807075bce9235", + "assignee": { + "login": "demoaccount2-commits", + "id": 223550959, + "node_id": "U_kgDODVMd7w", + "gravatar_id": "", + "url": "https://api.github.com/users/demoaccount2-commits", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "assignees": [ + { + "login": "demoaccount2-commits", + "id": 223550959, + "node_id": "U_kgDODVMd7w", + "gravatar_id": "", + "url": "https://api.github.com/users/demoaccount2-commits", + "type": "User", + "user_view_type": "public", + "site_admin": false + } + ], + "requested_reviewers": [], + "requested_teams": [], + "labels": [ + { + "id": 9024465370, + "node_id": "LA_kwDOPU9UaM8AAAACGeZp2g", + "url": "https://api.github.com/repos/6543/test_ci_tmp/labels/bug", + "name": "bug", + "color": "d73a4a", + "default": true, + "description": "Something isn't working" + } + ], + "milestone": null, + "draft": false, + "head": { + "label": "6543:6543-patch-1", + "ref": "6543-patch-1", + "sha": "36b5813240a9d2daa29b05046d56a53e18f39a3e", + "user": { + "login": "6543", + "id": 24977596, + "node_id": "MDQ6VXNlcjI0OTc3NTk2", + "gravatar_id": "", + "url": "https://api.github.com/users/6543", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "repo": { + "id": 1028609128, + "node_id": "R_kgDOPU9UaA", + "name": "test_ci_tmp", + "full_name": "6543/test_ci_tmp", + "private": false, + "owner": { + "login": "6543", + "id": 24977596, + "node_id": "MDQ6VXNlcjI0OTc3NTk2", + "gravatar_id": "", + "url": "https://api.github.com/users/6543", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "description": null, + "fork": false, + "url": "https://api.github.com/repos/6543/test_ci_tmp", + "created_at": "2025-07-29T19:35:41Z", + "updated_at": "2025-07-29T19:36:23Z", + "pushed_at": "2025-07-29T19:36:21Z", + "homepage": null, + "size": 3, + "stargazers_count": 0, + "watchers_count": 0, + "language": "Dockerfile", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "has_discussions": false, + "forks_count": 0, + "archived": false, + "disabled": false, + "open_issues_count": 1, + "license": null, + "allow_forking": true, + "is_template": false, + "web_commit_signoff_required": false, + "topics": [], + "visibility": "public", + "forks": 0, + "open_issues": 1, + "watchers": 0, + "default_branch": "main", + "allow_squash_merge": true, + "allow_merge_commit": true, + "allow_rebase_merge": true, + "allow_auto_merge": false, + "delete_branch_on_merge": false, + "allow_update_branch": false, + "use_squash_pr_title_as_default": false, + "squash_merge_commit_message": "COMMIT_MESSAGES", + "squash_merge_commit_title": "COMMIT_OR_PR_TITLE", + "merge_commit_message": "PR_TITLE", + "merge_commit_title": "MERGE_MESSAGE" + } + }, + "base": { + "label": "6543:main", + "ref": "main", + "sha": "67012991d6c69b1c58378346fca366b864d8d1a1", + "user": { + "login": "6543", + "id": 24977596, + "node_id": "MDQ6VXNlcjI0OTc3NTk2", + "gravatar_id": "", + "url": "https://api.github.com/users/6543", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "repo": { + "id": 1028609128, + "node_id": "R_kgDOPU9UaA", + "name": "test_ci_tmp", + "full_name": "6543/test_ci_tmp", + "private": false, + "owner": { + "login": "6543", + "id": 24977596, + "node_id": "MDQ6VXNlcjI0OTc3NTk2", + "gravatar_id": "", + "url": "https://api.github.com/users/6543", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "description": null, + "fork": false, + "url": "https://api.github.com/repos/6543/test_ci_tmp", + "created_at": "2025-07-29T19:35:41Z", + "updated_at": "2025-07-29T19:36:23Z", + "pushed_at": "2025-07-29T19:36:21Z", + "homepage": null, + "size": 3, + "stargazers_count": 0, + "watchers_count": 0, + "language": "Dockerfile", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "has_discussions": false, + "forks_count": 0, + "archived": false, + "disabled": false, + "open_issues_count": 1, + "license": null, + "allow_forking": true, + "is_template": false, + "web_commit_signoff_required": false, + "topics": [], + "visibility": "public", + "forks": 0, + "open_issues": 1, + "watchers": 0, + "default_branch": "main", + "allow_squash_merge": true, + "allow_merge_commit": true, + "allow_rebase_merge": true, + "allow_auto_merge": false, + "delete_branch_on_merge": false, + "allow_update_branch": false, + "use_squash_pr_title_as_default": false, + "squash_merge_commit_message": "COMMIT_MESSAGES", + "squash_merge_commit_title": "COMMIT_OR_PR_TITLE", + "merge_commit_message": "PR_TITLE", + "merge_commit_title": "MERGE_MESSAGE" + } + }, + "_links": { + "self": { + "href": "https://api.github.com/repos/6543/test_ci_tmp/pulls/1" + }, + "html": { + "href": "https://github.com/6543/test_ci_tmp/pull/1" + }, + "issue": { + "href": "https://api.github.com/repos/6543/test_ci_tmp/issues/1" + }, + "comments": { + "href": "https://api.github.com/repos/6543/test_ci_tmp/issues/1/comments" + }, + "review_comments": { + "href": "https://api.github.com/repos/6543/test_ci_tmp/pulls/1/comments" + }, + "review_comment": { + "href": "https://api.github.com/repos/6543/test_ci_tmp/pulls/comments{/number}" + }, + "commits": { + "href": "https://api.github.com/repos/6543/test_ci_tmp/pulls/1/commits" + }, + "statuses": { + "href": "https://api.github.com/repos/6543/test_ci_tmp/statuses/36b5813240a9d2daa29b05046d56a53e18f39a3e" + } + }, + "author_association": "OWNER", + "auto_merge": null, + "active_lock_reason": null, + "merged": false, + "mergeable": true, + "rebaseable": true, + "mergeable_state": "unstable", + "merged_by": null, + "comments": 0, + "review_comments": 0, + "maintainer_can_modify": false, + "commits": 1, + "additions": 1, + "deletions": 0, + "changed_files": 1 + }, + "assignee": { + "login": "demoaccount2-commits", + "id": 223550959, + "node_id": "U_kgDODVMd7w", + "gravatar_id": "", + "url": "https://api.github.com/users/demoaccount2-commits", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "repository": { + "id": 1028609128, + "node_id": "R_kgDOPU9UaA", + "name": "test_ci_tmp", + "full_name": "6543/test_ci_tmp", + "private": false, + "owner": { + "login": "6543", + "id": 24977596, + "node_id": "MDQ6VXNlcjI0OTc3NTk2", + "gravatar_id": "", + "url": "https://api.github.com/users/6543", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "description": null, + "fork": false, + "url": "https://api.github.com/repos/6543/test_ci_tmp", + "created_at": "2025-07-29T19:35:41Z", + "updated_at": "2025-07-29T19:36:23Z", + "pushed_at": "2025-07-29T19:36:21Z", + "homepage": null, + "size": 3, + "stargazers_count": 0, + "watchers_count": 0, + "language": "Dockerfile", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "has_discussions": false, + "forks_count": 0, + "archived": false, + "disabled": false, + "open_issues_count": 1, + "license": null, + "allow_forking": true, + "is_template": false, + "web_commit_signoff_required": false, + "topics": [], + "visibility": "public", + "forks": 0, + "open_issues": 1, + "watchers": 0, + "default_branch": "main" + }, + "sender": { + "login": "demoaccount2-commits", + "id": 223550959, + "node_id": "U_kgDODVMd7w", + "gravatar_id": "", + "url": "https://api.github.com/users/demoaccount2-commits", + "type": "User", + "user_view_type": "public", + "site_admin": false + } +} diff --git a/server/forge/github/fixtures/HookPullRequestAssigneeRemoved.json b/server/forge/github/fixtures/HookPullRequestAssigneeRemoved.json new file mode 100644 index 00000000000..3e7e8e7110d --- /dev/null +++ b/server/forge/github/fixtures/HookPullRequestAssigneeRemoved.json @@ -0,0 +1,303 @@ +{ + "action": "unassigned", + "number": 1, + "pull_request": { + "url": "https://api.github.com/repos/6543/test_ci_tmp/pulls/1", + "id": 2705176047, + "node_id": "PR_kwDOPU9UaM6hPbXv", + "number": 1, + "state": "open", + "locked": false, + "title": "Some ned more AAAA", + "user": { + "login": "6543", + "id": 24977596, + "node_id": "MDQ6VXNlcjI0OTc3NTk2", + "gravatar_id": "", + "url": "https://api.github.com/users/6543", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "body": "yeaaa", + "created_at": "2025-07-29T20:00:54Z", + "updated_at": "2025-07-30T00:06:11Z", + "closed_at": null, + "merged_at": null, + "merge_commit_sha": "b5fafd8b1c043723a38c99775bc807075bce9235", + "assignee": null, + "assignees": [], + "requested_reviewers": [], + "requested_teams": [], + "labels": [ + { + "id": 9024465370, + "node_id": "LA_kwDOPU9UaM8AAAACGeZp2g", + "url": "https://api.github.com/repos/6543/test_ci_tmp/labels/bug", + "name": "bug", + "color": "d73a4a", + "default": true, + "description": "Something isn't working" + } + ], + "milestone": null, + "draft": false, + "head": { + "label": "6543:6543-patch-1", + "ref": "6543-patch-1", + "sha": "36b5813240a9d2daa29b05046d56a53e18f39a3e", + "user": { + "login": "6543", + "id": 24977596, + "node_id": "MDQ6VXNlcjI0OTc3NTk2", + "gravatar_id": "", + "url": "https://api.github.com/users/6543", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "repo": { + "id": 1028609128, + "node_id": "R_kgDOPU9UaA", + "name": "test_ci_tmp", + "full_name": "6543/test_ci_tmp", + "private": false, + "owner": { + "login": "6543", + "id": 24977596, + "node_id": "MDQ6VXNlcjI0OTc3NTk2", + "gravatar_id": "", + "url": "https://api.github.com/users/6543", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "description": null, + "fork": false, + "url": "https://api.github.com/repos/6543/test_ci_tmp", + "created_at": "2025-07-29T19:35:41Z", + "updated_at": "2025-07-29T19:36:23Z", + "pushed_at": "2025-07-29T19:36:21Z", + "homepage": null, + "size": 3, + "stargazers_count": 0, + "watchers_count": 0, + "language": "Dockerfile", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "has_discussions": false, + "forks_count": 0, + "archived": false, + "disabled": false, + "open_issues_count": 1, + "license": null, + "allow_forking": true, + "is_template": false, + "web_commit_signoff_required": false, + "topics": [], + "visibility": "public", + "forks": 0, + "open_issues": 1, + "watchers": 0, + "default_branch": "main", + "allow_squash_merge": true, + "allow_merge_commit": true, + "allow_rebase_merge": true, + "allow_auto_merge": false, + "delete_branch_on_merge": false, + "allow_update_branch": false, + "use_squash_pr_title_as_default": false, + "squash_merge_commit_message": "COMMIT_MESSAGES", + "squash_merge_commit_title": "COMMIT_OR_PR_TITLE", + "merge_commit_message": "PR_TITLE", + "merge_commit_title": "MERGE_MESSAGE" + } + }, + "base": { + "label": "6543:main", + "ref": "main", + "sha": "67012991d6c69b1c58378346fca366b864d8d1a1", + "user": { + "login": "6543", + "id": 24977596, + "node_id": "MDQ6VXNlcjI0OTc3NTk2", + "gravatar_id": "", + "url": "https://api.github.com/users/6543", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "repo": { + "id": 1028609128, + "node_id": "R_kgDOPU9UaA", + "name": "test_ci_tmp", + "full_name": "6543/test_ci_tmp", + "private": false, + "owner": { + "login": "6543", + "id": 24977596, + "node_id": "MDQ6VXNlcjI0OTc3NTk2", + "gravatar_id": "", + "url": "https://api.github.com/users/6543", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "description": null, + "fork": false, + "url": "https://api.github.com/repos/6543/test_ci_tmp", + "created_at": "2025-07-29T19:35:41Z", + "updated_at": "2025-07-29T19:36:23Z", + "pushed_at": "2025-07-29T19:36:21Z", + "homepage": null, + "size": 3, + "stargazers_count": 0, + "watchers_count": 0, + "language": "Dockerfile", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "has_discussions": false, + "forks_count": 0, + "archived": false, + "disabled": false, + "open_issues_count": 1, + "license": null, + "allow_forking": true, + "is_template": false, + "web_commit_signoff_required": false, + "topics": [], + "visibility": "public", + "forks": 0, + "open_issues": 1, + "watchers": 0, + "default_branch": "main", + "allow_squash_merge": true, + "allow_merge_commit": true, + "allow_rebase_merge": true, + "allow_auto_merge": false, + "delete_branch_on_merge": false, + "allow_update_branch": false, + "use_squash_pr_title_as_default": false, + "squash_merge_commit_message": "COMMIT_MESSAGES", + "squash_merge_commit_title": "COMMIT_OR_PR_TITLE", + "merge_commit_message": "PR_TITLE", + "merge_commit_title": "MERGE_MESSAGE" + } + }, + "_links": { + "self": { + "href": "https://api.github.com/repos/6543/test_ci_tmp/pulls/1" + }, + "html": { + "href": "https://github.com/6543/test_ci_tmp/pull/1" + }, + "issue": { + "href": "https://api.github.com/repos/6543/test_ci_tmp/issues/1" + }, + "comments": { + "href": "https://api.github.com/repos/6543/test_ci_tmp/issues/1/comments" + }, + "review_comments": { + "href": "https://api.github.com/repos/6543/test_ci_tmp/pulls/1/comments" + }, + "review_comment": { + "href": "https://api.github.com/repos/6543/test_ci_tmp/pulls/comments{/number}" + }, + "commits": { + "href": "https://api.github.com/repos/6543/test_ci_tmp/pulls/1/commits" + }, + "statuses": { + "href": "https://api.github.com/repos/6543/test_ci_tmp/statuses/36b5813240a9d2daa29b05046d56a53e18f39a3e" + } + }, + "author_association": "OWNER", + "auto_merge": null, + "active_lock_reason": null, + "merged": false, + "mergeable": true, + "rebaseable": true, + "mergeable_state": "unstable", + "merged_by": null, + "comments": 0, + "review_comments": 0, + "maintainer_can_modify": false, + "commits": 1, + "additions": 1, + "deletions": 0, + "changed_files": 1 + }, + "assignee": { + "login": "6543", + "id": 24977596, + "node_id": "MDQ6VXNlcjI0OTc3NTk2", + "gravatar_id": "", + "url": "https://api.github.com/users/6543", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "repository": { + "id": 1028609128, + "node_id": "R_kgDOPU9UaA", + "name": "test_ci_tmp", + "full_name": "6543/test_ci_tmp", + "private": false, + "owner": { + "login": "6543", + "id": 24977596, + "node_id": "MDQ6VXNlcjI0OTc3NTk2", + "gravatar_id": "", + "url": "https://api.github.com/users/6543", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "description": null, + "fork": false, + "url": "https://api.github.com/repos/6543/test_ci_tmp", + "created_at": "2025-07-29T19:35:41Z", + "updated_at": "2025-07-29T19:36:23Z", + "pushed_at": "2025-07-29T19:36:21Z", + "homepage": null, + "size": 3, + "stargazers_count": 0, + "watchers_count": 0, + "language": "Dockerfile", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "has_discussions": false, + "forks_count": 0, + "archived": false, + "disabled": false, + "open_issues_count": 1, + "license": null, + "allow_forking": true, + "is_template": false, + "web_commit_signoff_required": false, + "topics": [], + "visibility": "public", + "forks": 0, + "open_issues": 1, + "watchers": 0, + "default_branch": "main" + }, + "sender": { + "login": "6543", + "id": 24977596, + "node_id": "MDQ6VXNlcjI0OTc3NTk2", + "gravatar_id": "", + "url": "https://api.github.com/users/6543", + "type": "User", + "user_view_type": "public", + "site_admin": false + } +} diff --git a/server/forge/github/fixtures/HookPullRequestEdited.json b/server/forge/github/fixtures/HookPullRequestEdited.json new file mode 100644 index 00000000000..3b970194a1b --- /dev/null +++ b/server/forge/github/fixtures/HookPullRequestEdited.json @@ -0,0 +1,506 @@ +{ + "action": "edited", + "number": 62, + "pull_request": { + "url": "https://api.github.com/repos/anbraten/test-ready-release-go/pulls/62", + "id": 1630965956, + "node_id": "PR_kwDOIl-VNc5hNpDE", + "html_url": "https://github.com/anbraten/test-ready-release-go/pull/62", + "diff_url": "https://github.com/anbraten/test-ready-release-go/pull/62.diff", + "patch_url": "https://github.com/anbraten/test-ready-release-go/pull/62.patch", + "issue_url": "https://api.github.com/repos/anbraten/test-ready-release-go/issues/62", + "number": 62, + "state": "open", + "locked": false, + "title": "Change file", + "user": { + "login": "anbraten", + "id": 6918444, + "node_id": "MDQ6VXNlcjY5MTg0NDQ=", + "avatar_url": "https://avatars.githubusercontent.com/u/6918444?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/anbraten", + "html_url": "https://github.com/anbraten", + "followers_url": "https://api.github.com/users/anbraten/followers", + "following_url": "https://api.github.com/users/anbraten/following{/other_user}", + "gists_url": "https://api.github.com/users/anbraten/gists{/gist_id}", + "starred_url": "https://api.github.com/users/anbraten/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/anbraten/subscriptions", + "organizations_url": "https://api.github.com/users/anbraten/orgs", + "repos_url": "https://api.github.com/users/anbraten/repos", + "events_url": "https://api.github.com/users/anbraten/events{/privacy}", + "received_events_url": "https://api.github.com/users/anbraten/received_events", + "type": "User", + "site_admin": false + }, + "body": null, + "created_at": "2023-12-05T18:13:16Z", + "updated_at": "2023-12-05T18:14:13Z", + "closed_at": "2023-12-05T18:14:13Z", + "merged_at": null, + "merge_commit_sha": "79fd3b2a13c462ef9b3169b9dee9cb39605fda1b", + "assignee": null, + "assignees": [], + "requested_reviewers": [], + "requested_teams": [], + "labels": [], + "milestone": null, + "draft": false, + "commits_url": "https://api.github.com/repos/anbraten/test-ready-release-go/pulls/62/commits", + "review_comments_url": "https://api.github.com/repos/anbraten/test-ready-release-go/pulls/62/comments", + "review_comment_url": "https://api.github.com/repos/anbraten/test-ready-release-go/pulls/comments{/number}", + "comments_url": "https://api.github.com/repos/anbraten/test-ready-release-go/issues/62/comments", + "statuses_url": "https://api.github.com/repos/anbraten/test-ready-release-go/statuses/c88b9ee719285134957cbc698c9b7ef9b78007bf", + "head": { + "label": "anbraten:anbraten-patch-3", + "ref": "anbraten-patch-3", + "sha": "c88b9ee719285134957cbc698c9b7ef9b78007bf", + "user": { + "login": "anbraten", + "id": 6918444, + "node_id": "MDQ6VXNlcjY5MTg0NDQ=", + "avatar_url": "https://avatars.githubusercontent.com/u/6918444?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/anbraten", + "html_url": "https://github.com/anbraten", + "followers_url": "https://api.github.com/users/anbraten/followers", + "following_url": "https://api.github.com/users/anbraten/following{/other_user}", + "gists_url": "https://api.github.com/users/anbraten/gists{/gist_id}", + "starred_url": "https://api.github.com/users/anbraten/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/anbraten/subscriptions", + "organizations_url": "https://api.github.com/users/anbraten/orgs", + "repos_url": "https://api.github.com/users/anbraten/repos", + "events_url": "https://api.github.com/users/anbraten/events{/privacy}", + "received_events_url": "https://api.github.com/users/anbraten/received_events", + "type": "User", + "site_admin": false + }, + "repo": { + "id": 576689461, + "node_id": "R_kgDOIl-VNQ", + "name": "test-ready-release-go", + "full_name": "anbraten/test-ready-release-go", + "private": false, + "owner": { + "login": "anbraten", + "id": 6918444, + "node_id": "MDQ6VXNlcjY5MTg0NDQ=", + "avatar_url": "https://avatars.githubusercontent.com/u/6918444?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/anbraten", + "html_url": "https://github.com/anbraten", + "followers_url": "https://api.github.com/users/anbraten/followers", + "following_url": "https://api.github.com/users/anbraten/following{/other_user}", + "gists_url": "https://api.github.com/users/anbraten/gists{/gist_id}", + "starred_url": "https://api.github.com/users/anbraten/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/anbraten/subscriptions", + "organizations_url": "https://api.github.com/users/anbraten/orgs", + "repos_url": "https://api.github.com/users/anbraten/repos", + "events_url": "https://api.github.com/users/anbraten/events{/privacy}", + "received_events_url": "https://api.github.com/users/anbraten/received_events", + "type": "User", + "site_admin": false + }, + "html_url": "https://github.com/anbraten/test-ready-release-go", + "description": null, + "fork": false, + "url": "https://api.github.com/repos/anbraten/test-ready-release-go", + "forks_url": "https://api.github.com/repos/anbraten/test-ready-release-go/forks", + "keys_url": "https://api.github.com/repos/anbraten/test-ready-release-go/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/anbraten/test-ready-release-go/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/anbraten/test-ready-release-go/teams", + "hooks_url": "https://api.github.com/repos/anbraten/test-ready-release-go/hooks", + "issue_events_url": "https://api.github.com/repos/anbraten/test-ready-release-go/issues/events{/number}", + "events_url": "https://api.github.com/repos/anbraten/test-ready-release-go/events", + "assignees_url": "https://api.github.com/repos/anbraten/test-ready-release-go/assignees{/user}", + "branches_url": "https://api.github.com/repos/anbraten/test-ready-release-go/branches{/branch}", + "tags_url": "https://api.github.com/repos/anbraten/test-ready-release-go/tags", + "blobs_url": "https://api.github.com/repos/anbraten/test-ready-release-go/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/anbraten/test-ready-release-go/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/anbraten/test-ready-release-go/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/anbraten/test-ready-release-go/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/anbraten/test-ready-release-go/statuses/{sha}", + "languages_url": "https://api.github.com/repos/anbraten/test-ready-release-go/languages", + "stargazers_url": "https://api.github.com/repos/anbraten/test-ready-release-go/stargazers", + "contributors_url": "https://api.github.com/repos/anbraten/test-ready-release-go/contributors", + "subscribers_url": "https://api.github.com/repos/anbraten/test-ready-release-go/subscribers", + "subscription_url": "https://api.github.com/repos/anbraten/test-ready-release-go/subscription", + "commits_url": "https://api.github.com/repos/anbraten/test-ready-release-go/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/anbraten/test-ready-release-go/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/anbraten/test-ready-release-go/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/anbraten/test-ready-release-go/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/anbraten/test-ready-release-go/contents/{+path}", + "compare_url": "https://api.github.com/repos/anbraten/test-ready-release-go/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/anbraten/test-ready-release-go/merges", + "archive_url": "https://api.github.com/repos/anbraten/test-ready-release-go/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/anbraten/test-ready-release-go/downloads", + "issues_url": "https://api.github.com/repos/anbraten/test-ready-release-go/issues{/number}", + "pulls_url": "https://api.github.com/repos/anbraten/test-ready-release-go/pulls{/number}", + "milestones_url": "https://api.github.com/repos/anbraten/test-ready-release-go/milestones{/number}", + "notifications_url": "https://api.github.com/repos/anbraten/test-ready-release-go/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/anbraten/test-ready-release-go/labels{/name}", + "releases_url": "https://api.github.com/repos/anbraten/test-ready-release-go/releases{/id}", + "deployments_url": "https://api.github.com/repos/anbraten/test-ready-release-go/deployments", + "created_at": "2022-12-10T16:59:42Z", + "updated_at": "2023-07-11T17:00:26Z", + "pushed_at": "2023-12-05T18:13:17Z", + "git_url": "git://github.com/anbraten/test-ready-release-go.git", + "ssh_url": "git@github.com:anbraten/test-ready-release-go.git", + "clone_url": "https://github.com/anbraten/test-ready-release-go.git", + "svn_url": "https://github.com/anbraten/test-ready-release-go", + "homepage": null, + "size": 11198, + "stargazers_count": 0, + "watchers_count": 0, + "language": "Go", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "has_discussions": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 0, + "license": { + "key": "apache-2.0", + "name": "Apache License 2.0", + "spdx_id": "Apache-2.0", + "url": "https://api.github.com/licenses/apache-2.0", + "node_id": "MDc6TGljZW5zZTI=" + }, + "allow_forking": true, + "is_template": false, + "web_commit_signoff_required": false, + "topics": [], + "visibility": "public", + "forks": 0, + "open_issues": 0, + "watchers": 0, + "default_branch": "main", + "allow_squash_merge": true, + "allow_merge_commit": true, + "allow_rebase_merge": true, + "allow_auto_merge": false, + "delete_branch_on_merge": false, + "allow_update_branch": false, + "use_squash_pr_title_as_default": false, + "squash_merge_commit_message": "COMMIT_MESSAGES", + "squash_merge_commit_title": "COMMIT_OR_PR_TITLE", + "merge_commit_message": "PR_TITLE", + "merge_commit_title": "MERGE_MESSAGE" + } + }, + "base": { + "label": "anbraten:main", + "ref": "main", + "sha": "26fd46e0d1237cdabfe84ec6a0f37466fc716952", + "user": { + "login": "anbraten", + "id": 6918444, + "node_id": "MDQ6VXNlcjY5MTg0NDQ=", + "avatar_url": "https://avatars.githubusercontent.com/u/6918444?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/anbraten", + "html_url": "https://github.com/anbraten", + "followers_url": "https://api.github.com/users/anbraten/followers", + "following_url": "https://api.github.com/users/anbraten/following{/other_user}", + "gists_url": "https://api.github.com/users/anbraten/gists{/gist_id}", + "starred_url": "https://api.github.com/users/anbraten/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/anbraten/subscriptions", + "organizations_url": "https://api.github.com/users/anbraten/orgs", + "repos_url": "https://api.github.com/users/anbraten/repos", + "events_url": "https://api.github.com/users/anbraten/events{/privacy}", + "received_events_url": "https://api.github.com/users/anbraten/received_events", + "type": "User", + "site_admin": false + }, + "repo": { + "id": 576689461, + "node_id": "R_kgDOIl-VNQ", + "name": "test-ready-release-go", + "full_name": "anbraten/test-ready-release-go", + "private": false, + "owner": { + "login": "anbraten", + "id": 6918444, + "node_id": "MDQ6VXNlcjY5MTg0NDQ=", + "avatar_url": "https://avatars.githubusercontent.com/u/6918444?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/anbraten", + "html_url": "https://github.com/anbraten", + "followers_url": "https://api.github.com/users/anbraten/followers", + "following_url": "https://api.github.com/users/anbraten/following{/other_user}", + "gists_url": "https://api.github.com/users/anbraten/gists{/gist_id}", + "starred_url": "https://api.github.com/users/anbraten/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/anbraten/subscriptions", + "organizations_url": "https://api.github.com/users/anbraten/orgs", + "repos_url": "https://api.github.com/users/anbraten/repos", + "events_url": "https://api.github.com/users/anbraten/events{/privacy}", + "received_events_url": "https://api.github.com/users/anbraten/received_events", + "type": "User", + "site_admin": false + }, + "html_url": "https://github.com/anbraten/test-ready-release-go", + "description": null, + "fork": false, + "url": "https://api.github.com/repos/anbraten/test-ready-release-go", + "forks_url": "https://api.github.com/repos/anbraten/test-ready-release-go/forks", + "keys_url": "https://api.github.com/repos/anbraten/test-ready-release-go/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/anbraten/test-ready-release-go/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/anbraten/test-ready-release-go/teams", + "hooks_url": "https://api.github.com/repos/anbraten/test-ready-release-go/hooks", + "issue_events_url": "https://api.github.com/repos/anbraten/test-ready-release-go/issues/events{/number}", + "events_url": "https://api.github.com/repos/anbraten/test-ready-release-go/events", + "assignees_url": "https://api.github.com/repos/anbraten/test-ready-release-go/assignees{/user}", + "branches_url": "https://api.github.com/repos/anbraten/test-ready-release-go/branches{/branch}", + "tags_url": "https://api.github.com/repos/anbraten/test-ready-release-go/tags", + "blobs_url": "https://api.github.com/repos/anbraten/test-ready-release-go/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/anbraten/test-ready-release-go/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/anbraten/test-ready-release-go/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/anbraten/test-ready-release-go/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/anbraten/test-ready-release-go/statuses/{sha}", + "languages_url": "https://api.github.com/repos/anbraten/test-ready-release-go/languages", + "stargazers_url": "https://api.github.com/repos/anbraten/test-ready-release-go/stargazers", + "contributors_url": "https://api.github.com/repos/anbraten/test-ready-release-go/contributors", + "subscribers_url": "https://api.github.com/repos/anbraten/test-ready-release-go/subscribers", + "subscription_url": "https://api.github.com/repos/anbraten/test-ready-release-go/subscription", + "commits_url": "https://api.github.com/repos/anbraten/test-ready-release-go/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/anbraten/test-ready-release-go/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/anbraten/test-ready-release-go/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/anbraten/test-ready-release-go/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/anbraten/test-ready-release-go/contents/{+path}", + "compare_url": "https://api.github.com/repos/anbraten/test-ready-release-go/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/anbraten/test-ready-release-go/merges", + "archive_url": "https://api.github.com/repos/anbraten/test-ready-release-go/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/anbraten/test-ready-release-go/downloads", + "issues_url": "https://api.github.com/repos/anbraten/test-ready-release-go/issues{/number}", + "pulls_url": "https://api.github.com/repos/anbraten/test-ready-release-go/pulls{/number}", + "milestones_url": "https://api.github.com/repos/anbraten/test-ready-release-go/milestones{/number}", + "notifications_url": "https://api.github.com/repos/anbraten/test-ready-release-go/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/anbraten/test-ready-release-go/labels{/name}", + "releases_url": "https://api.github.com/repos/anbraten/test-ready-release-go/releases{/id}", + "deployments_url": "https://api.github.com/repos/anbraten/test-ready-release-go/deployments", + "created_at": "2022-12-10T16:59:42Z", + "updated_at": "2023-07-11T17:00:26Z", + "pushed_at": "2023-12-05T18:13:17Z", + "git_url": "git://github.com/anbraten/test-ready-release-go.git", + "ssh_url": "git@github.com:anbraten/test-ready-release-go.git", + "clone_url": "https://github.com/anbraten/test-ready-release-go.git", + "svn_url": "https://github.com/anbraten/test-ready-release-go", + "homepage": null, + "size": 11198, + "stargazers_count": 0, + "watchers_count": 0, + "language": "Go", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "has_discussions": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 0, + "license": { + "key": "apache-2.0", + "name": "Apache License 2.0", + "spdx_id": "Apache-2.0", + "url": "https://api.github.com/licenses/apache-2.0", + "node_id": "MDc6TGljZW5zZTI=" + }, + "allow_forking": true, + "is_template": false, + "web_commit_signoff_required": false, + "topics": [], + "visibility": "public", + "forks": 0, + "open_issues": 0, + "watchers": 0, + "default_branch": "main", + "allow_squash_merge": true, + "allow_merge_commit": true, + "allow_rebase_merge": true, + "allow_auto_merge": false, + "delete_branch_on_merge": false, + "allow_update_branch": false, + "use_squash_pr_title_as_default": false, + "squash_merge_commit_message": "COMMIT_MESSAGES", + "squash_merge_commit_title": "COMMIT_OR_PR_TITLE", + "merge_commit_message": "PR_TITLE", + "merge_commit_title": "MERGE_MESSAGE" + } + }, + "_links": { + "self": { + "href": "https://api.github.com/repos/anbraten/test-ready-release-go/pulls/62" + }, + "html": { + "href": "https://github.com/anbraten/test-ready-release-go/pull/62" + }, + "issue": { + "href": "https://api.github.com/repos/anbraten/test-ready-release-go/issues/62" + }, + "comments": { + "href": "https://api.github.com/repos/anbraten/test-ready-release-go/issues/62/comments" + }, + "review_comments": { + "href": "https://api.github.com/repos/anbraten/test-ready-release-go/pulls/62/comments" + }, + "review_comment": { + "href": "https://api.github.com/repos/anbraten/test-ready-release-go/pulls/comments{/number}" + }, + "commits": { + "href": "https://api.github.com/repos/anbraten/test-ready-release-go/pulls/62/commits" + }, + "statuses": { + "href": "https://api.github.com/repos/anbraten/test-ready-release-go/statuses/c88b9ee719285134957cbc698c9b7ef9b78007bf" + } + }, + "author_association": "OWNER", + "auto_merge": null, + "active_lock_reason": null, + "merged": false, + "mergeable": true, + "rebaseable": false, + "mergeable_state": "clean", + "merged_by": null, + "comments": 0, + "review_comments": 0, + "maintainer_can_modify": false, + "commits": 1, + "additions": 1, + "deletions": 0, + "changed_files": 1 + }, + "repository": { + "id": 576689461, + "node_id": "R_kgDOIl-VNQ", + "name": "test-ready-release-go", + "full_name": "anbraten/test-ready-release-go", + "private": false, + "owner": { + "login": "anbraten", + "id": 6918444, + "node_id": "MDQ6VXNlcjY5MTg0NDQ=", + "avatar_url": "https://avatars.githubusercontent.com/u/6918444?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/anbraten", + "html_url": "https://github.com/anbraten", + "followers_url": "https://api.github.com/users/anbraten/followers", + "following_url": "https://api.github.com/users/anbraten/following{/other_user}", + "gists_url": "https://api.github.com/users/anbraten/gists{/gist_id}", + "starred_url": "https://api.github.com/users/anbraten/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/anbraten/subscriptions", + "organizations_url": "https://api.github.com/users/anbraten/orgs", + "repos_url": "https://api.github.com/users/anbraten/repos", + "events_url": "https://api.github.com/users/anbraten/events{/privacy}", + "received_events_url": "https://api.github.com/users/anbraten/received_events", + "type": "User", + "site_admin": false + }, + "html_url": "https://github.com/anbraten/test-ready-release-go", + "description": null, + "fork": false, + "url": "https://api.github.com/repos/anbraten/test-ready-release-go", + "forks_url": "https://api.github.com/repos/anbraten/test-ready-release-go/forks", + "keys_url": "https://api.github.com/repos/anbraten/test-ready-release-go/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/anbraten/test-ready-release-go/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/anbraten/test-ready-release-go/teams", + "hooks_url": "https://api.github.com/repos/anbraten/test-ready-release-go/hooks", + "issue_events_url": "https://api.github.com/repos/anbraten/test-ready-release-go/issues/events{/number}", + "events_url": "https://api.github.com/repos/anbraten/test-ready-release-go/events", + "assignees_url": "https://api.github.com/repos/anbraten/test-ready-release-go/assignees{/user}", + "branches_url": "https://api.github.com/repos/anbraten/test-ready-release-go/branches{/branch}", + "tags_url": "https://api.github.com/repos/anbraten/test-ready-release-go/tags", + "blobs_url": "https://api.github.com/repos/anbraten/test-ready-release-go/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/anbraten/test-ready-release-go/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/anbraten/test-ready-release-go/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/anbraten/test-ready-release-go/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/anbraten/test-ready-release-go/statuses/{sha}", + "languages_url": "https://api.github.com/repos/anbraten/test-ready-release-go/languages", + "stargazers_url": "https://api.github.com/repos/anbraten/test-ready-release-go/stargazers", + "contributors_url": "https://api.github.com/repos/anbraten/test-ready-release-go/contributors", + "subscribers_url": "https://api.github.com/repos/anbraten/test-ready-release-go/subscribers", + "subscription_url": "https://api.github.com/repos/anbraten/test-ready-release-go/subscription", + "commits_url": "https://api.github.com/repos/anbraten/test-ready-release-go/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/anbraten/test-ready-release-go/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/anbraten/test-ready-release-go/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/anbraten/test-ready-release-go/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/anbraten/test-ready-release-go/contents/{+path}", + "compare_url": "https://api.github.com/repos/anbraten/test-ready-release-go/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/anbraten/test-ready-release-go/merges", + "archive_url": "https://api.github.com/repos/anbraten/test-ready-release-go/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/anbraten/test-ready-release-go/downloads", + "issues_url": "https://api.github.com/repos/anbraten/test-ready-release-go/issues{/number}", + "pulls_url": "https://api.github.com/repos/anbraten/test-ready-release-go/pulls{/number}", + "milestones_url": "https://api.github.com/repos/anbraten/test-ready-release-go/milestones{/number}", + "notifications_url": "https://api.github.com/repos/anbraten/test-ready-release-go/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/anbraten/test-ready-release-go/labels{/name}", + "releases_url": "https://api.github.com/repos/anbraten/test-ready-release-go/releases{/id}", + "deployments_url": "https://api.github.com/repos/anbraten/test-ready-release-go/deployments", + "created_at": "2022-12-10T16:59:42Z", + "updated_at": "2023-07-11T17:00:26Z", + "pushed_at": "2023-12-05T18:13:17Z", + "git_url": "git://github.com/anbraten/test-ready-release-go.git", + "ssh_url": "git@github.com:anbraten/test-ready-release-go.git", + "clone_url": "https://github.com/anbraten/test-ready-release-go.git", + "svn_url": "https://github.com/anbraten/test-ready-release-go", + "homepage": null, + "size": 11198, + "stargazers_count": 0, + "watchers_count": 0, + "language": "Go", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "has_discussions": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 0, + "license": { + "key": "apache-2.0", + "name": "Apache License 2.0", + "spdx_id": "Apache-2.0", + "url": "https://api.github.com/licenses/apache-2.0", + "node_id": "MDc6TGljZW5zZTI=" + }, + "allow_forking": true, + "is_template": false, + "web_commit_signoff_required": false, + "topics": [], + "visibility": "public", + "forks": 0, + "open_issues": 0, + "watchers": 0, + "default_branch": "main" + }, + "sender": { + "login": "anbraten", + "id": 6918444, + "node_id": "MDQ6VXNlcjY5MTg0NDQ=", + "avatar_url": "https://avatars.githubusercontent.com/u/6918444?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/anbraten", + "html_url": "https://github.com/anbraten", + "followers_url": "https://api.github.com/users/anbraten/followers", + "following_url": "https://api.github.com/users/anbraten/following{/other_user}", + "gists_url": "https://api.github.com/users/anbraten/gists{/gist_id}", + "starred_url": "https://api.github.com/users/anbraten/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/anbraten/subscriptions", + "organizations_url": "https://api.github.com/users/anbraten/orgs", + "repos_url": "https://api.github.com/users/anbraten/repos", + "events_url": "https://api.github.com/users/anbraten/events{/privacy}", + "received_events_url": "https://api.github.com/users/anbraten/received_events", + "type": "User", + "site_admin": false + } +} diff --git a/server/forge/github/fixtures/HookPullRequestLabelAdded.json b/server/forge/github/fixtures/HookPullRequestLabelAdded.json new file mode 100644 index 00000000000..1f4d00595e9 --- /dev/null +++ b/server/forge/github/fixtures/HookPullRequestLabelAdded.json @@ -0,0 +1,335 @@ +{ + "action": "labeled", + "number": 1, + "pull_request": { + "url": "https://api.github.com/repos/6543/test_ci_tmp/pulls/1", + "id": 2705176047, + "node_id": "PR_kwDOPU9UaM6hPbXv", + "number": 1, + "state": "open", + "locked": false, + "title": "Some ned more AAAA", + "user": { + "login": "6543", + "id": 24977596, + "node_id": "MDQ6VXNlcjI0OTc3NTk2", + "gravatar_id": "", + "url": "https://api.github.com/users/6543", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "body": "yeaaa", + "created_at": "2025-07-29T20:00:54Z", + "updated_at": "2025-07-29T23:46:36Z", + "closed_at": null, + "merged_at": null, + "merge_commit_sha": "b5fafd8b1c043723a38c99775bc807075bce9235", + "assignee": null, + "assignees": [], + "requested_reviewers": [], + "requested_teams": [], + "labels": [ + { + "id": 9024465376, + "node_id": "LA_kwDOPU9UaM8AAAACGeZp4A", + "url": "https://api.github.com/repos/6543/test_ci_tmp/labels/documentation", + "name": "documentation", + "color": "0075ca", + "default": true, + "description": "Improvements or additions to documentation" + }, + { + "id": 9024465382, + "node_id": "LA_kwDOPU9UaM8AAAACGeZp5g", + "url": "https://api.github.com/repos/6543/test_ci_tmp/labels/enhancement", + "name": "enhancement", + "color": "a2eeef", + "default": true, + "description": "New feature or request" + } + ], + "milestone": { + "url": "https://api.github.com/repos/6543/test_ci_tmp/milestones/2", + "id": 13392101, + "node_id": "MI_kwDOPU9UaM4AzFjl", + "number": 2, + "title": "open mile", + "description": "ongoing", + "creator": { + "login": "demoaccount2-commits", + "id": 223550959, + "node_id": "U_kgDODVMd7w", + "gravatar_id": "", + "url": "https://api.github.com/users/demoaccount2-commits", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "open_issues": 1, + "closed_issues": 0, + "state": "open", + "created_at": "2025-07-29T23:46:08Z", + "updated_at": "2025-07-29T23:46:29Z", + "due_on": null, + "closed_at": null + }, + "draft": false, + "head": { + "label": "6543:6543-patch-1", + "ref": "6543-patch-1", + "sha": "36b5813240a9d2daa29b05046d56a53e18f39a3e", + "user": { + "login": "6543", + "id": 24977596, + "node_id": "MDQ6VXNlcjI0OTc3NTk2", + "gravatar_id": "", + "url": "https://api.github.com/users/6543", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "repo": { + "id": 1028609128, + "node_id": "R_kgDOPU9UaA", + "name": "test_ci_tmp", + "full_name": "6543/test_ci_tmp", + "private": false, + "owner": { + "login": "6543", + "id": 24977596, + "node_id": "MDQ6VXNlcjI0OTc3NTk2", + "gravatar_id": "", + "url": "https://api.github.com/users/6543", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "description": null, + "fork": false, + "url": "https://api.github.com/repos/6543/test_ci_tmp", + "created_at": "2025-07-29T19:35:41Z", + "updated_at": "2025-07-29T19:36:23Z", + "pushed_at": "2025-07-29T19:36:21Z", + "homepage": null, + "size": 3, + "stargazers_count": 0, + "watchers_count": 0, + "language": "Dockerfile", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "has_discussions": false, + "forks_count": 0, + "archived": false, + "disabled": false, + "open_issues_count": 1, + "license": null, + "allow_forking": true, + "is_template": false, + "web_commit_signoff_required": false, + "topics": [], + "visibility": "public", + "forks": 0, + "open_issues": 1, + "watchers": 0, + "default_branch": "main", + "allow_squash_merge": true, + "allow_merge_commit": true, + "allow_rebase_merge": true, + "allow_auto_merge": false, + "delete_branch_on_merge": false, + "allow_update_branch": false, + "use_squash_pr_title_as_default": false, + "squash_merge_commit_message": "COMMIT_MESSAGES", + "squash_merge_commit_title": "COMMIT_OR_PR_TITLE", + "merge_commit_message": "PR_TITLE", + "merge_commit_title": "MERGE_MESSAGE" + } + }, + "base": { + "label": "6543:main", + "ref": "main", + "sha": "67012991d6c69b1c58378346fca366b864d8d1a1", + "user": { + "login": "6543", + "id": 24977596, + "node_id": "MDQ6VXNlcjI0OTc3NTk2", + "gravatar_id": "", + "url": "https://api.github.com/users/6543", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "repo": { + "id": 1028609128, + "node_id": "R_kgDOPU9UaA", + "name": "test_ci_tmp", + "full_name": "6543/test_ci_tmp", + "private": false, + "owner": { + "login": "6543", + "id": 24977596, + "node_id": "MDQ6VXNlcjI0OTc3NTk2", + "gravatar_id": "", + "url": "https://api.github.com/users/6543", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "description": null, + "fork": false, + "url": "https://api.github.com/repos/6543/test_ci_tmp", + "created_at": "2025-07-29T19:35:41Z", + "updated_at": "2025-07-29T19:36:23Z", + "pushed_at": "2025-07-29T19:36:21Z", + "homepage": null, + "size": 3, + "stargazers_count": 0, + "watchers_count": 0, + "language": "Dockerfile", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "has_discussions": false, + "forks_count": 0, + "archived": false, + "disabled": false, + "open_issues_count": 1, + "license": null, + "allow_forking": true, + "is_template": false, + "web_commit_signoff_required": false, + "topics": [], + "visibility": "public", + "forks": 0, + "open_issues": 1, + "watchers": 0, + "default_branch": "main", + "allow_squash_merge": true, + "allow_merge_commit": true, + "allow_rebase_merge": true, + "allow_auto_merge": false, + "delete_branch_on_merge": false, + "allow_update_branch": false, + "use_squash_pr_title_as_default": false, + "squash_merge_commit_message": "COMMIT_MESSAGES", + "squash_merge_commit_title": "COMMIT_OR_PR_TITLE", + "merge_commit_message": "PR_TITLE", + "merge_commit_title": "MERGE_MESSAGE" + } + }, + "_links": { + "self": { + "href": "https://api.github.com/repos/6543/test_ci_tmp/pulls/1" + }, + "html": { + "href": "https://github.com/6543/test_ci_tmp/pull/1" + }, + "issue": { + "href": "https://api.github.com/repos/6543/test_ci_tmp/issues/1" + }, + "comments": { + "href": "https://api.github.com/repos/6543/test_ci_tmp/issues/1/comments" + }, + "review_comments": { + "href": "https://api.github.com/repos/6543/test_ci_tmp/pulls/1/comments" + }, + "review_comment": { + "href": "https://api.github.com/repos/6543/test_ci_tmp/pulls/comments{/number}" + }, + "commits": { + "href": "https://api.github.com/repos/6543/test_ci_tmp/pulls/1/commits" + }, + "statuses": { + "href": "https://api.github.com/repos/6543/test_ci_tmp/statuses/36b5813240a9d2daa29b05046d56a53e18f39a3e" + } + }, + "author_association": "OWNER", + "auto_merge": null, + "active_lock_reason": null, + "merged": false, + "mergeable": true, + "rebaseable": true, + "mergeable_state": "unstable", + "merged_by": null, + "comments": 0, + "review_comments": 0, + "maintainer_can_modify": false, + "commits": 1, + "additions": 1, + "deletions": 0, + "changed_files": 1 + }, + "label": { + "id": 9024465376, + "node_id": "LA_kwDOPU9UaM8AAAACGeZp4A", + "url": "https://api.github.com/repos/6543/test_ci_tmp/labels/documentation", + "name": "documentation", + "color": "0075ca", + "default": true, + "description": "Improvements or additions to documentation" + }, + "repository": { + "id": 1028609128, + "node_id": "R_kgDOPU9UaA", + "name": "test_ci_tmp", + "full_name": "6543/test_ci_tmp", + "private": false, + "owner": { + "login": "6543", + "id": 24977596, + "node_id": "MDQ6VXNlcjI0OTc3NTk2", + "gravatar_id": "", + "url": "https://api.github.com/users/6543", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "description": null, + "fork": false, + "url": "https://api.github.com/repos/6543/test_ci_tmp", + "created_at": "2025-07-29T19:35:41Z", + "updated_at": "2025-07-29T19:36:23Z", + "pushed_at": "2025-07-29T19:36:21Z", + "homepage": null, + "size": 3, + "stargazers_count": 0, + "watchers_count": 0, + "language": "Dockerfile", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "has_discussions": false, + "forks_count": 0, + "archived": false, + "disabled": false, + "open_issues_count": 1, + "license": null, + "allow_forking": true, + "is_template": false, + "web_commit_signoff_required": false, + "topics": [], + "visibility": "public", + "forks": 0, + "open_issues": 1, + "watchers": 0, + "default_branch": "main" + }, + "sender": { + "login": "demoaccount2-commits", + "id": 223550959, + "node_id": "U_kgDODVMd7w", + "gravatar_id": "", + "url": "https://api.github.com/users/demoaccount2-commits", + "type": "User", + "user_view_type": "public", + "site_admin": false + } +} diff --git a/server/forge/github/fixtures/HookPullRequestLabelRemoved.json b/server/forge/github/fixtures/HookPullRequestLabelRemoved.json new file mode 100644 index 00000000000..0851b283d48 --- /dev/null +++ b/server/forge/github/fixtures/HookPullRequestLabelRemoved.json @@ -0,0 +1,326 @@ +{ + "action": "unlabeled", + "number": 1, + "pull_request": { + "url": "https://api.github.com/repos/6543/test_ci_tmp/pulls/1", + "id": 2705176047, + "node_id": "PR_kwDOPU9UaM6hPbXv", + "number": 1, + "state": "open", + "locked": false, + "title": "Some ned more AAAA", + "user": { + "login": "6543", + "id": 24977596, + "node_id": "MDQ6VXNlcjI0OTc3NTk2", + "gravatar_id": "", + "url": "https://api.github.com/users/6543", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "body": "yeaaa", + "created_at": "2025-07-29T20:00:54Z", + "updated_at": "2025-07-29T23:54:55Z", + "closed_at": null, + "merged_at": null, + "merge_commit_sha": "b5fafd8b1c043723a38c99775bc807075bce9235", + "assignee": null, + "assignees": [], + "requested_reviewers": [], + "requested_teams": [], + "labels": [ + { + "id": 9024465370, + "node_id": "LA_kwDOPU9UaM8AAAACGeZp2g", + "url": "https://api.github.com/repos/6543/test_ci_tmp/labels/bug", + "name": "bug", + "color": "d73a4a", + "default": true, + "description": "Something isn't working" + } + ], + "milestone": { + "url": "https://api.github.com/repos/6543/test_ci_tmp/milestones/2", + "id": 13392101, + "node_id": "MI_kwDOPU9UaM4AzFjl", + "number": 2, + "title": "open mile", + "description": "ongoing", + "creator": { + "login": "demoaccount2-commits", + "id": 223550959, + "node_id": "U_kgDODVMd7w", + "gravatar_id": "", + "url": "https://api.github.com/users/demoaccount2-commits", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "open_issues": 1, + "closed_issues": 0, + "state": "open", + "created_at": "2025-07-29T23:46:08Z", + "updated_at": "2025-07-29T23:46:29Z", + "due_on": null, + "closed_at": null + }, + "draft": false, + "head": { + "label": "6543:6543-patch-1", + "ref": "6543-patch-1", + "sha": "36b5813240a9d2daa29b05046d56a53e18f39a3e", + "user": { + "login": "6543", + "id": 24977596, + "node_id": "MDQ6VXNlcjI0OTc3NTk2", + "gravatar_id": "", + "url": "https://api.github.com/users/6543", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "repo": { + "id": 1028609128, + "node_id": "R_kgDOPU9UaA", + "name": "test_ci_tmp", + "full_name": "6543/test_ci_tmp", + "private": false, + "owner": { + "login": "6543", + "id": 24977596, + "node_id": "MDQ6VXNlcjI0OTc3NTk2", + "gravatar_id": "", + "url": "https://api.github.com/users/6543", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "description": null, + "fork": false, + "url": "https://api.github.com/repos/6543/test_ci_tmp", + "created_at": "2025-07-29T19:35:41Z", + "updated_at": "2025-07-29T19:36:23Z", + "pushed_at": "2025-07-29T19:36:21Z", + "homepage": null, + "size": 3, + "stargazers_count": 0, + "watchers_count": 0, + "language": "Dockerfile", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "has_discussions": false, + "forks_count": 0, + "archived": false, + "disabled": false, + "open_issues_count": 1, + "license": null, + "allow_forking": true, + "is_template": false, + "web_commit_signoff_required": false, + "topics": [], + "visibility": "public", + "forks": 0, + "open_issues": 1, + "watchers": 0, + "default_branch": "main", + "allow_squash_merge": true, + "allow_merge_commit": true, + "allow_rebase_merge": true, + "allow_auto_merge": false, + "delete_branch_on_merge": false, + "allow_update_branch": false, + "use_squash_pr_title_as_default": false, + "squash_merge_commit_message": "COMMIT_MESSAGES", + "squash_merge_commit_title": "COMMIT_OR_PR_TITLE", + "merge_commit_message": "PR_TITLE", + "merge_commit_title": "MERGE_MESSAGE" + } + }, + "base": { + "label": "6543:main", + "ref": "main", + "sha": "67012991d6c69b1c58378346fca366b864d8d1a1", + "user": { + "login": "6543", + "id": 24977596, + "node_id": "MDQ6VXNlcjI0OTc3NTk2", + "gravatar_id": "", + "url": "https://api.github.com/users/6543", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "repo": { + "id": 1028609128, + "node_id": "R_kgDOPU9UaA", + "name": "test_ci_tmp", + "full_name": "6543/test_ci_tmp", + "private": false, + "owner": { + "login": "6543", + "id": 24977596, + "node_id": "MDQ6VXNlcjI0OTc3NTk2", + "gravatar_id": "", + "url": "https://api.github.com/users/6543", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "description": null, + "fork": false, + "url": "https://api.github.com/repos/6543/test_ci_tmp", + "created_at": "2025-07-29T19:35:41Z", + "updated_at": "2025-07-29T19:36:23Z", + "pushed_at": "2025-07-29T19:36:21Z", + "homepage": null, + "size": 3, + "stargazers_count": 0, + "watchers_count": 0, + "language": "Dockerfile", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "has_discussions": false, + "forks_count": 0, + "archived": false, + "disabled": false, + "open_issues_count": 1, + "license": null, + "allow_forking": true, + "is_template": false, + "web_commit_signoff_required": false, + "topics": [], + "visibility": "public", + "forks": 0, + "open_issues": 1, + "watchers": 0, + "default_branch": "main", + "allow_squash_merge": true, + "allow_merge_commit": true, + "allow_rebase_merge": true, + "allow_auto_merge": false, + "delete_branch_on_merge": false, + "allow_update_branch": false, + "use_squash_pr_title_as_default": false, + "squash_merge_commit_message": "COMMIT_MESSAGES", + "squash_merge_commit_title": "COMMIT_OR_PR_TITLE", + "merge_commit_message": "PR_TITLE", + "merge_commit_title": "MERGE_MESSAGE" + } + }, + "_links": { + "self": { + "href": "https://api.github.com/repos/6543/test_ci_tmp/pulls/1" + }, + "html": { + "href": "https://github.com/6543/test_ci_tmp/pull/1" + }, + "issue": { + "href": "https://api.github.com/repos/6543/test_ci_tmp/issues/1" + }, + "comments": { + "href": "https://api.github.com/repos/6543/test_ci_tmp/issues/1/comments" + }, + "review_comments": { + "href": "https://api.github.com/repos/6543/test_ci_tmp/pulls/1/comments" + }, + "review_comment": { + "href": "https://api.github.com/repos/6543/test_ci_tmp/pulls/comments{/number}" + }, + "commits": { + "href": "https://api.github.com/repos/6543/test_ci_tmp/pulls/1/commits" + }, + "statuses": { + "href": "https://api.github.com/repos/6543/test_ci_tmp/statuses/36b5813240a9d2daa29b05046d56a53e18f39a3e" + } + }, + "author_association": "OWNER", + "auto_merge": null, + "active_lock_reason": null, + "merged": false, + "mergeable": true, + "rebaseable": true, + "mergeable_state": "unstable", + "merged_by": null, + "comments": 0, + "review_comments": 0, + "maintainer_can_modify": false, + "commits": 1, + "additions": 1, + "deletions": 0, + "changed_files": 1 + }, + "label": { + "id": 9024465380, + "node_id": "LA_kwDOPU9UaM8AAAACGeZp5A", + "url": "https://api.github.com/repos/6543/test_ci_tmp/labels/duplicate", + "name": "duplicate", + "color": "cfd3d7", + "default": true, + "description": "This issue or pull request already exists" + }, + "repository": { + "id": 1028609128, + "node_id": "R_kgDOPU9UaA", + "name": "test_ci_tmp", + "full_name": "6543/test_ci_tmp", + "private": false, + "owner": { + "login": "6543", + "id": 24977596, + "node_id": "MDQ6VXNlcjI0OTc3NTk2", + "gravatar_id": "", + "url": "https://api.github.com/users/6543", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "description": null, + "fork": false, + "url": "https://api.github.com/repos/6543/test_ci_tmp", + "created_at": "2025-07-29T19:35:41Z", + "updated_at": "2025-07-29T19:36:23Z", + "pushed_at": "2025-07-29T19:36:21Z", + "homepage": null, + "size": 3, + "stargazers_count": 0, + "watchers_count": 0, + "language": "Dockerfile", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "has_discussions": false, + "forks_count": 0, + "archived": false, + "disabled": false, + "open_issues_count": 1, + "license": null, + "allow_forking": true, + "is_template": false, + "web_commit_signoff_required": false, + "topics": [], + "visibility": "public", + "forks": 0, + "open_issues": 1, + "watchers": 0, + "default_branch": "main" + }, + "sender": { + "login": "demoaccount2-commits", + "id": 223550959, + "node_id": "U_kgDODVMd7w", + "gravatar_id": "", + "url": "https://api.github.com/users/demoaccount2-commits", + "type": "User", + "user_view_type": "public", + "site_admin": false + } +} diff --git a/server/forge/github/fixtures/HookPullRequestLabelsCleared.json b/server/forge/github/fixtures/HookPullRequestLabelsCleared.json new file mode 100644 index 00000000000..e8347e4e145 --- /dev/null +++ b/server/forge/github/fixtures/HookPullRequestLabelsCleared.json @@ -0,0 +1,504 @@ +{ + "action": "unlabeled", + "number": 1, + "pull_request": { + "url": "https://api.github.com/repos/6543/test_ci_tmp/pulls/1", + "id": 2705176047, + "node_id": "PR_kwDOPU9UaM6hPbXv", + "html_url": "https://github.com/6543/test_ci_tmp/pull/1", + "diff_url": "https://github.com/6543/test_ci_tmp/pull/1.diff", + "patch_url": "https://github.com/6543/test_ci_tmp/pull/1.patch", + "issue_url": "https://api.github.com/repos/6543/test_ci_tmp/issues/1", + "number": 1, + "state": "open", + "locked": false, + "title": "Some ned more AAAA", + "user": { + "login": "6543", + "id": 24977596, + "node_id": "MDQ6VXNlcjI0OTc3NTk2", + "avatar_url": "https://avatars.githubusercontent.com/u/24977596?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/6543", + "html_url": "https://github.com/6543", + "followers_url": "https://api.github.com/users/6543/followers", + "following_url": "https://api.github.com/users/6543/following{/other_user}", + "gists_url": "https://api.github.com/users/6543/gists{/gist_id}", + "starred_url": "https://api.github.com/users/6543/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/6543/subscriptions", + "organizations_url": "https://api.github.com/users/6543/orgs", + "repos_url": "https://api.github.com/users/6543/repos", + "events_url": "https://api.github.com/users/6543/events{/privacy}", + "received_events_url": "https://api.github.com/users/6543/received_events", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "body": "yeaaa", + "created_at": "2025-07-29T20:00:54Z", + "updated_at": "2025-09-22T12:34:38Z", + "closed_at": null, + "merged_at": null, + "merge_commit_sha": "c449d9571e3cfabc9ee42cc6725196497e16151a", + "assignee": null, + "assignees": [], + "requested_reviewers": [], + "requested_teams": [], + "labels": [], + "milestone": null, + "draft": false, + "commits_url": "https://api.github.com/repos/6543/test_ci_tmp/pulls/1/commits", + "review_comments_url": "https://api.github.com/repos/6543/test_ci_tmp/pulls/1/comments", + "review_comment_url": "https://api.github.com/repos/6543/test_ci_tmp/pulls/comments{/number}", + "comments_url": "https://api.github.com/repos/6543/test_ci_tmp/issues/1/comments", + "statuses_url": "https://api.github.com/repos/6543/test_ci_tmp/statuses/36b5813240a9d2daa29b05046d56a53e18f39a3e", + "head": { + "label": "6543:6543-patch-1", + "ref": "6543-patch-1", + "sha": "36b5813240a9d2daa29b05046d56a53e18f39a3e", + "user": { + "login": "6543", + "id": 24977596, + "node_id": "MDQ6VXNlcjI0OTc3NTk2", + "avatar_url": "https://avatars.githubusercontent.com/u/24977596?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/6543", + "html_url": "https://github.com/6543", + "followers_url": "https://api.github.com/users/6543/followers", + "following_url": "https://api.github.com/users/6543/following{/other_user}", + "gists_url": "https://api.github.com/users/6543/gists{/gist_id}", + "starred_url": "https://api.github.com/users/6543/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/6543/subscriptions", + "organizations_url": "https://api.github.com/users/6543/orgs", + "repos_url": "https://api.github.com/users/6543/repos", + "events_url": "https://api.github.com/users/6543/events{/privacy}", + "received_events_url": "https://api.github.com/users/6543/received_events", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "repo": { + "id": 1028609128, + "node_id": "R_kgDOPU9UaA", + "name": "test_ci_tmp", + "full_name": "6543/test_ci_tmp", + "private": false, + "owner": { + "login": "6543", + "id": 24977596, + "node_id": "MDQ6VXNlcjI0OTc3NTk2", + "avatar_url": "https://avatars.githubusercontent.com/u/24977596?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/6543", + "html_url": "https://github.com/6543", + "followers_url": "https://api.github.com/users/6543/followers", + "following_url": "https://api.github.com/users/6543/following{/other_user}", + "gists_url": "https://api.github.com/users/6543/gists{/gist_id}", + "starred_url": "https://api.github.com/users/6543/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/6543/subscriptions", + "organizations_url": "https://api.github.com/users/6543/orgs", + "repos_url": "https://api.github.com/users/6543/repos", + "events_url": "https://api.github.com/users/6543/events{/privacy}", + "received_events_url": "https://api.github.com/users/6543/received_events", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "html_url": "https://github.com/6543/test_ci_tmp", + "description": null, + "fork": false, + "url": "https://api.github.com/repos/6543/test_ci_tmp", + "forks_url": "https://api.github.com/repos/6543/test_ci_tmp/forks", + "keys_url": "https://api.github.com/repos/6543/test_ci_tmp/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/6543/test_ci_tmp/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/6543/test_ci_tmp/teams", + "hooks_url": "https://api.github.com/repos/6543/test_ci_tmp/hooks", + "issue_events_url": "https://api.github.com/repos/6543/test_ci_tmp/issues/events{/number}", + "events_url": "https://api.github.com/repos/6543/test_ci_tmp/events", + "assignees_url": "https://api.github.com/repos/6543/test_ci_tmp/assignees{/user}", + "branches_url": "https://api.github.com/repos/6543/test_ci_tmp/branches{/branch}", + "tags_url": "https://api.github.com/repos/6543/test_ci_tmp/tags", + "blobs_url": "https://api.github.com/repos/6543/test_ci_tmp/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/6543/test_ci_tmp/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/6543/test_ci_tmp/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/6543/test_ci_tmp/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/6543/test_ci_tmp/statuses/{sha}", + "languages_url": "https://api.github.com/repos/6543/test_ci_tmp/languages", + "stargazers_url": "https://api.github.com/repos/6543/test_ci_tmp/stargazers", + "contributors_url": "https://api.github.com/repos/6543/test_ci_tmp/contributors", + "subscribers_url": "https://api.github.com/repos/6543/test_ci_tmp/subscribers", + "subscription_url": "https://api.github.com/repos/6543/test_ci_tmp/subscription", + "commits_url": "https://api.github.com/repos/6543/test_ci_tmp/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/6543/test_ci_tmp/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/6543/test_ci_tmp/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/6543/test_ci_tmp/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/6543/test_ci_tmp/contents/{+path}", + "compare_url": "https://api.github.com/repos/6543/test_ci_tmp/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/6543/test_ci_tmp/merges", + "archive_url": "https://api.github.com/repos/6543/test_ci_tmp/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/6543/test_ci_tmp/downloads", + "issues_url": "https://api.github.com/repos/6543/test_ci_tmp/issues{/number}", + "pulls_url": "https://api.github.com/repos/6543/test_ci_tmp/pulls{/number}", + "milestones_url": "https://api.github.com/repos/6543/test_ci_tmp/milestones{/number}", + "notifications_url": "https://api.github.com/repos/6543/test_ci_tmp/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/6543/test_ci_tmp/labels{/name}", + "releases_url": "https://api.github.com/repos/6543/test_ci_tmp/releases{/id}", + "deployments_url": "https://api.github.com/repos/6543/test_ci_tmp/deployments", + "created_at": "2025-07-29T19:35:41Z", + "updated_at": "2025-07-29T19:36:23Z", + "pushed_at": "2025-07-29T19:36:21Z", + "git_url": "git://github.com/6543/test_ci_tmp.git", + "ssh_url": "git@github.com:6543/test_ci_tmp.git", + "clone_url": "https://github.com/6543/test_ci_tmp.git", + "svn_url": "https://github.com/6543/test_ci_tmp", + "homepage": null, + "size": 3, + "stargazers_count": 0, + "watchers_count": 0, + "language": "Dockerfile", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "has_discussions": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 1, + "license": null, + "allow_forking": true, + "is_template": false, + "web_commit_signoff_required": false, + "topics": [], + "visibility": "public", + "forks": 0, + "open_issues": 1, + "watchers": 0, + "default_branch": "main", + "allow_squash_merge": true, + "allow_merge_commit": true, + "allow_rebase_merge": true, + "allow_auto_merge": false, + "delete_branch_on_merge": false, + "allow_update_branch": false, + "use_squash_pr_title_as_default": false, + "squash_merge_commit_message": "COMMIT_MESSAGES", + "squash_merge_commit_title": "COMMIT_OR_PR_TITLE", + "merge_commit_message": "PR_TITLE", + "merge_commit_title": "MERGE_MESSAGE" + } + }, + "base": { + "label": "6543:main", + "ref": "main", + "sha": "67012991d6c69b1c58378346fca366b864d8d1a1", + "user": { + "login": "6543", + "id": 24977596, + "node_id": "MDQ6VXNlcjI0OTc3NTk2", + "avatar_url": "https://avatars.githubusercontent.com/u/24977596?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/6543", + "html_url": "https://github.com/6543", + "followers_url": "https://api.github.com/users/6543/followers", + "following_url": "https://api.github.com/users/6543/following{/other_user}", + "gists_url": "https://api.github.com/users/6543/gists{/gist_id}", + "starred_url": "https://api.github.com/users/6543/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/6543/subscriptions", + "organizations_url": "https://api.github.com/users/6543/orgs", + "repos_url": "https://api.github.com/users/6543/repos", + "events_url": "https://api.github.com/users/6543/events{/privacy}", + "received_events_url": "https://api.github.com/users/6543/received_events", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "repo": { + "id": 1028609128, + "node_id": "R_kgDOPU9UaA", + "name": "test_ci_tmp", + "full_name": "6543/test_ci_tmp", + "private": false, + "owner": { + "login": "6543", + "id": 24977596, + "node_id": "MDQ6VXNlcjI0OTc3NTk2", + "avatar_url": "https://avatars.githubusercontent.com/u/24977596?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/6543", + "html_url": "https://github.com/6543", + "followers_url": "https://api.github.com/users/6543/followers", + "following_url": "https://api.github.com/users/6543/following{/other_user}", + "gists_url": "https://api.github.com/users/6543/gists{/gist_id}", + "starred_url": "https://api.github.com/users/6543/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/6543/subscriptions", + "organizations_url": "https://api.github.com/users/6543/orgs", + "repos_url": "https://api.github.com/users/6543/repos", + "events_url": "https://api.github.com/users/6543/events{/privacy}", + "received_events_url": "https://api.github.com/users/6543/received_events", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "html_url": "https://github.com/6543/test_ci_tmp", + "description": null, + "fork": false, + "url": "https://api.github.com/repos/6543/test_ci_tmp", + "forks_url": "https://api.github.com/repos/6543/test_ci_tmp/forks", + "keys_url": "https://api.github.com/repos/6543/test_ci_tmp/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/6543/test_ci_tmp/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/6543/test_ci_tmp/teams", + "hooks_url": "https://api.github.com/repos/6543/test_ci_tmp/hooks", + "issue_events_url": "https://api.github.com/repos/6543/test_ci_tmp/issues/events{/number}", + "events_url": "https://api.github.com/repos/6543/test_ci_tmp/events", + "assignees_url": "https://api.github.com/repos/6543/test_ci_tmp/assignees{/user}", + "branches_url": "https://api.github.com/repos/6543/test_ci_tmp/branches{/branch}", + "tags_url": "https://api.github.com/repos/6543/test_ci_tmp/tags", + "blobs_url": "https://api.github.com/repos/6543/test_ci_tmp/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/6543/test_ci_tmp/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/6543/test_ci_tmp/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/6543/test_ci_tmp/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/6543/test_ci_tmp/statuses/{sha}", + "languages_url": "https://api.github.com/repos/6543/test_ci_tmp/languages", + "stargazers_url": "https://api.github.com/repos/6543/test_ci_tmp/stargazers", + "contributors_url": "https://api.github.com/repos/6543/test_ci_tmp/contributors", + "subscribers_url": "https://api.github.com/repos/6543/test_ci_tmp/subscribers", + "subscription_url": "https://api.github.com/repos/6543/test_ci_tmp/subscription", + "commits_url": "https://api.github.com/repos/6543/test_ci_tmp/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/6543/test_ci_tmp/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/6543/test_ci_tmp/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/6543/test_ci_tmp/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/6543/test_ci_tmp/contents/{+path}", + "compare_url": "https://api.github.com/repos/6543/test_ci_tmp/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/6543/test_ci_tmp/merges", + "archive_url": "https://api.github.com/repos/6543/test_ci_tmp/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/6543/test_ci_tmp/downloads", + "issues_url": "https://api.github.com/repos/6543/test_ci_tmp/issues{/number}", + "pulls_url": "https://api.github.com/repos/6543/test_ci_tmp/pulls{/number}", + "milestones_url": "https://api.github.com/repos/6543/test_ci_tmp/milestones{/number}", + "notifications_url": "https://api.github.com/repos/6543/test_ci_tmp/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/6543/test_ci_tmp/labels{/name}", + "releases_url": "https://api.github.com/repos/6543/test_ci_tmp/releases{/id}", + "deployments_url": "https://api.github.com/repos/6543/test_ci_tmp/deployments", + "created_at": "2025-07-29T19:35:41Z", + "updated_at": "2025-07-29T19:36:23Z", + "pushed_at": "2025-07-29T19:36:21Z", + "git_url": "git://github.com/6543/test_ci_tmp.git", + "ssh_url": "git@github.com:6543/test_ci_tmp.git", + "clone_url": "https://github.com/6543/test_ci_tmp.git", + "svn_url": "https://github.com/6543/test_ci_tmp", + "homepage": null, + "size": 3, + "stargazers_count": 0, + "watchers_count": 0, + "language": "Dockerfile", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "has_discussions": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 1, + "license": null, + "allow_forking": true, + "is_template": false, + "web_commit_signoff_required": false, + "topics": [], + "visibility": "public", + "forks": 0, + "open_issues": 1, + "watchers": 0, + "default_branch": "main", + "allow_squash_merge": true, + "allow_merge_commit": true, + "allow_rebase_merge": true, + "allow_auto_merge": false, + "delete_branch_on_merge": false, + "allow_update_branch": false, + "use_squash_pr_title_as_default": false, + "squash_merge_commit_message": "COMMIT_MESSAGES", + "squash_merge_commit_title": "COMMIT_OR_PR_TITLE", + "merge_commit_message": "PR_TITLE", + "merge_commit_title": "MERGE_MESSAGE" + } + }, + "_links": { + "self": { + "href": "https://api.github.com/repos/6543/test_ci_tmp/pulls/1" + }, + "html": { + "href": "https://github.com/6543/test_ci_tmp/pull/1" + }, + "issue": { + "href": "https://api.github.com/repos/6543/test_ci_tmp/issues/1" + }, + "comments": { + "href": "https://api.github.com/repos/6543/test_ci_tmp/issues/1/comments" + }, + "review_comments": { + "href": "https://api.github.com/repos/6543/test_ci_tmp/pulls/1/comments" + }, + "review_comment": { + "href": "https://api.github.com/repos/6543/test_ci_tmp/pulls/comments{/number}" + }, + "commits": { + "href": "https://api.github.com/repos/6543/test_ci_tmp/pulls/1/commits" + }, + "statuses": { + "href": "https://api.github.com/repos/6543/test_ci_tmp/statuses/36b5813240a9d2daa29b05046d56a53e18f39a3e" + } + }, + "author_association": "OWNER", + "auto_merge": null, + "active_lock_reason": null, + "merged": false, + "mergeable": true, + "rebaseable": true, + "mergeable_state": "unstable", + "merged_by": null, + "comments": 0, + "review_comments": 0, + "maintainer_can_modify": false, + "commits": 1, + "additions": 1, + "deletions": 0, + "changed_files": 1 + }, + "label": { + "id": 9024465382, + "node_id": "LA_kwDOPU9UaM8AAAACGeZp5g", + "url": "https://api.github.com/repos/6543/test_ci_tmp/labels/enhancement", + "name": "enhancement", + "color": "a2eeef", + "default": true, + "description": "New feature or request" + }, + "repository": { + "id": 1028609128, + "node_id": "R_kgDOPU9UaA", + "name": "test_ci_tmp", + "full_name": "6543/test_ci_tmp", + "private": false, + "owner": { + "login": "6543", + "id": 24977596, + "node_id": "MDQ6VXNlcjI0OTc3NTk2", + "avatar_url": "https://avatars.githubusercontent.com/u/24977596?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/6543", + "html_url": "https://github.com/6543", + "followers_url": "https://api.github.com/users/6543/followers", + "following_url": "https://api.github.com/users/6543/following{/other_user}", + "gists_url": "https://api.github.com/users/6543/gists{/gist_id}", + "starred_url": "https://api.github.com/users/6543/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/6543/subscriptions", + "organizations_url": "https://api.github.com/users/6543/orgs", + "repos_url": "https://api.github.com/users/6543/repos", + "events_url": "https://api.github.com/users/6543/events{/privacy}", + "received_events_url": "https://api.github.com/users/6543/received_events", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "html_url": "https://github.com/6543/test_ci_tmp", + "description": null, + "fork": false, + "url": "https://api.github.com/repos/6543/test_ci_tmp", + "forks_url": "https://api.github.com/repos/6543/test_ci_tmp/forks", + "keys_url": "https://api.github.com/repos/6543/test_ci_tmp/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/6543/test_ci_tmp/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/6543/test_ci_tmp/teams", + "hooks_url": "https://api.github.com/repos/6543/test_ci_tmp/hooks", + "issue_events_url": "https://api.github.com/repos/6543/test_ci_tmp/issues/events{/number}", + "events_url": "https://api.github.com/repos/6543/test_ci_tmp/events", + "assignees_url": "https://api.github.com/repos/6543/test_ci_tmp/assignees{/user}", + "branches_url": "https://api.github.com/repos/6543/test_ci_tmp/branches{/branch}", + "tags_url": "https://api.github.com/repos/6543/test_ci_tmp/tags", + "blobs_url": "https://api.github.com/repos/6543/test_ci_tmp/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/6543/test_ci_tmp/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/6543/test_ci_tmp/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/6543/test_ci_tmp/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/6543/test_ci_tmp/statuses/{sha}", + "languages_url": "https://api.github.com/repos/6543/test_ci_tmp/languages", + "stargazers_url": "https://api.github.com/repos/6543/test_ci_tmp/stargazers", + "contributors_url": "https://api.github.com/repos/6543/test_ci_tmp/contributors", + "subscribers_url": "https://api.github.com/repos/6543/test_ci_tmp/subscribers", + "subscription_url": "https://api.github.com/repos/6543/test_ci_tmp/subscription", + "commits_url": "https://api.github.com/repos/6543/test_ci_tmp/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/6543/test_ci_tmp/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/6543/test_ci_tmp/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/6543/test_ci_tmp/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/6543/test_ci_tmp/contents/{+path}", + "compare_url": "https://api.github.com/repos/6543/test_ci_tmp/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/6543/test_ci_tmp/merges", + "archive_url": "https://api.github.com/repos/6543/test_ci_tmp/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/6543/test_ci_tmp/downloads", + "issues_url": "https://api.github.com/repos/6543/test_ci_tmp/issues{/number}", + "pulls_url": "https://api.github.com/repos/6543/test_ci_tmp/pulls{/number}", + "milestones_url": "https://api.github.com/repos/6543/test_ci_tmp/milestones{/number}", + "notifications_url": "https://api.github.com/repos/6543/test_ci_tmp/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/6543/test_ci_tmp/labels{/name}", + "releases_url": "https://api.github.com/repos/6543/test_ci_tmp/releases{/id}", + "deployments_url": "https://api.github.com/repos/6543/test_ci_tmp/deployments", + "created_at": "2025-07-29T19:35:41Z", + "updated_at": "2025-07-29T19:36:23Z", + "pushed_at": "2025-07-29T19:36:21Z", + "git_url": "git://github.com/6543/test_ci_tmp.git", + "ssh_url": "git@github.com:6543/test_ci_tmp.git", + "clone_url": "https://github.com/6543/test_ci_tmp.git", + "svn_url": "https://github.com/6543/test_ci_tmp", + "homepage": null, + "size": 3, + "stargazers_count": 0, + "watchers_count": 0, + "language": "Dockerfile", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "has_discussions": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 1, + "license": null, + "allow_forking": true, + "is_template": false, + "web_commit_signoff_required": false, + "topics": [], + "visibility": "public", + "forks": 0, + "open_issues": 1, + "watchers": 0, + "default_branch": "main" + }, + "sender": { + "login": "6543", + "id": 24977596, + "node_id": "MDQ6VXNlcjI0OTc3NTk2", + "avatar_url": "https://avatars.githubusercontent.com/u/24977596?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/6543", + "html_url": "https://github.com/6543", + "followers_url": "https://api.github.com/users/6543/followers", + "following_url": "https://api.github.com/users/6543/following{/other_user}", + "gists_url": "https://api.github.com/users/6543/gists{/gist_id}", + "starred_url": "https://api.github.com/users/6543/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/6543/subscriptions", + "organizations_url": "https://api.github.com/users/6543/orgs", + "repos_url": "https://api.github.com/users/6543/repos", + "events_url": "https://api.github.com/users/6543/events{/privacy}", + "received_events_url": "https://api.github.com/users/6543/received_events", + "type": "User", + "user_view_type": "public", + "site_admin": false + } +} diff --git a/server/forge/github/fixtures/HookPullRequestMilestoneAdded.json b/server/forge/github/fixtures/HookPullRequestMilestoneAdded.json new file mode 100644 index 00000000000..ac612fafbd7 --- /dev/null +++ b/server/forge/github/fixtures/HookPullRequestMilestoneAdded.json @@ -0,0 +1,332 @@ +{ + "action": "milestoned", + "number": 1, + "pull_request": { + "url": "https://api.github.com/repos/6543/test_ci_tmp/pulls/1", + "id": 2705176047, + "node_id": "PR_kwDOPU9UaM6hPbXv", + "number": 1, + "state": "open", + "locked": false, + "title": "Some ned more AAAA", + "user": { + "login": "6543", + "id": 24977596, + "node_id": "MDQ6VXNlcjI0OTc3NTk2", + "gravatar_id": "", + "url": "https://api.github.com/users/6543", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "body": "yeaaa", + "created_at": "2025-07-29T20:00:54Z", + "updated_at": "2025-07-29T23:46:29Z", + "closed_at": null, + "merged_at": null, + "merge_commit_sha": "b5fafd8b1c043723a38c99775bc807075bce9235", + "assignee": null, + "assignees": [], + "requested_reviewers": [], + "requested_teams": [], + "labels": [], + "milestone": { + "url": "https://api.github.com/repos/6543/test_ci_tmp/milestones/2", + "id": 13392101, + "node_id": "MI_kwDOPU9UaM4AzFjl", + "number": 2, + "title": "open mile", + "description": "ongoing", + "creator": { + "login": "demoaccount2-commits", + "id": 223550959, + "node_id": "U_kgDODVMd7w", + "gravatar_id": "", + "url": "https://api.github.com/users/demoaccount2-commits", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "open_issues": 1, + "closed_issues": 0, + "state": "open", + "created_at": "2025-07-29T23:46:08Z", + "updated_at": "2025-07-29T23:46:29Z", + "due_on": null, + "closed_at": null + }, + "draft": false, + "head": { + "label": "6543:6543-patch-1", + "ref": "6543-patch-1", + "sha": "36b5813240a9d2daa29b05046d56a53e18f39a3e", + "user": { + "login": "6543", + "id": 24977596, + "node_id": "MDQ6VXNlcjI0OTc3NTk2", + "gravatar_id": "", + "url": "https://api.github.com/users/6543", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "repo": { + "id": 1028609128, + "node_id": "R_kgDOPU9UaA", + "name": "test_ci_tmp", + "full_name": "6543/test_ci_tmp", + "private": false, + "owner": { + "login": "6543", + "id": 24977596, + "node_id": "MDQ6VXNlcjI0OTc3NTk2", + "gravatar_id": "", + "url": "https://api.github.com/users/6543", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "description": null, + "fork": false, + "url": "https://api.github.com/repos/6543/test_ci_tmp", + "created_at": "2025-07-29T19:35:41Z", + "updated_at": "2025-07-29T19:36:23Z", + "pushed_at": "2025-07-29T19:36:21Z", + "homepage": null, + "size": 3, + "stargazers_count": 0, + "watchers_count": 0, + "language": "Dockerfile", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "has_discussions": false, + "forks_count": 0, + "archived": false, + "disabled": false, + "open_issues_count": 1, + "license": null, + "allow_forking": true, + "is_template": false, + "web_commit_signoff_required": false, + "topics": [], + "visibility": "public", + "forks": 0, + "open_issues": 1, + "watchers": 0, + "default_branch": "main", + "allow_squash_merge": true, + "allow_merge_commit": true, + "allow_rebase_merge": true, + "allow_auto_merge": false, + "delete_branch_on_merge": false, + "allow_update_branch": false, + "use_squash_pr_title_as_default": false, + "squash_merge_commit_message": "COMMIT_MESSAGES", + "squash_merge_commit_title": "COMMIT_OR_PR_TITLE", + "merge_commit_message": "PR_TITLE", + "merge_commit_title": "MERGE_MESSAGE" + } + }, + "base": { + "label": "6543:main", + "ref": "main", + "sha": "67012991d6c69b1c58378346fca366b864d8d1a1", + "user": { + "login": "6543", + "id": 24977596, + "node_id": "MDQ6VXNlcjI0OTc3NTk2", + "gravatar_id": "", + "url": "https://api.github.com/users/6543", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "repo": { + "id": 1028609128, + "node_id": "R_kgDOPU9UaA", + "name": "test_ci_tmp", + "full_name": "6543/test_ci_tmp", + "private": false, + "owner": { + "login": "6543", + "id": 24977596, + "node_id": "MDQ6VXNlcjI0OTc3NTk2", + "gravatar_id": "", + "url": "https://api.github.com/users/6543", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "description": null, + "fork": false, + "url": "https://api.github.com/repos/6543/test_ci_tmp", + "created_at": "2025-07-29T19:35:41Z", + "updated_at": "2025-07-29T19:36:23Z", + "pushed_at": "2025-07-29T19:36:21Z", + "homepage": null, + "size": 3, + "stargazers_count": 0, + "watchers_count": 0, + "language": "Dockerfile", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "has_discussions": false, + "forks_count": 0, + "archived": false, + "disabled": false, + "open_issues_count": 1, + "license": null, + "allow_forking": true, + "is_template": false, + "web_commit_signoff_required": false, + "topics": [], + "visibility": "public", + "forks": 0, + "open_issues": 1, + "watchers": 0, + "default_branch": "main", + "allow_squash_merge": true, + "allow_merge_commit": true, + "allow_rebase_merge": true, + "allow_auto_merge": false, + "delete_branch_on_merge": false, + "allow_update_branch": false, + "use_squash_pr_title_as_default": false, + "squash_merge_commit_message": "COMMIT_MESSAGES", + "squash_merge_commit_title": "COMMIT_OR_PR_TITLE", + "merge_commit_message": "PR_TITLE", + "merge_commit_title": "MERGE_MESSAGE" + } + }, + "_links": { + "self": { + "href": "https://api.github.com/repos/6543/test_ci_tmp/pulls/1" + }, + "html": { + "href": "https://github.com/6543/test_ci_tmp/pull/1" + }, + "issue": { + "href": "https://api.github.com/repos/6543/test_ci_tmp/issues/1" + }, + "comments": { + "href": "https://api.github.com/repos/6543/test_ci_tmp/issues/1/comments" + }, + "review_comments": { + "href": "https://api.github.com/repos/6543/test_ci_tmp/pulls/1/comments" + }, + "review_comment": { + "href": "https://api.github.com/repos/6543/test_ci_tmp/pulls/comments{/number}" + }, + "commits": { + "href": "https://api.github.com/repos/6543/test_ci_tmp/pulls/1/commits" + }, + "statuses": { + "href": "https://api.github.com/repos/6543/test_ci_tmp/statuses/36b5813240a9d2daa29b05046d56a53e18f39a3e" + } + }, + "author_association": "OWNER", + "auto_merge": null, + "active_lock_reason": null, + "merged": false, + "mergeable": true, + "rebaseable": true, + "mergeable_state": "unstable", + "merged_by": null, + "comments": 0, + "review_comments": 0, + "maintainer_can_modify": false, + "commits": 1, + "additions": 1, + "deletions": 0, + "changed_files": 1 + }, + "milestone": { + "url": "https://api.github.com/repos/6543/test_ci_tmp/milestones/2", + "id": 13392101, + "node_id": "MI_kwDOPU9UaM4AzFjl", + "number": 2, + "title": "open mile", + "description": "ongoing", + "creator": { + "login": "demoaccount2-commits", + "id": 223550959, + "node_id": "U_kgDODVMd7w", + "gravatar_id": "", + "url": "https://api.github.com/users/demoaccount2-commits", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "open_issues": 1, + "closed_issues": 0, + "state": "open", + "created_at": "2025-07-29T23:46:08Z", + "updated_at": "2025-07-29T23:46:29Z", + "due_on": null, + "closed_at": null + }, + "repository": { + "id": 1028609128, + "node_id": "R_kgDOPU9UaA", + "name": "test_ci_tmp", + "full_name": "6543/test_ci_tmp", + "private": false, + "owner": { + "login": "6543", + "id": 24977596, + "node_id": "MDQ6VXNlcjI0OTc3NTk2", + "gravatar_id": "", + "url": "https://api.github.com/users/6543", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "description": null, + "fork": false, + "url": "https://api.github.com/repos/6543/test_ci_tmp", + "created_at": "2025-07-29T19:35:41Z", + "updated_at": "2025-07-29T19:36:23Z", + "pushed_at": "2025-07-29T19:36:21Z", + "homepage": null, + "size": 3, + "stargazers_count": 0, + "watchers_count": 0, + "language": "Dockerfile", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "has_discussions": false, + "forks_count": 0, + "archived": false, + "disabled": false, + "open_issues_count": 1, + "license": null, + "allow_forking": true, + "is_template": false, + "web_commit_signoff_required": false, + "topics": [], + "visibility": "public", + "forks": 0, + "open_issues": 1, + "watchers": 0, + "default_branch": "main" + }, + "sender": { + "login": "demoaccount2-commits", + "id": 223550959, + "node_id": "U_kgDODVMd7w", + "gravatar_id": "", + "url": "https://api.github.com/users/demoaccount2-commits", + "type": "User", + "user_view_type": "public", + "site_admin": false + } +} diff --git a/server/forge/github/fixtures/HookPullRequestMilestoneRemoved.json b/server/forge/github/fixtures/HookPullRequestMilestoneRemoved.json new file mode 100644 index 00000000000..bc95e57834f --- /dev/null +++ b/server/forge/github/fixtures/HookPullRequestMilestoneRemoved.json @@ -0,0 +1,318 @@ +{ + "action": "demilestoned", + "number": 1, + "pull_request": { + "url": "https://api.github.com/repos/6543/test_ci_tmp/pulls/1", + "id": 2705176047, + "node_id": "PR_kwDOPU9UaM6hPbXv", + "number": 1, + "state": "open", + "locked": false, + "title": "Some ned more AAAA", + "user": { + "login": "6543", + "id": 24977596, + "node_id": "MDQ6VXNlcjI0OTc3NTk2", + "gravatar_id": "", + "url": "https://api.github.com/users/6543", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "body": "yeaaa", + "created_at": "2025-07-29T20:00:54Z", + "updated_at": "2025-07-30T00:01:25Z", + "closed_at": null, + "merged_at": null, + "merge_commit_sha": "b5fafd8b1c043723a38c99775bc807075bce9235", + "assignee": null, + "assignees": [], + "requested_reviewers": [], + "requested_teams": [], + "labels": [ + { + "id": 9024465370, + "node_id": "LA_kwDOPU9UaM8AAAACGeZp2g", + "url": "https://api.github.com/repos/6543/test_ci_tmp/labels/bug", + "name": "bug", + "color": "d73a4a", + "default": true, + "description": "Something isn't working" + } + ], + "milestone": null, + "draft": false, + "head": { + "label": "6543:6543-patch-1", + "ref": "6543-patch-1", + "sha": "36b5813240a9d2daa29b05046d56a53e18f39a3e", + "user": { + "login": "6543", + "id": 24977596, + "node_id": "MDQ6VXNlcjI0OTc3NTk2", + "gravatar_id": "", + "url": "https://api.github.com/users/6543", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "repo": { + "id": 1028609128, + "node_id": "R_kgDOPU9UaA", + "name": "test_ci_tmp", + "full_name": "6543/test_ci_tmp", + "private": false, + "owner": { + "login": "6543", + "id": 24977596, + "node_id": "MDQ6VXNlcjI0OTc3NTk2", + "gravatar_id": "", + "url": "https://api.github.com/users/6543", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "description": null, + "fork": false, + "url": "https://api.github.com/repos/6543/test_ci_tmp", + "created_at": "2025-07-29T19:35:41Z", + "updated_at": "2025-07-29T19:36:23Z", + "pushed_at": "2025-07-29T19:36:21Z", + "homepage": null, + "size": 3, + "stargazers_count": 0, + "watchers_count": 0, + "language": "Dockerfile", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "has_discussions": false, + "forks_count": 0, + "archived": false, + "disabled": false, + "open_issues_count": 1, + "license": null, + "allow_forking": true, + "is_template": false, + "web_commit_signoff_required": false, + "topics": [], + "visibility": "public", + "forks": 0, + "open_issues": 1, + "watchers": 0, + "default_branch": "main", + "allow_squash_merge": true, + "allow_merge_commit": true, + "allow_rebase_merge": true, + "allow_auto_merge": false, + "delete_branch_on_merge": false, + "allow_update_branch": false, + "use_squash_pr_title_as_default": false, + "squash_merge_commit_message": "COMMIT_MESSAGES", + "squash_merge_commit_title": "COMMIT_OR_PR_TITLE", + "merge_commit_message": "PR_TITLE", + "merge_commit_title": "MERGE_MESSAGE" + } + }, + "base": { + "label": "6543:main", + "ref": "main", + "sha": "67012991d6c69b1c58378346fca366b864d8d1a1", + "user": { + "login": "6543", + "id": 24977596, + "node_id": "MDQ6VXNlcjI0OTc3NTk2", + "gravatar_id": "", + "url": "https://api.github.com/users/6543", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "repo": { + "id": 1028609128, + "node_id": "R_kgDOPU9UaA", + "name": "test_ci_tmp", + "full_name": "6543/test_ci_tmp", + "private": false, + "owner": { + "login": "6543", + "id": 24977596, + "node_id": "MDQ6VXNlcjI0OTc3NTk2", + "gravatar_id": "", + "url": "https://api.github.com/users/6543", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "description": null, + "fork": false, + "url": "https://api.github.com/repos/6543/test_ci_tmp", + "created_at": "2025-07-29T19:35:41Z", + "updated_at": "2025-07-29T19:36:23Z", + "pushed_at": "2025-07-29T19:36:21Z", + "homepage": null, + "size": 3, + "stargazers_count": 0, + "watchers_count": 0, + "language": "Dockerfile", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "has_discussions": false, + "forks_count": 0, + "archived": false, + "disabled": false, + "open_issues_count": 1, + "license": null, + "allow_forking": true, + "is_template": false, + "web_commit_signoff_required": false, + "topics": [], + "visibility": "public", + "forks": 0, + "open_issues": 1, + "watchers": 0, + "default_branch": "main", + "allow_squash_merge": true, + "allow_merge_commit": true, + "allow_rebase_merge": true, + "allow_auto_merge": false, + "delete_branch_on_merge": false, + "allow_update_branch": false, + "use_squash_pr_title_as_default": false, + "squash_merge_commit_message": "COMMIT_MESSAGES", + "squash_merge_commit_title": "COMMIT_OR_PR_TITLE", + "merge_commit_message": "PR_TITLE", + "merge_commit_title": "MERGE_MESSAGE" + } + }, + "_links": { + "self": { + "href": "https://api.github.com/repos/6543/test_ci_tmp/pulls/1" + }, + "html": { + "href": "https://github.com/6543/test_ci_tmp/pull/1" + }, + "issue": { + "href": "https://api.github.com/repos/6543/test_ci_tmp/issues/1" + }, + "comments": { + "href": "https://api.github.com/repos/6543/test_ci_tmp/issues/1/comments" + }, + "review_comments": { + "href": "https://api.github.com/repos/6543/test_ci_tmp/pulls/1/comments" + }, + "review_comment": { + "href": "https://api.github.com/repos/6543/test_ci_tmp/pulls/comments{/number}" + }, + "commits": { + "href": "https://api.github.com/repos/6543/test_ci_tmp/pulls/1/commits" + }, + "statuses": { + "href": "https://api.github.com/repos/6543/test_ci_tmp/statuses/36b5813240a9d2daa29b05046d56a53e18f39a3e" + } + }, + "author_association": "OWNER", + "auto_merge": null, + "active_lock_reason": null, + "merged": false, + "mergeable": true, + "rebaseable": true, + "mergeable_state": "unstable", + "merged_by": null, + "comments": 0, + "review_comments": 0, + "maintainer_can_modify": false, + "commits": 1, + "additions": 1, + "deletions": 0, + "changed_files": 1 + }, + "milestone": { + "url": "https://api.github.com/repos/6543/test_ci_tmp/milestones/1", + "id": 13392100, + "node_id": "MI_kwDOPU9UaM4AzFjk", + "number": 1, + "title": "closed mile", + "description": "", + "creator": { + "login": "demoaccount2-commits", + "id": 223550959, + "node_id": "U_kgDODVMd7w", + "gravatar_id": "", + "url": "https://api.github.com/users/demoaccount2-commits", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "open_issues": 0, + "closed_issues": 0, + "state": "closed", + "created_at": "2025-07-29T23:45:30Z", + "updated_at": "2025-07-30T00:01:25Z", + "due_on": "2029-03-16T07:00:00Z", + "closed_at": "2025-07-29T23:45:35Z" + }, + "repository": { + "id": 1028609128, + "node_id": "R_kgDOPU9UaA", + "name": "test_ci_tmp", + "full_name": "6543/test_ci_tmp", + "private": false, + "owner": { + "login": "6543", + "id": 24977596, + "node_id": "MDQ6VXNlcjI0OTc3NTk2", + "gravatar_id": "", + "url": "https://api.github.com/users/6543", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "description": null, + "fork": false, + "url": "https://api.github.com/repos/6543/test_ci_tmp", + "created_at": "2025-07-29T19:35:41Z", + "updated_at": "2025-07-29T19:36:23Z", + "pushed_at": "2025-07-29T19:36:21Z", + "homepage": null, + "size": 3, + "stargazers_count": 0, + "watchers_count": 0, + "language": "Dockerfile", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "has_discussions": false, + "forks_count": 0, + "archived": false, + "disabled": false, + "open_issues_count": 1, + "license": null, + "allow_forking": true, + "is_template": false, + "web_commit_signoff_required": false, + "topics": [], + "visibility": "public", + "forks": 0, + "open_issues": 1, + "watchers": 0, + "default_branch": "main" + }, + "sender": { + "login": "demoaccount2-commits", + "id": 223550959, + "node_id": "U_kgDODVMd7w", + "gravatar_id": "", + "url": "https://api.github.com/users/demoaccount2-commits", + "type": "User", + "user_view_type": "public", + "site_admin": false + } +} diff --git a/server/forge/github/fixtures/HookPullRequestReviewRequested.json b/server/forge/github/fixtures/HookPullRequestReviewRequested.json new file mode 100644 index 00000000000..3aaea412628 --- /dev/null +++ b/server/forge/github/fixtures/HookPullRequestReviewRequested.json @@ -0,0 +1,304 @@ +{ + "action": "review_requested", + "number": 1, + "pull_request": { + "url": "https://api.github.com/repos/6543/test_ci_tmp/pulls/1", + "id": 2705176047, + "node_id": "PR_kwDOPU9UaM6hPbXv", + "number": 1, + "state": "open", + "locked": false, + "title": "Some ned more AAAA", + "user": { + "login": "6543", + "id": 24977596, + "node_id": "MDQ6VXNlcjI0OTc3NTk2", + "gravatar_id": "", + "url": "https://api.github.com/users/6543", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "body": "yeaaa", + "created_at": "2025-07-29T20:00:54Z", + "updated_at": "2025-07-29T23:20:52Z", + "closed_at": null, + "merged_at": null, + "merge_commit_sha": "b5fafd8b1c043723a38c99775bc807075bce9235", + "assignee": null, + "assignees": [], + "requested_reviewers": [ + { + "login": "demoaccount2-commits", + "id": 223550959, + "node_id": "U_kgDODVMd7w", + "gravatar_id": "", + "url": "https://api.github.com/users/demoaccount2-commits", + "type": "User", + "user_view_type": "public", + "site_admin": false + } + ], + "requested_teams": [], + "labels": [], + "milestone": null, + "draft": false, + "head": { + "label": "6543:6543-patch-1", + "ref": "6543-patch-1", + "sha": "36b5813240a9d2daa29b05046d56a53e18f39a3e", + "user": { + "login": "6543", + "id": 24977596, + "node_id": "MDQ6VXNlcjI0OTc3NTk2", + "gravatar_id": "", + "url": "https://api.github.com/users/6543", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "repo": { + "id": 1028609128, + "node_id": "R_kgDOPU9UaA", + "name": "test_ci_tmp", + "full_name": "6543/test_ci_tmp", + "private": false, + "owner": { + "login": "6543", + "id": 24977596, + "node_id": "MDQ6VXNlcjI0OTc3NTk2", + "gravatar_id": "", + "url": "https://api.github.com/users/6543", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "description": null, + "fork": false, + "url": "https://api.github.com/repos/6543/test_ci_tmp", + "created_at": "2025-07-29T19:35:41Z", + "updated_at": "2025-07-29T19:36:23Z", + "pushed_at": "2025-07-29T19:36:21Z", + "homepage": null, + "size": 3, + "stargazers_count": 0, + "watchers_count": 0, + "language": "Dockerfile", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "has_discussions": false, + "forks_count": 0, + "archived": false, + "disabled": false, + "open_issues_count": 1, + "license": null, + "allow_forking": true, + "is_template": false, + "web_commit_signoff_required": false, + "topics": [], + "visibility": "public", + "forks": 0, + "open_issues": 1, + "watchers": 0, + "default_branch": "main", + "allow_squash_merge": true, + "allow_merge_commit": true, + "allow_rebase_merge": true, + "allow_auto_merge": false, + "delete_branch_on_merge": false, + "allow_update_branch": false, + "use_squash_pr_title_as_default": false, + "squash_merge_commit_message": "COMMIT_MESSAGES", + "squash_merge_commit_title": "COMMIT_OR_PR_TITLE", + "merge_commit_message": "PR_TITLE", + "merge_commit_title": "MERGE_MESSAGE" + } + }, + "base": { + "label": "6543:main", + "ref": "main", + "sha": "67012991d6c69b1c58378346fca366b864d8d1a1", + "user": { + "login": "6543", + "id": 24977596, + "node_id": "MDQ6VXNlcjI0OTc3NTk2", + "gravatar_id": "", + "url": "https://api.github.com/users/6543", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "repo": { + "id": 1028609128, + "node_id": "R_kgDOPU9UaA", + "name": "test_ci_tmp", + "full_name": "6543/test_ci_tmp", + "private": false, + "owner": { + "login": "6543", + "id": 24977596, + "node_id": "MDQ6VXNlcjI0OTc3NTk2", + "gravatar_id": "", + "url": "https://api.github.com/users/6543", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "description": null, + "fork": false, + "url": "https://api.github.com/repos/6543/test_ci_tmp", + "created_at": "2025-07-29T19:35:41Z", + "updated_at": "2025-07-29T19:36:23Z", + "pushed_at": "2025-07-29T19:36:21Z", + "homepage": null, + "size": 3, + "stargazers_count": 0, + "watchers_count": 0, + "language": "Dockerfile", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "has_discussions": false, + "forks_count": 0, + "archived": false, + "disabled": false, + "open_issues_count": 1, + "license": null, + "allow_forking": true, + "is_template": false, + "web_commit_signoff_required": false, + "topics": [], + "visibility": "public", + "forks": 0, + "open_issues": 1, + "watchers": 0, + "default_branch": "main", + "allow_squash_merge": true, + "allow_merge_commit": true, + "allow_rebase_merge": true, + "allow_auto_merge": false, + "delete_branch_on_merge": false, + "allow_update_branch": false, + "use_squash_pr_title_as_default": false, + "squash_merge_commit_message": "COMMIT_MESSAGES", + "squash_merge_commit_title": "COMMIT_OR_PR_TITLE", + "merge_commit_message": "PR_TITLE", + "merge_commit_title": "MERGE_MESSAGE" + } + }, + "_links": { + "self": { + "href": "https://api.github.com/repos/6543/test_ci_tmp/pulls/1" + }, + "html": { + "href": "https://github.com/6543/test_ci_tmp/pull/1" + }, + "issue": { + "href": "https://api.github.com/repos/6543/test_ci_tmp/issues/1" + }, + "comments": { + "href": "https://api.github.com/repos/6543/test_ci_tmp/issues/1/comments" + }, + "review_comments": { + "href": "https://api.github.com/repos/6543/test_ci_tmp/pulls/1/comments" + }, + "review_comment": { + "href": "https://api.github.com/repos/6543/test_ci_tmp/pulls/comments{/number}" + }, + "commits": { + "href": "https://api.github.com/repos/6543/test_ci_tmp/pulls/1/commits" + }, + "statuses": { + "href": "https://api.github.com/repos/6543/test_ci_tmp/statuses/36b5813240a9d2daa29b05046d56a53e18f39a3e" + } + }, + "author_association": "OWNER", + "auto_merge": null, + "active_lock_reason": null, + "merged": false, + "mergeable": true, + "rebaseable": true, + "mergeable_state": "unstable", + "merged_by": null, + "comments": 0, + "review_comments": 0, + "maintainer_can_modify": false, + "commits": 1, + "additions": 1, + "deletions": 0, + "changed_files": 1 + }, + "requested_reviewer": { + "login": "demoaccount2-commits", + "id": 223550959, + "node_id": "U_kgDODVMd7w", + "gravatar_id": "", + "url": "https://api.github.com/users/demoaccount2-commits", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "repository": { + "id": 1028609128, + "node_id": "R_kgDOPU9UaA", + "name": "test_ci_tmp", + "full_name": "6543/test_ci_tmp", + "private": false, + "owner": { + "login": "6543", + "id": 24977596, + "node_id": "MDQ6VXNlcjI0OTc3NTk2", + "gravatar_id": "", + "url": "https://api.github.com/users/6543", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "description": null, + "fork": false, + "url": "https://api.github.com/repos/6543/test_ci_tmp", + "created_at": "2025-07-29T19:35:41Z", + "updated_at": "2025-07-29T19:36:23Z", + "pushed_at": "2025-07-29T19:36:21Z", + "homepage": null, + "size": 3, + "stargazers_count": 0, + "watchers_count": 0, + "language": "Dockerfile", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "has_discussions": false, + "forks_count": 0, + "archived": false, + "disabled": false, + "open_issues_count": 1, + "license": null, + "allow_forking": true, + "is_template": false, + "web_commit_signoff_required": false, + "topics": [], + "visibility": "public", + "forks": 0, + "open_issues": 1, + "watchers": 0, + "default_branch": "main" + }, + "sender": { + "login": "demoaccount2-commits", + "id": 223550959, + "node_id": "U_kgDODVMd7w", + "gravatar_id": "", + "url": "https://api.github.com/users/demoaccount2-commits", + "type": "User", + "user_view_type": "public", + "site_admin": false + } +} diff --git a/server/forge/github/fixtures/hooks.go b/server/forge/github/fixtures/hooks.go index 714b0baad3c..352e82bcbb6 100644 --- a/server/forge/github/fixtures/hooks.go +++ b/server/forge/github/fixtures/hooks.go @@ -71,8 +71,35 @@ var HookPullRequestMerged string //go:embed HookPullRequestClosed.json var HookPullRequestClosed string +//go:embed HookPullRequestEdited.json +var HookPullRequestEdited string + //go:embed HookRelease.json var HookRelease string +//go:embed HookPullRequestReviewRequested.json +var HookPullRequestReviewRequested string + +//go:embed HookPullRequestMilestoneAdded.json +var HookPullRequestMilestoneAdded string + +//go:embed HookPullRequestMilestoneRemoved.json +var HookPullRequestMilestoneRemoved string + +//go:embed HookPullRequestLabelAdded.json +var HookPullRequestLabelAdded string + +//go:embed HookPullRequestLabelRemoved.json +var HookPullRequestLabelRemoved string + +//go:embed HookPullRequestAssigneeAdded.json +var HookPullRequestAssigneeAdded string + +//go:embed HookPullRequestAssigneeRemoved.json +var HookPullRequestAssigneeRemoved string + //go:embed HookPullRequestReopened.json var HookPullRequestReopened string + +//go:embed HookPullRequestLabelsCleared.json +var HookPullRequestLabelsCleared string diff --git a/server/forge/github/github.go b/server/forge/github/github.go index cd33a77d010..ccbd0343a63 100644 --- a/server/forge/github/github.go +++ b/server/forge/github/github.go @@ -559,6 +559,7 @@ func (c *client) Activate(ctx context.Context, u *model.User, r *model.Repo, lin Events: []string{ "push", "pull_request", + "pull_request_review", "deployment", }, Config: &github.HookConfig{ diff --git a/server/forge/github/parse.go b/server/forge/github/parse.go index 8d5b14fe8b3..22f4e0ff68f 100644 --- a/server/forge/github/parse.go +++ b/server/forge/github/parse.go @@ -24,6 +24,7 @@ import ( "github.com/google/go-github/v74/github" + "go.woodpecker-ci.org/woodpecker/v3/server/forge/common" "go.woodpecker-ci.org/woodpecker/v3/server/forge/types" "go.woodpecker-ci.org/woodpecker/v3/server/model" "go.woodpecker-ci.org/woodpecker/v3/shared/utils" @@ -32,14 +33,25 @@ import ( const ( hookField = "payload" - actionOpen = "opened" - actionReopen = "reopened" - actionClose = "closed" - actionSync = "synchronize" - actionReleased = "released" + actionOpen = "opened" + actionReopen = "reopened" + actionClose = "closed" + actionSync = "synchronize" + actionReleased = "released" + actionAssigned = "assigned" + actionConvertedToDraft = "converted_to_draft" + actionDemilestoned = "demilestoned" + actionEdited = "edited" + actionLabeled = "labeled" + actionLocked = "locked" + actionMilestoned = "milestoned" + actionReadyForReview = "ready_for_review" + actionUnassigned = "unassigned" + actionUnlabeled = "unlabeled" + actionUnlocked = "unlocked" - stateOpen = "open" - stateClose = "closed" + labelCleared = "label_cleared" + labelUpdated = "label_updated" ) // parseHook parses a GitHub hook from an http.Request request and returns @@ -149,31 +161,49 @@ func parseDeployHook(hook *github.DeploymentEvent) (*model.Repo, *model.Pipeline // parsePullHook parses a pull request hook and returns the Repo and Pipeline // details. func parsePullHook(hook *github.PullRequestEvent, merge bool) (*github.PullRequest, *model.Repo, *model.Pipeline, error) { - if hook.GetAction() != actionOpen && - hook.GetAction() != actionSync && - hook.GetAction() != actionClose && - hook.GetAction() != actionReopen { - return nil, nil, nil, nil - } - event := model.EventPull - if hook.GetPullRequest().GetState() == stateClose { + eventAction := "" + + switch hook.GetAction() { + case actionOpen, actionReopen, actionSync: + // default case nothing to do + case actionClose: event = model.EventPullClosed + case actionAssigned, + actionConvertedToDraft, + actionDemilestoned, + actionEdited, + actionLabeled, + actionLocked, + actionMilestoned, + actionReadyForReview, + actionUnassigned, + actionUnlabeled, + actionUnlocked: + // metadata pull events + event = model.EventPullMetadata + eventAction = common.NormalizeEventReason(hook.GetAction()) + default: + return nil, nil, nil, &types.ErrIgnoreEvent{ + Event: string(model.EventPullMetadata), + Reason: fmt.Sprintf("action %s is not supported", hook.GetAction()), + } } fromFork := hook.GetPullRequest().GetHead().GetRepo().GetID() != hook.GetPullRequest().GetBase().GetRepo().GetID() pipeline := &model.Pipeline{ - Event: event, - Commit: hook.GetPullRequest().GetHead().GetSHA(), - ForgeURL: hook.GetPullRequest().GetHTMLURL(), - Ref: fmt.Sprintf(headRefs, hook.GetPullRequest().GetNumber()), - Branch: hook.GetPullRequest().GetBase().GetRef(), - Message: hook.GetPullRequest().GetTitle(), - Author: hook.GetPullRequest().GetUser().GetLogin(), - Avatar: hook.GetPullRequest().GetUser().GetAvatarURL(), - Title: hook.GetPullRequest().GetTitle(), - Sender: hook.GetSender().GetLogin(), + Event: event, + EventReason: []string{eventAction}, + Commit: hook.GetPullRequest().GetHead().GetSHA(), + ForgeURL: hook.GetPullRequest().GetHTMLURL(), + Ref: fmt.Sprintf(headRefs, hook.GetPullRequest().GetNumber()), + Branch: hook.GetPullRequest().GetBase().GetRef(), + Message: hook.GetPullRequest().GetTitle(), + Author: hook.GetPullRequest().GetUser().GetLogin(), + Avatar: hook.GetPullRequest().GetUser().GetAvatarURL(), + Title: hook.GetPullRequest().GetTitle(), + Sender: hook.GetSender().GetLogin(), Refspec: fmt.Sprintf(refSpec, hook.GetPullRequest().GetHead().GetRef(), hook.GetPullRequest().GetBase().GetRef(), @@ -186,6 +216,15 @@ func parsePullHook(hook *github.PullRequestEvent, merge bool) (*github.PullReque pipeline.Ref = fmt.Sprintf(mergeRefs, hook.GetPullRequest().GetNumber()) } + // normalize label events to match other forges + if eventAction == actionLabeled || eventAction == actionUnlabeled { + if len(pipeline.PullRequestLabels) == 0 { + pipeline.EventReason = []string{labelCleared} + } else { + pipeline.EventReason = []string{labelUpdated} + } + } + return hook.GetPullRequest(), convertRepo(hook.GetRepo()), pipeline, nil } diff --git a/server/forge/github/parse_test.go b/server/forge/github/parse_test.go index 294254d2f1c..7791dac34e0 100644 --- a/server/forge/github/parse_test.go +++ b/server/forge/github/parse_test.go @@ -93,6 +93,17 @@ func Test_parseHook(t *testing.T) { assert.NotNil(t, p) assert.Equal(t, model.EventPullClosed, b.Event) }) + + t.Run("reopen a pull", func(t *testing.T) { + req := testHookRequest([]byte(fixtures.HookPullRequestReopened), hookPull) + p, r, b, err := parseHook(req, false) + assert.NoError(t, err) + assert.NotNil(t, r) + assert.NotNil(t, b) + assert.NotNil(t, p) + assert.Equal(t, model.EventPull, b.Event) + }) + t.Run("PR merged hook", func(t *testing.T) { req := testHookRequest([]byte(fixtures.HookPullRequestMerged), hookPull) p, r, b, err := parseHook(req, false) @@ -103,6 +114,17 @@ func Test_parseHook(t *testing.T) { assert.Equal(t, model.EventPullClosed, b.Event) }) + t.Run("PR edited hook", func(t *testing.T) { + req := testHookRequest([]byte(fixtures.HookPullRequestEdited), hookPull) + p, r, b, err := parseHook(req, false) + assert.NoError(t, err) + assert.NotNil(t, r) + assert.NotNil(t, b) + assert.NotNil(t, p) + assert.Equal(t, model.EventPullMetadata, b.Event) + assert.Equal(t, []string{"edited"}, b.EventReason) + }) + t.Run("deploy hook", func(t *testing.T) { req := testHookRequest([]byte(fixtures.HookDeploy), hookDeploy) p, r, b, err := parseHook(req, false) @@ -127,13 +149,285 @@ func Test_parseHook(t *testing.T) { assert.True(t, strings.HasPrefix(b.Ref, "refs/tags/")) }) - t.Run("reopen a pull", func(t *testing.T) { - req := testHookRequest([]byte(fixtures.HookPullRequestReopened), hookPull) + t.Run("pull review requested", func(t *testing.T) { + req := testHookRequest([]byte(fixtures.HookPullRequestReviewRequested), hookPull) + p, r, b, err := parseHook(req, false) + assert.ErrorIs(t, err, &types.ErrIgnoreEvent{}) + assert.Nil(t, r) + assert.Nil(t, b) + assert.Nil(t, p) + }) + + t.Run("pull milestoned", func(t *testing.T) { + req := testHookRequest([]byte(fixtures.HookPullRequestMilestoneAdded), hookPull) p, r, b, err := parseHook(req, false) assert.NoError(t, err) assert.NotNil(t, r) assert.NotNil(t, b) - assert.NotNil(t, p) - assert.Equal(t, model.EventPull, b.Event) + assert.Equal(t, model.EventPullMetadata, b.Event) + assert.Equal(t, []string{"milestoned"}, b.EventReason) + if assert.NotNil(t, p) { + assert.Equal(t, int64(2705176047), *p.ID) + assert.Equal(t, 1, *p.Number) + assert.Equal(t, "open", *p.State) + assert.Equal(t, "Some ned more AAAA", *p.Title) + assert.Equal(t, "yeaaa", *p.Body) + assert.Equal(t, false, *p.Draft) + assert.Equal(t, false, *p.Merged) + assert.Equal(t, true, *p.Mergeable) + assert.Equal(t, "unstable", *p.MergeableState) + if assert.NotNil(t, p.User) { + assert.Equal(t, "6543", *p.User.Login) + assert.Equal(t, int64(24977596), *p.User.ID) + } + if assert.NotNil(t, p.Milestone) { + assert.Equal(t, int64(13392101), *p.Milestone.ID) + assert.Equal(t, 2, *p.Milestone.Number) + assert.Equal(t, "open mile", *p.Milestone.Title) + assert.Equal(t, "ongoing", *p.Milestone.Description) + assert.Equal(t, "open", *p.Milestone.State) + if assert.NotNil(t, p.Milestone.Creator) { + assert.Equal(t, "demoaccount2-commits", *p.Milestone.Creator.Login) + assert.Equal(t, int64(223550959), *p.Milestone.Creator.ID) + } + } + assert.Empty(t, p.RequestedReviewers) + if assert.NotNil(t, p.Head) { + assert.Equal(t, "6543-patch-1", *p.Head.Ref) + assert.Equal(t, "36b5813240a9d2daa29b05046d56a53e18f39a3e", *p.Head.SHA) + } + if assert.NotNil(t, p.Base) { + assert.Equal(t, "main", *p.Base.Ref) + assert.Equal(t, "67012991d6c69b1c58378346fca366b864d8d1a1", *p.Base.SHA) + } + } + }) + + // milestone change will result two webhooks an demilestoned and milestoned + + t.Run("pull request demilestoned", func(t *testing.T) { + req := testHookRequest([]byte(fixtures.HookPullRequestMilestoneRemoved), hookPull) + p, r, b, err := parseHook(req, false) + assert.NoError(t, err) + assert.NotNil(t, r) + assert.NotNil(t, b) + assert.Equal(t, model.EventPullMetadata, b.Event) + assert.Equal(t, []string{"demilestoned"}, b.EventReason) + if assert.NotNil(t, p) { + assert.Equal(t, int64(2705176047), *p.ID) + assert.Equal(t, 1, *p.Number) + assert.Equal(t, "open", *p.State) + assert.Equal(t, "Some ned more AAAA", *p.Title) + if assert.NotNil(t, p.User) { + assert.Equal(t, "6543", *p.User.Login) + assert.Equal(t, int64(24977596), *p.User.ID) + } + if assert.Len(t, p.Labels, 1) { + assert.Equal(t, int64(9024465370), *p.Labels[0].ID) + assert.Equal(t, "bug", *p.Labels[0].Name) + assert.Equal(t, "d73a4a", *p.Labels[0].Color) + assert.Equal(t, "Something isn't working", *p.Labels[0].Description) + } + assert.Nil(t, p.Milestone) + if assert.NotNil(t, p.Head) { + assert.Equal(t, "6543-patch-1", *p.Head.Ref) + assert.Equal(t, "36b5813240a9d2daa29b05046d56a53e18f39a3e", *p.Head.SHA) + } + if assert.NotNil(t, p.Base) { + assert.Equal(t, "main", *p.Base.Ref) + assert.Equal(t, "67012991d6c69b1c58378346fca366b864d8d1a1", *p.Base.SHA) + } + } + }) + + t.Run("pull request labele added", func(t *testing.T) { + req := testHookRequest([]byte(fixtures.HookPullRequestLabelAdded), hookPull) + p, r, b, err := parseHook(req, false) + assert.NoError(t, err) + assert.NotNil(t, r) + assert.NotNil(t, b) + assert.Equal(t, model.EventPullMetadata, b.Event) + assert.Equal(t, []string{"label_updated"}, b.EventReason) + if assert.NotNil(t, p) { + assert.Equal(t, int64(2705176047), *p.ID) + assert.Equal(t, 1, *p.Number) + assert.Equal(t, "open", *p.State) + assert.Equal(t, "Some ned more AAAA", *p.Title) + assert.Equal(t, "yeaaa", *p.Body) + assert.Equal(t, false, *p.Draft) + assert.Equal(t, false, *p.Merged) + assert.Equal(t, true, *p.Mergeable) + assert.Equal(t, "unstable", *p.MergeableState) + if assert.NotNil(t, p.User) { + assert.Equal(t, "6543", *p.User.Login) + assert.Equal(t, int64(24977596), *p.User.ID) + } + if assert.Len(t, p.Labels, 2) { + assert.Equal(t, int64(9024465376), *p.Labels[0].ID) + assert.Equal(t, "documentation", *p.Labels[0].Name) + assert.Equal(t, "0075ca", *p.Labels[0].Color) + assert.Equal(t, "Improvements or additions to documentation", *p.Labels[0].Description) + assert.Equal(t, int64(9024465382), *p.Labels[1].ID) + assert.Equal(t, "enhancement", *p.Labels[1].Name) + assert.Equal(t, "a2eeef", *p.Labels[1].Color) + assert.Equal(t, "New feature or request", *p.Labels[1].Description) + } + if assert.NotNil(t, p.Milestone) { + assert.Equal(t, int64(13392101), *p.Milestone.ID) + assert.Equal(t, "open mile", *p.Milestone.Title) + } + assert.Empty(t, p.RequestedReviewers) + if assert.NotNil(t, p.Head) { + assert.Equal(t, "6543-patch-1", *p.Head.Ref) + assert.Equal(t, "36b5813240a9d2daa29b05046d56a53e18f39a3e", *p.Head.SHA) + } + if assert.NotNil(t, p.Base) { + assert.Equal(t, "main", *p.Base.Ref) + assert.Equal(t, "67012991d6c69b1c58378346fca366b864d8d1a1", *p.Base.SHA) + } + } + }) + + // lable change will result two webhooks an unlable and labeled + + t.Run("pull request got label removed", func(t *testing.T) { + req := testHookRequest([]byte(fixtures.HookPullRequestLabelRemoved), hookPull) + p, r, b, err := parseHook(req, false) + assert.NoError(t, err) + assert.NotNil(t, r) + assert.NotNil(t, b) + assert.Equal(t, model.EventPullMetadata, b.Event) + assert.Equal(t, []string{"label_updated"}, b.EventReason) + if assert.NotNil(t, p) { + assert.Equal(t, int64(2705176047), *p.ID) + assert.Equal(t, 1, *p.Number) + assert.Equal(t, "open", *p.State) + assert.Equal(t, "Some ned more AAAA", *p.Title) + if assert.NotNil(t, p.User) { + assert.Equal(t, "6543", *p.User.Login) + assert.Equal(t, int64(24977596), *p.User.ID) + } + if assert.Len(t, p.Labels, 1) { + assert.Equal(t, int64(9024465370), *p.Labels[0].ID) + assert.Equal(t, "bug", *p.Labels[0].Name) + assert.Equal(t, "d73a4a", *p.Labels[0].Color) + assert.Equal(t, "Something isn't working", *p.Labels[0].Description) + } + if assert.NotNil(t, p.Head) { + assert.Equal(t, "6543-patch-1", *p.Head.Ref) + assert.Equal(t, "36b5813240a9d2daa29b05046d56a53e18f39a3e", *p.Head.SHA) + } + if assert.NotNil(t, p.Base) { + assert.Equal(t, "main", *p.Base.Ref) + assert.Equal(t, "67012991d6c69b1c58378346fca366b864d8d1a1", *p.Base.SHA) + } + } + }) + + t.Run("pull request got all label removed", func(t *testing.T) { + req := testHookRequest([]byte(fixtures.HookPullRequestLabelsCleared), hookPull) + p, r, b, err := parseHook(req, false) + assert.NoError(t, err) + assert.NotNil(t, r) + assert.NotNil(t, b) + assert.Equal(t, model.EventPullMetadata, b.Event) + assert.Equal(t, []string{"label_cleared"}, b.EventReason) + if assert.NotNil(t, p) { + assert.Equal(t, int64(2705176047), *p.ID) + assert.Equal(t, 1, *p.Number) + assert.Equal(t, "open", *p.State) + assert.Equal(t, "Some ned more AAAA", *p.Title) + assert.Empty(t, p.Labels) + if assert.NotNil(t, p.User) { + assert.Equal(t, "6543", *p.User.Login) + assert.Equal(t, int64(24977596), *p.User.ID) + } + if assert.NotNil(t, p.Head) { + assert.Equal(t, "6543-patch-1", *p.Head.Ref) + assert.Equal(t, "36b5813240a9d2daa29b05046d56a53e18f39a3e", *p.Head.SHA) + } + if assert.NotNil(t, p.Base) { + assert.Equal(t, "main", *p.Base.Ref) + assert.Equal(t, "67012991d6c69b1c58378346fca366b864d8d1a1", *p.Base.SHA) + } + } + }) + + t.Run("pull request assigned", func(t *testing.T) { + req := testHookRequest([]byte(fixtures.HookPullRequestAssigneeAdded), hookPull) + p, r, b, err := parseHook(req, false) + assert.NoError(t, err) + assert.NotNil(t, r) + assert.NotNil(t, b) + assert.Equal(t, model.EventPullMetadata, b.Event) + assert.Equal(t, []string{"assigned"}, b.EventReason) + if assert.NotNil(t, p) { + assert.Equal(t, int64(2705176047), *p.ID) + assert.Equal(t, 1, *p.Number) + assert.Equal(t, "open", *p.State) + assert.Equal(t, "Some ned more AAAA", *p.Title) + if assert.NotNil(t, p.User) { + assert.Equal(t, "6543", *p.User.Login) + assert.Equal(t, int64(24977596), *p.User.ID) + } + if assert.NotNil(t, p.Assignee) { + assert.Equal(t, "demoaccount2-commits", *p.Assignee.Login) + assert.Equal(t, int64(223550959), *p.Assignee.ID) + } + if assert.Len(t, p.Assignees, 1) { + assert.Equal(t, "demoaccount2-commits", *p.Assignees[0].Login) + assert.Equal(t, int64(223550959), *p.Assignees[0].ID) + } + if assert.Len(t, p.Labels, 1) { + assert.Equal(t, int64(9024465370), *p.Labels[0].ID) + assert.Equal(t, "bug", *p.Labels[0].Name) + } + assert.Nil(t, p.Milestone) + if assert.NotNil(t, p.Head) { + assert.Equal(t, "6543-patch-1", *p.Head.Ref) + assert.Equal(t, "36b5813240a9d2daa29b05046d56a53e18f39a3e", *p.Head.SHA) + } + if assert.NotNil(t, p.Base) { + assert.Equal(t, "main", *p.Base.Ref) + assert.Equal(t, "67012991d6c69b1c58378346fca366b864d8d1a1", *p.Base.SHA) + } + } + }) + + // assigne change will result two webhooks an assigned and unassigned + + t.Run("pull request unassigned", func(t *testing.T) { + req := testHookRequest([]byte(fixtures.HookPullRequestAssigneeRemoved), hookPull) + p, r, b, err := parseHook(req, false) + assert.NoError(t, err) + assert.NotNil(t, r) + assert.NotNil(t, b) + assert.Equal(t, model.EventPullMetadata, b.Event) + assert.Equal(t, []string{"unassigned"}, b.EventReason) + if assert.NotNil(t, p) { + assert.Equal(t, int64(2705176047), *p.ID) + assert.Equal(t, 1, *p.Number) + assert.Equal(t, "open", *p.State) + assert.Equal(t, "Some ned more AAAA", *p.Title) + if assert.NotNil(t, p.User) { + assert.Equal(t, "6543", *p.User.Login) + assert.Equal(t, int64(24977596), *p.User.ID) + } + assert.Nil(t, p.Assignee) + assert.Empty(t, p.Assignees) + if assert.Len(t, p.Labels, 1) { + assert.Equal(t, int64(9024465370), *p.Labels[0].ID) + assert.Equal(t, "bug", *p.Labels[0].Name) + } + assert.Nil(t, p.Milestone) + if assert.NotNil(t, p.Head) { + assert.Equal(t, "6543-patch-1", *p.Head.Ref) + assert.Equal(t, "36b5813240a9d2daa29b05046d56a53e18f39a3e", *p.Head.SHA) + } + if assert.NotNil(t, p.Base) { + assert.Equal(t, "main", *p.Base.Ref) + assert.Equal(t, "67012991d6c69b1c58378346fca366b864d8d1a1", *p.Base.SHA) + } + } }) } diff --git a/server/forge/gitlab/convert.go b/server/forge/gitlab/convert.go index d7262639220..ea5ddaafd06 100644 --- a/server/forge/gitlab/convert.go +++ b/server/forge/gitlab/convert.go @@ -23,6 +23,8 @@ import ( gitlab "gitlab.com/gitlab-org/api/client-go" + "go.woodpecker-ci.org/woodpecker/v3/server/forge/common" + "go.woodpecker-ci.org/woodpecker/v3/server/forge/types" "go.woodpecker-ci.org/woodpecker/v3/server/model" "go.woodpecker-ci.org/woodpecker/v3/shared/utils" ) @@ -30,6 +32,25 @@ import ( const ( mergeRefs = "refs/merge-requests/%d/head" // merge request merged with base VisibilityLevelInternal = 10 + + stateOpened = "opened" + + actionOpen = "open" + actionClose = "close" + actionReopen = "reopen" + actionMerge = "merge" + actionUpdate = "update" + + metadataReasonAssigned = "assigned" + metadataReasonUnassigned = "unassigned" + metadataReasonMilestoned = "milestoned" + metadataReasonDemilestoned = "demilestoned" + metadataReasonTitleEdited = "title_edited" + metadataReasonDescriptionEdited = "description_edited" + metadataReasonLabelsAdded = "labels_added" + metadataReasonLabelsCleared = "labels_cleared" + metadataReasonLabelsUpdated = "labels_updated" + metadataReasonReviewRequested = "review_requested" ) func (g *GitLab) convertGitLabRepo(_repo *gitlab.Project, projectMember *gitlab.ProjectMember) (*model.Repo, error) { @@ -71,6 +92,81 @@ func convertMergeRequestHook(hook *gitlab.MergeEvent, req *http.Request) (mergeI source := hook.ObjectAttributes.Source obj := hook.ObjectAttributes + switch obj.Action { + case actionClose, actionMerge: + // pull close event + pipeline.Event = model.EventPullClosed + + case actionOpen, actionReopen: + // pull open event -> pull event + pipeline.Event = model.EventPull + + case actionUpdate: + if obj.OldRev != "" && obj.State == stateOpened { + // if some git action happened then OldRev != "" -> it's a normal pull_request trigger + // https://github.com/woodpecker-ci/woodpecker/pull/3338 + // https://docs.gitlab.com/ee/user/project/integrations/webhook_events.html#merge-request-events + pipeline.Event = model.EventPull + break + } + + pipeline.Event = model.EventPullMetadata + // All changes are just update actions ... so we have to look into the changes section + var reason []string + if len(hook.Changes.Assignees.Current) != 0 { + reason = append(reason, metadataReasonAssigned) + } + if len(hook.Changes.Assignees.Previous) != 0 { + reason = append(reason, metadataReasonUnassigned) + } + + if hook.Changes.MilestoneID.Current != 0 { + reason = append(reason, metadataReasonMilestoned) + } + if hook.Changes.MilestoneID.Previous != 0 { + reason = append(reason, metadataReasonDemilestoned) + } + + if len(hook.Changes.Title.Current) != 0 || len(hook.Changes.Title.Previous) != 0 { + reason = append(reason, metadataReasonTitleEdited) + } + + if len(hook.Changes.Description.Current) != 0 || len(hook.Changes.Description.Previous) != 0 { + reason = append(reason, metadataReasonDescriptionEdited) + } + + switch { + case len(hook.Changes.Labels.Current) != 0 && len(hook.Changes.Labels.Previous) == 0: + reason = append(reason, metadataReasonLabelsAdded) + case len(hook.Changes.Labels.Current) == 0 && len(hook.Changes.Labels.Previous) != 0: + reason = append(reason, metadataReasonLabelsCleared) + case len(hook.Changes.Labels.Current) != 0 && len(hook.Changes.Labels.Previous) != 0: + reason = append(reason, metadataReasonLabelsUpdated) + } + + if len(hook.Changes.Reviewers.Current) > len(hook.Changes.Reviewers.Previous) { + reason = append(reason, metadataReasonReviewRequested) + } + + for i := range reason { + reason[i] = common.NormalizeEventReason(reason[i]) + } + + pipeline.EventReason = reason + if len(pipeline.EventReason) == 0 { + return 0, 0, nil, nil, &types.ErrIgnoreEvent{ + Event: "Merge Request Hook", + Reason: fmt.Sprintf("Action '%s' no supported changes detected", obj.Action), + } + } + default: + // non supported action + return 0, 0, nil, nil, &types.ErrIgnoreEvent{ + Event: "Merge Request Hook", + Reason: fmt.Sprintf("Action '%s' not supported", obj.Action), + } + } + switch { case target == nil && source == nil: return 0, 0, nil, nil, fmt.Errorf("target and source keys expected in merge request hook") @@ -112,11 +208,6 @@ func convertMergeRequestHook(hook *gitlab.MergeEvent, req *http.Request) (mergeI repo.Avatar = target.AvatarURL } - pipeline.Event = model.EventPull - if obj.State == "closed" || obj.State == "merged" { - pipeline.Event = model.EventPullClosed - } - lastCommit := obj.LastCommit pipeline.Message = lastCommit.Message diff --git a/server/forge/gitlab/fixtures/HookPullRequestAssigned.json b/server/forge/gitlab/fixtures/HookPullRequestAssigned.json new file mode 100644 index 00000000000..eb4bf435f12 --- /dev/null +++ b/server/forge/gitlab/fixtures/HookPullRequestAssigned.json @@ -0,0 +1,183 @@ +{ + "object_kind": "merge_request", + "event_type": "merge_request", + "user": { + "id": 4575606, + "name": "6543", + "username": "real6543", + "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/4575606/avatar.png", + "email": "[REDACTED]" + }, + "project": { + "id": 72081820, + "name": "test_ci_tmp", + "description": null, + "web_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "avatar_url": null, + "git_ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "git_http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git", + "namespace": "demoaccount2-commits-group", + "visibility_level": 0, + "path_with_namespace": "demoaccount2-commits-group/test_ci_tmp", + "default_branch": "main", + "ci_config_path": "", + "homepage": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git" + }, + "object_attributes": { + "assignee_id": 4575606, + "author_id": 4575606, + "created_at": "2025-08-05 21:48:25 UTC", + "description": ":tada: text that you might read eventually.", + "draft": false, + "head_pipeline_id": null, + "id": 405095454, + "iid": 3, + "last_edited_at": "2025-08-05 22:01:30 UTC", + "last_edited_by_id": 4575606, + "merge_commit_sha": null, + "merge_error": null, + "merge_params": { + "force_remove_source_branch": "0" + }, + "merge_status": "can_be_merged", + "merge_user_id": null, + "merge_when_pipeline_succeeds": false, + "milestone_id": 6088906, + "source_branch": "real6543-main-patch-42541", + "source_project_id": 72081820, + "state_id": 1, + "target_branch": "main", + "target_project_id": 72081820, + "time_estimate": 0, + "title": "Edit README for more text to read", + "updated_at": "2025-08-06 01:23:04 UTC", + "updated_by_id": 4575606, + "prepared_at": "2025-08-05 21:48:27 UTC", + "assignee_ids": [4575606], + "blocking_discussions_resolved": true, + "detailed_merge_status": "mergeable", + "first_contribution": true, + "human_time_change": null, + "human_time_estimate": null, + "human_total_time_spent": null, + "labels": [ + { + "id": 41869666, + "title": "good first issue", + "color": "#7057ff", + "project_id": 72081820, + "created_at": "2025-07-30 00:40:00 UTC", + "updated_at": "2025-07-30 00:40:00 UTC", + "template": false, + "description": null, + "type": "ProjectLabel", + "group_id": null + } + ], + "last_commit": { + "id": "2f7670508b771e7e77839402be8b34b13787aba8", + "message": "Edit README.md", + "title": "Edit README.md", + "timestamp": "2025-08-05T21:45:58+00:00", + "url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp/-/commit/2f7670508b771e7e77839402be8b34b13787aba8", + "author": { + "name": "6543", + "email": "[REDACTED]" + } + }, + "reviewer_ids": [], + "source": { + "id": 72081820, + "name": "test_ci_tmp", + "description": null, + "web_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "avatar_url": null, + "git_ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "git_http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git", + "namespace": "demoaccount2-commits-group", + "visibility_level": 0, + "path_with_namespace": "demoaccount2-commits-group/test_ci_tmp", + "default_branch": "main", + "ci_config_path": "", + "homepage": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git" + }, + "state": "opened", + "target": { + "id": 72081820, + "name": "test_ci_tmp", + "description": null, + "web_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "avatar_url": null, + "git_ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "git_http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git", + "namespace": "demoaccount2-commits-group", + "visibility_level": 0, + "path_with_namespace": "demoaccount2-commits-group/test_ci_tmp", + "default_branch": "main", + "ci_config_path": "", + "homepage": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git" + }, + "time_change": 0, + "total_time_spent": 0, + "url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp/-/merge_requests/3", + "work_in_progress": false, + "approval_rules": [], + "action": "update" + }, + "labels": [ + { + "id": 41869666, + "title": "good first issue", + "color": "#7057ff", + "project_id": 72081820, + "created_at": "2025-07-30 00:40:00 UTC", + "updated_at": "2025-07-30 00:40:00 UTC", + "template": false, + "description": null, + "type": "ProjectLabel", + "group_id": null + } + ], + "changes": { + "updated_at": { + "previous": "2025-08-06 01:21:37 UTC", + "current": "2025-08-06 01:23:04 UTC" + }, + "assignees": { + "previous": [], + "current": [ + { + "id": 4575606, + "name": "6543", + "username": "real6543", + "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/4575606/avatar.png", + "email": "[REDACTED]" + } + ] + } + }, + "repository": { + "name": "test_ci_tmp", + "url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "description": null, + "homepage": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp" + }, + "assignees": [ + { + "id": 4575606, + "name": "6543", + "username": "real6543", + "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/4575606/avatar.png", + "email": "[REDACTED]" + } + ] +} diff --git a/server/forge/gitlab/fixtures/HookPullRequestDemilestoned.json b/server/forge/gitlab/fixtures/HookPullRequestDemilestoned.json new file mode 100644 index 00000000000..519b4e6b08b --- /dev/null +++ b/server/forge/gitlab/fixtures/HookPullRequestDemilestoned.json @@ -0,0 +1,175 @@ +{ + "object_kind": "merge_request", + "event_type": "merge_request", + "user": { + "id": 4575606, + "name": "6543", + "username": "real6543", + "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/4575606/avatar.png", + "email": "[REDACTED]" + }, + "project": { + "id": 72081820, + "name": "test_ci_tmp", + "description": null, + "web_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "avatar_url": null, + "git_ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "git_http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git", + "namespace": "demoaccount2-commits-group", + "visibility_level": 0, + "path_with_namespace": "demoaccount2-commits-group/test_ci_tmp", + "default_branch": "main", + "ci_config_path": "", + "homepage": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git" + }, + "object_attributes": { + "assignee_id": 29352624, + "author_id": 4575606, + "created_at": "2025-08-05 21:48:25 UTC", + "description": ":tada: text that you might read eventually.", + "draft": false, + "head_pipeline_id": null, + "id": 405095454, + "iid": 3, + "last_edited_at": "2025-08-05 22:01:30 UTC", + "last_edited_by_id": 4575606, + "merge_commit_sha": null, + "merge_error": null, + "merge_params": { + "force_remove_source_branch": "0" + }, + "merge_status": "can_be_merged", + "merge_user_id": null, + "merge_when_pipeline_succeeds": false, + "milestone_id": null, + "source_branch": "real6543-main-patch-42541", + "source_project_id": 72081820, + "state_id": 1, + "target_branch": "main", + "target_project_id": 72081820, + "time_estimate": 0, + "title": "Edit README for more text to read", + "updated_at": "2025-08-06 01:25:34 UTC", + "updated_by_id": 4575606, + "prepared_at": "2025-08-05 21:48:27 UTC", + "assignee_ids": [29352624], + "blocking_discussions_resolved": true, + "detailed_merge_status": "mergeable", + "first_contribution": true, + "human_time_change": null, + "human_time_estimate": null, + "human_total_time_spent": null, + "labels": [ + { + "id": 41869666, + "title": "good first issue", + "color": "#7057ff", + "project_id": 72081820, + "created_at": "2025-07-30 00:40:00 UTC", + "updated_at": "2025-07-30 00:40:00 UTC", + "template": false, + "description": null, + "type": "ProjectLabel", + "group_id": null + } + ], + "last_commit": { + "id": "2f7670508b771e7e77839402be8b34b13787aba8", + "message": "Edit README.md", + "title": "Edit README.md", + "timestamp": "2025-08-05T21:45:58+00:00", + "url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp/-/commit/2f7670508b771e7e77839402be8b34b13787aba8", + "author": { + "name": "6543", + "email": "[REDACTED]" + } + }, + "reviewer_ids": [], + "source": { + "id": 72081820, + "name": "test_ci_tmp", + "description": null, + "web_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "avatar_url": null, + "git_ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "git_http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git", + "namespace": "demoaccount2-commits-group", + "visibility_level": 0, + "path_with_namespace": "demoaccount2-commits-group/test_ci_tmp", + "default_branch": "main", + "ci_config_path": "", + "homepage": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git" + }, + "state": "opened", + "target": { + "id": 72081820, + "name": "test_ci_tmp", + "description": null, + "web_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "avatar_url": null, + "git_ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "git_http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git", + "namespace": "demoaccount2-commits-group", + "visibility_level": 0, + "path_with_namespace": "demoaccount2-commits-group/test_ci_tmp", + "default_branch": "main", + "ci_config_path": "", + "homepage": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git" + }, + "time_change": 0, + "total_time_spent": 0, + "url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp/-/merge_requests/3", + "work_in_progress": false, + "approval_rules": [], + "action": "update" + }, + "labels": [ + { + "id": 41869666, + "title": "good first issue", + "color": "#7057ff", + "project_id": 72081820, + "created_at": "2025-07-30 00:40:00 UTC", + "updated_at": "2025-07-30 00:40:00 UTC", + "template": false, + "description": null, + "type": "ProjectLabel", + "group_id": null + } + ], + "changes": { + "milestone_id": { + "previous": 6088906, + "current": null + }, + "updated_at": { + "previous": "2025-08-06 01:24:11 UTC", + "current": "2025-08-06 01:25:34 UTC" + } + }, + "repository": { + "name": "test_ci_tmp", + "url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "description": null, + "homepage": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp" + }, + "assignees": [ + { + "id": 29352624, + "name": "demoaccount2-commits", + "username": "demoaccount2-commits", + "avatar_url": "https://secure.gravatar.com/avatar/510e64831d3748ef1d2143c4a9766c30684f17991b31ee23ece8bb2f26a35fc2?s=80&d=identicon", + "email": "[REDACTED]" + } + ] +} diff --git a/server/forge/gitlab/fixtures/HookPullRequestEdited.json b/server/forge/gitlab/fixtures/HookPullRequestEdited.json new file mode 100644 index 00000000000..70c75096cda --- /dev/null +++ b/server/forge/gitlab/fixtures/HookPullRequestEdited.json @@ -0,0 +1,191 @@ +{ + "object_kind": "merge_request", + "event_type": "merge_request", + "user": { + "id": 4575606, + "name": "6543", + "username": "real6543", + "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/4575606/avatar.png", + "email": "[REDACTED]" + }, + "project": { + "id": 72081820, + "name": "test_ci_tmp", + "description": null, + "web_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "avatar_url": null, + "git_ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "git_http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git", + "namespace": "demoaccount2-commits-group", + "visibility_level": 0, + "path_with_namespace": "demoaccount2-commits-group/test_ci_tmp", + "default_branch": "main", + "ci_config_path": "", + "homepage": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git" + }, + "object_attributes": { + "assignee_id": 4575606, + "author_id": 4575606, + "created_at": "2025-08-05 21:48:25 UTC", + "description": ":tada: text that you might read eventually.", + "draft": false, + "head_pipeline_id": null, + "id": 405095454, + "iid": 3, + "last_edited_at": "2025-08-05 22:01:30 UTC", + "last_edited_by_id": 4575606, + "merge_commit_sha": null, + "merge_error": null, + "merge_params": { + "force_remove_source_branch": "0" + }, + "merge_status": "can_be_merged", + "merge_user_id": null, + "merge_when_pipeline_succeeds": false, + "milestone_id": 6088906, + "source_branch": "real6543-main-patch-42541", + "source_project_id": 72081820, + "state_id": 1, + "target_branch": "main", + "target_project_id": 72081820, + "time_estimate": 0, + "title": "Edit README for more text to read", + "updated_at": "2025-08-05 22:01:30 UTC", + "updated_by_id": 4575606, + "prepared_at": "2025-08-05 21:48:27 UTC", + "assignee_ids": [4575606], + "blocking_discussions_resolved": true, + "detailed_merge_status": "mergeable", + "first_contribution": true, + "human_time_change": null, + "human_time_estimate": null, + "human_total_time_spent": null, + "labels": [ + { + "id": 41869663, + "title": "documentation", + "color": "#0075ca", + "project_id": 72081820, + "created_at": "2025-07-30 00:40:00 UTC", + "updated_at": "2025-07-30 00:40:00 UTC", + "template": false, + "description": null, + "type": "ProjectLabel", + "group_id": null + } + ], + "last_commit": { + "id": "2f7670508b771e7e77839402be8b34b13787aba8", + "message": "Edit README.md", + "title": "Edit README.md", + "timestamp": "2025-08-05T21:45:58+00:00", + "url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp/-/commit/2f7670508b771e7e77839402be8b34b13787aba8", + "author": { + "name": "6543", + "email": "[REDACTED]" + } + }, + "reviewer_ids": [], + "source": { + "id": 72081820, + "name": "test_ci_tmp", + "description": null, + "web_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "avatar_url": null, + "git_ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "git_http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git", + "namespace": "demoaccount2-commits-group", + "visibility_level": 0, + "path_with_namespace": "demoaccount2-commits-group/test_ci_tmp", + "default_branch": "main", + "ci_config_path": "", + "homepage": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git" + }, + "state": "opened", + "target": { + "id": 72081820, + "name": "test_ci_tmp", + "description": null, + "web_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "avatar_url": null, + "git_ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "git_http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git", + "namespace": "demoaccount2-commits-group", + "visibility_level": 0, + "path_with_namespace": "demoaccount2-commits-group/test_ci_tmp", + "default_branch": "main", + "ci_config_path": "", + "homepage": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git" + }, + "time_change": 0, + "total_time_spent": 0, + "url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp/-/merge_requests/3", + "work_in_progress": false, + "approval_rules": [], + "action": "update" + }, + "labels": [ + { + "id": 41869663, + "title": "documentation", + "color": "#0075ca", + "project_id": 72081820, + "created_at": "2025-07-30 00:40:00 UTC", + "updated_at": "2025-07-30 00:40:00 UTC", + "template": false, + "description": null, + "type": "ProjectLabel", + "group_id": null + } + ], + "changes": { + "description": { + "previous": ":tada: text that you might read eventually", + "current": ":tada: text that you might read eventually." + }, + "last_edited_at": { + "previous": null, + "current": "2025-08-05 22:01:30 UTC" + }, + "last_edited_by_id": { + "previous": null, + "current": 4575606 + }, + "title": { + "previous": "Edit README.md for more text to read", + "current": "Edit README for more text to read" + }, + "updated_at": { + "previous": "2025-08-05 21:48:27 UTC", + "current": "2025-08-05 22:01:30 UTC" + }, + "updated_by_id": { + "previous": null, + "current": 4575606 + } + }, + "repository": { + "name": "test_ci_tmp", + "url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "description": null, + "homepage": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp" + }, + "assignees": [ + { + "id": 4575606, + "name": "6543", + "username": "real6543", + "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/4575606/avatar.png", + "email": "[REDACTED]" + } + ] +} diff --git a/server/forge/gitlab/fixtures/HookPullRequestLabelsAdded.json b/server/forge/gitlab/fixtures/HookPullRequestLabelsAdded.json new file mode 100644 index 00000000000..2bde847f60c --- /dev/null +++ b/server/forge/gitlab/fixtures/HookPullRequestLabelsAdded.json @@ -0,0 +1,175 @@ +{ + "object_kind": "merge_request", + "event_type": "merge_request", + "user": { + "id": 4575606, + "name": "6543", + "username": "real6543", + "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/4575606/avatar.png", + "email": "[REDACTED]" + }, + "project": { + "id": 72081820, + "name": "test_ci_tmp", + "description": null, + "web_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "avatar_url": null, + "git_ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "git_http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git", + "namespace": "demoaccount2-commits-group", + "visibility_level": 0, + "path_with_namespace": "demoaccount2-commits-group/test_ci_tmp", + "default_branch": "main", + "ci_config_path": "", + "homepage": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git" + }, + "object_attributes": { + "assignee_id": null, + "author_id": 4575606, + "created_at": "2025-08-05 21:48:25 UTC", + "description": ":tada: text that you might read eventually.", + "draft": false, + "head_pipeline_id": null, + "id": 405095454, + "iid": 3, + "last_edited_at": "2025-08-05 22:01:30 UTC", + "last_edited_by_id": 4575606, + "merge_commit_sha": null, + "merge_error": null, + "merge_params": { + "force_remove_source_branch": "0" + }, + "merge_status": "can_be_merged", + "merge_user_id": null, + "merge_when_pipeline_succeeds": false, + "milestone_id": 6088906, + "source_branch": "real6543-main-patch-42541", + "source_project_id": 72081820, + "state_id": 1, + "target_branch": "main", + "target_project_id": 72081820, + "time_estimate": 0, + "title": "Edit README for more text to read", + "updated_at": "2025-08-06 01:21:37 UTC", + "updated_by_id": 4575606, + "prepared_at": "2025-08-05 21:48:27 UTC", + "assignee_ids": [], + "blocking_discussions_resolved": true, + "detailed_merge_status": "mergeable", + "first_contribution": true, + "human_time_change": null, + "human_time_estimate": null, + "human_total_time_spent": null, + "labels": [ + { + "id": 41869666, + "title": "good first issue", + "color": "#7057ff", + "project_id": 72081820, + "created_at": "2025-07-30 00:40:00 UTC", + "updated_at": "2025-07-30 00:40:00 UTC", + "template": false, + "description": null, + "type": "ProjectLabel", + "group_id": null + } + ], + "last_commit": { + "id": "2f7670508b771e7e77839402be8b34b13787aba8", + "message": "Edit README.md", + "title": "Edit README.md", + "timestamp": "2025-08-05T21:45:58+00:00", + "url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp/-/commit/2f7670508b771e7e77839402be8b34b13787aba8", + "author": { + "name": "6543", + "email": "[REDACTED]" + } + }, + "reviewer_ids": [], + "source": { + "id": 72081820, + "name": "test_ci_tmp", + "description": null, + "web_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "avatar_url": null, + "git_ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "git_http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git", + "namespace": "demoaccount2-commits-group", + "visibility_level": 0, + "path_with_namespace": "demoaccount2-commits-group/test_ci_tmp", + "default_branch": "main", + "ci_config_path": "", + "homepage": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git" + }, + "state": "opened", + "target": { + "id": 72081820, + "name": "test_ci_tmp", + "description": null, + "web_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "avatar_url": null, + "git_ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "git_http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git", + "namespace": "demoaccount2-commits-group", + "visibility_level": 0, + "path_with_namespace": "demoaccount2-commits-group/test_ci_tmp", + "default_branch": "main", + "ci_config_path": "", + "homepage": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git" + }, + "time_change": 0, + "total_time_spent": 0, + "url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp/-/merge_requests/3", + "work_in_progress": false, + "approval_rules": [], + "action": "update" + }, + "labels": [ + { + "id": 41869666, + "title": "good first issue", + "color": "#7057ff", + "project_id": 72081820, + "created_at": "2025-07-30 00:40:00 UTC", + "updated_at": "2025-07-30 00:40:00 UTC", + "template": false, + "description": null, + "type": "ProjectLabel", + "group_id": null + } + ], + "changes": { + "labels": { + "previous": [], + "current": [ + { + "id": 41869666, + "title": "good first issue", + "color": "#7057ff", + "project_id": 72081820, + "created_at": "2025-07-30 00:40:00 UTC", + "updated_at": "2025-07-30 00:40:00 UTC", + "template": false, + "description": null, + "type": "ProjectLabel", + "group_id": null + } + ] + } + }, + "repository": { + "name": "test_ci_tmp", + "url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "description": null, + "homepage": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp" + } +} diff --git a/server/forge/gitlab/fixtures/HookPullRequestLabelsCleared.json b/server/forge/gitlab/fixtures/HookPullRequestLabelsCleared.json new file mode 100644 index 00000000000..9c935de8673 --- /dev/null +++ b/server/forge/gitlab/fixtures/HookPullRequestLabelsCleared.json @@ -0,0 +1,165 @@ +{ + "object_kind": "merge_request", + "event_type": "merge_request", + "user": { + "id": 4575606, + "name": "6543", + "username": "real6543", + "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/4575606/avatar.png", + "email": "[REDACTED]" + }, + "project": { + "id": 72081820, + "name": "test_ci_tmp", + "description": null, + "web_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "avatar_url": null, + "git_ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "git_http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git", + "namespace": "demoaccount2-commits-group", + "visibility_level": 0, + "path_with_namespace": "demoaccount2-commits-group/test_ci_tmp", + "default_branch": "main", + "ci_config_path": "", + "homepage": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git" + }, + "object_attributes": { + "assignee_id": null, + "author_id": 4575606, + "created_at": "2025-08-05 21:48:25 UTC", + "description": ":tada: text that you might read eventually.", + "draft": false, + "head_pipeline_id": null, + "id": 405095454, + "iid": 3, + "last_edited_at": "2025-08-05 22:01:30 UTC", + "last_edited_by_id": 4575606, + "merge_commit_sha": null, + "merge_error": null, + "merge_params": { + "force_remove_source_branch": "0" + }, + "merge_status": "can_be_merged", + "merge_user_id": null, + "merge_when_pipeline_succeeds": false, + "milestone_id": 6088906, + "source_branch": "real6543-main-patch-42541", + "source_project_id": 72081820, + "state_id": 1, + "target_branch": "main", + "target_project_id": 72081820, + "time_estimate": 0, + "title": "Edit README for more text to read", + "updated_at": "2025-08-06 01:21:37 UTC", + "updated_by_id": 4575606, + "prepared_at": "2025-08-05 21:48:27 UTC", + "assignee_ids": [], + "blocking_discussions_resolved": true, + "detailed_merge_status": "mergeable", + "first_contribution": true, + "human_time_change": null, + "human_time_estimate": null, + "human_total_time_spent": null, + "labels": [], + "last_commit": { + "id": "2f7670508b771e7e77839402be8b34b13787aba8", + "message": "Edit README.md", + "title": "Edit README.md", + "timestamp": "2025-08-05T21:45:58+00:00", + "url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp/-/commit/2f7670508b771e7e77839402be8b34b13787aba8", + "author": { + "name": "6543", + "email": "[REDACTED]" + } + }, + "reviewer_ids": [], + "source": { + "id": 72081820, + "name": "test_ci_tmp", + "description": null, + "web_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "avatar_url": null, + "git_ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "git_http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git", + "namespace": "demoaccount2-commits-group", + "visibility_level": 0, + "path_with_namespace": "demoaccount2-commits-group/test_ci_tmp", + "default_branch": "main", + "ci_config_path": "", + "homepage": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git" + }, + "state": "opened", + "target": { + "id": 72081820, + "name": "test_ci_tmp", + "description": null, + "web_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "avatar_url": null, + "git_ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "git_http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git", + "namespace": "demoaccount2-commits-group", + "visibility_level": 0, + "path_with_namespace": "demoaccount2-commits-group/test_ci_tmp", + "default_branch": "main", + "ci_config_path": "", + "homepage": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git" + }, + "time_change": 0, + "total_time_spent": 0, + "url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp/-/merge_requests/3", + "work_in_progress": false, + "approval_rules": [], + "action": "update" + }, + "labels": [], + "changes": { + "updated_at": { + "previous": "2025-08-06 01:20:04 UTC", + "current": "2025-08-06 01:21:37 UTC" + }, + "labels": { + "previous": [ + { + "id": 41869665, + "title": "enhancement", + "color": "#a2eeef", + "project_id": 72081820, + "created_at": "2025-07-30 00:40:00 UTC", + "updated_at": "2025-07-30 00:40:00 UTC", + "template": false, + "description": null, + "type": "ProjectLabel", + "group_id": null + }, + { + "id": 41869667, + "title": "help wanted", + "color": "#008672", + "project_id": 72081820, + "created_at": "2025-07-30 00:40:00 UTC", + "updated_at": "2025-07-30 00:40:00 UTC", + "template": false, + "description": null, + "type": "ProjectLabel", + "group_id": null + } + ], + "current": [] + } + }, + "repository": { + "name": "test_ci_tmp", + "url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "description": null, + "homepage": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp" + } +} diff --git a/server/forge/gitlab/fixtures/HookPullRequestLabelsUpdated.json b/server/forge/gitlab/fixtures/HookPullRequestLabelsUpdated.json new file mode 100644 index 00000000000..1f6fa2a9217 --- /dev/null +++ b/server/forge/gitlab/fixtures/HookPullRequestLabelsUpdated.json @@ -0,0 +1,228 @@ +{ + "object_kind": "merge_request", + "event_type": "merge_request", + "user": { + "id": 4575606, + "name": "6543", + "username": "real6543", + "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/4575606/avatar.png", + "email": "[REDACTED]" + }, + "project": { + "id": 72081820, + "name": "test_ci_tmp", + "description": null, + "web_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "avatar_url": null, + "git_ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "git_http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git", + "namespace": "demoaccount2-commits-group", + "visibility_level": 0, + "path_with_namespace": "demoaccount2-commits-group/test_ci_tmp", + "default_branch": "main", + "ci_config_path": "", + "homepage": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git" + }, + "object_attributes": { + "assignee_id": null, + "author_id": 4575606, + "created_at": "2025-08-05 21:48:25 UTC", + "description": ":tada: text that you might read eventually.", + "draft": false, + "head_pipeline_id": null, + "id": 405095454, + "iid": 3, + "last_edited_at": "2025-08-05 22:01:30 UTC", + "last_edited_by_id": 4575606, + "merge_commit_sha": null, + "merge_error": null, + "merge_params": { + "force_remove_source_branch": "0" + }, + "merge_status": "can_be_merged", + "merge_user_id": null, + "merge_when_pipeline_succeeds": false, + "milestone_id": 6088906, + "source_branch": "real6543-main-patch-42541", + "source_project_id": 72081820, + "state_id": 1, + "target_branch": "main", + "target_project_id": 72081820, + "time_estimate": 0, + "title": "Edit README for more text to read", + "updated_at": "2025-08-06 01:20:04 UTC", + "updated_by_id": 4575606, + "prepared_at": "2025-08-05 21:48:27 UTC", + "assignee_ids": [], + "blocking_discussions_resolved": true, + "detailed_merge_status": "mergeable", + "first_contribution": true, + "human_time_change": null, + "human_time_estimate": null, + "human_total_time_spent": null, + "labels": [ + { + "id": 41869665, + "title": "enhancement", + "color": "#a2eeef", + "project_id": 72081820, + "created_at": "2025-07-30 00:40:00 UTC", + "updated_at": "2025-07-30 00:40:00 UTC", + "template": false, + "description": null, + "type": "ProjectLabel", + "group_id": null + }, + { + "id": 41869667, + "title": "help wanted", + "color": "#008672", + "project_id": 72081820, + "created_at": "2025-07-30 00:40:00 UTC", + "updated_at": "2025-07-30 00:40:00 UTC", + "template": false, + "description": null, + "type": "ProjectLabel", + "group_id": null + } + ], + "last_commit": { + "id": "2f7670508b771e7e77839402be8b34b13787aba8", + "message": "Edit README.md", + "title": "Edit README.md", + "timestamp": "2025-08-05T21:45:58+00:00", + "url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp/-/commit/2f7670508b771e7e77839402be8b34b13787aba8", + "author": { + "name": "6543", + "email": "[REDACTED]" + } + }, + "reviewer_ids": [], + "source": { + "id": 72081820, + "name": "test_ci_tmp", + "description": null, + "web_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "avatar_url": null, + "git_ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "git_http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git", + "namespace": "demoaccount2-commits-group", + "visibility_level": 0, + "path_with_namespace": "demoaccount2-commits-group/test_ci_tmp", + "default_branch": "main", + "ci_config_path": "", + "homepage": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git" + }, + "state": "opened", + "target": { + "id": 72081820, + "name": "test_ci_tmp", + "description": null, + "web_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "avatar_url": null, + "git_ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "git_http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git", + "namespace": "demoaccount2-commits-group", + "visibility_level": 0, + "path_with_namespace": "demoaccount2-commits-group/test_ci_tmp", + "default_branch": "main", + "ci_config_path": "", + "homepage": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git" + }, + "time_change": 0, + "total_time_spent": 0, + "url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp/-/merge_requests/3", + "work_in_progress": false, + "approval_rules": [], + "action": "update" + }, + "labels": [ + { + "id": 41869665, + "title": "enhancement", + "color": "#a2eeef", + "project_id": 72081820, + "created_at": "2025-07-30 00:40:00 UTC", + "updated_at": "2025-07-30 00:40:00 UTC", + "template": false, + "description": null, + "type": "ProjectLabel", + "group_id": null + }, + { + "id": 41869667, + "title": "help wanted", + "color": "#008672", + "project_id": 72081820, + "created_at": "2025-07-30 00:40:00 UTC", + "updated_at": "2025-07-30 00:40:00 UTC", + "template": false, + "description": null, + "type": "ProjectLabel", + "group_id": null + } + ], + "changes": { + "updated_at": { + "previous": "2025-08-06 01:18:10 UTC", + "current": "2025-08-06 01:20:04 UTC" + }, + "labels": { + "previous": [ + { + "id": 41869663, + "title": "documentation", + "color": "#0075ca", + "project_id": 72081820, + "created_at": "2025-07-30 00:40:00 UTC", + "updated_at": "2025-07-30 00:40:00 UTC", + "template": false, + "description": null, + "type": "ProjectLabel", + "group_id": null + } + ], + "current": [ + { + "id": 41869665, + "title": "enhancement", + "color": "#a2eeef", + "project_id": 72081820, + "created_at": "2025-07-30 00:40:00 UTC", + "updated_at": "2025-07-30 00:40:00 UTC", + "template": false, + "description": null, + "type": "ProjectLabel", + "group_id": null + }, + { + "id": 41869667, + "title": "help wanted", + "color": "#008672", + "project_id": 72081820, + "created_at": "2025-07-30 00:40:00 UTC", + "updated_at": "2025-07-30 00:40:00 UTC", + "template": false, + "description": null, + "type": "ProjectLabel", + "group_id": null + } + ] + } + }, + "repository": { + "name": "test_ci_tmp", + "url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "description": null, + "homepage": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp" + } +} diff --git a/server/forge/gitlab/fixtures/HookPullRequestMilestoned.json b/server/forge/gitlab/fixtures/HookPullRequestMilestoned.json new file mode 100644 index 00000000000..5343e8c8cdb --- /dev/null +++ b/server/forge/gitlab/fixtures/HookPullRequestMilestoned.json @@ -0,0 +1,175 @@ +{ + "object_kind": "merge_request", + "event_type": "merge_request", + "user": { + "id": 4575606, + "name": "6543", + "username": "real6543", + "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/4575606/avatar.png", + "email": "[REDACTED]" + }, + "project": { + "id": 72081820, + "name": "test_ci_tmp", + "description": null, + "web_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "avatar_url": null, + "git_ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "git_http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git", + "namespace": "demoaccount2-commits-group", + "visibility_level": 0, + "path_with_namespace": "demoaccount2-commits-group/test_ci_tmp", + "default_branch": "main", + "ci_config_path": "", + "homepage": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git" + }, + "object_attributes": { + "assignee_id": 29352624, + "author_id": 4575606, + "created_at": "2025-08-05 21:48:25 UTC", + "description": ":tada: text that you might read eventually.", + "draft": false, + "head_pipeline_id": null, + "id": 405095454, + "iid": 3, + "last_edited_at": "2025-08-05 22:01:30 UTC", + "last_edited_by_id": 4575606, + "merge_commit_sha": null, + "merge_error": null, + "merge_params": { + "force_remove_source_branch": "0" + }, + "merge_status": "can_be_merged", + "merge_user_id": null, + "merge_when_pipeline_succeeds": false, + "milestone_id": 6088906, + "source_branch": "real6543-main-patch-42541", + "source_project_id": 72081820, + "state_id": 1, + "target_branch": "main", + "target_project_id": 72081820, + "time_estimate": 0, + "title": "Edit README for more text to read", + "updated_at": "2025-08-06 01:27:00 UTC", + "updated_by_id": 4575606, + "prepared_at": "2025-08-05 21:48:27 UTC", + "assignee_ids": [29352624], + "blocking_discussions_resolved": true, + "detailed_merge_status": "mergeable", + "first_contribution": true, + "human_time_change": null, + "human_time_estimate": null, + "human_total_time_spent": null, + "labels": [ + { + "id": 41869666, + "title": "good first issue", + "color": "#7057ff", + "project_id": 72081820, + "created_at": "2025-07-30 00:40:00 UTC", + "updated_at": "2025-07-30 00:40:00 UTC", + "template": false, + "description": null, + "type": "ProjectLabel", + "group_id": null + } + ], + "last_commit": { + "id": "2f7670508b771e7e77839402be8b34b13787aba8", + "message": "Edit README.md", + "title": "Edit README.md", + "timestamp": "2025-08-05T21:45:58+00:00", + "url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp/-/commit/2f7670508b771e7e77839402be8b34b13787aba8", + "author": { + "name": "6543", + "email": "[REDACTED]" + } + }, + "reviewer_ids": [], + "source": { + "id": 72081820, + "name": "test_ci_tmp", + "description": null, + "web_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "avatar_url": null, + "git_ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "git_http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git", + "namespace": "demoaccount2-commits-group", + "visibility_level": 0, + "path_with_namespace": "demoaccount2-commits-group/test_ci_tmp", + "default_branch": "main", + "ci_config_path": "", + "homepage": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git" + }, + "state": "opened", + "target": { + "id": 72081820, + "name": "test_ci_tmp", + "description": null, + "web_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "avatar_url": null, + "git_ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "git_http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git", + "namespace": "demoaccount2-commits-group", + "visibility_level": 0, + "path_with_namespace": "demoaccount2-commits-group/test_ci_tmp", + "default_branch": "main", + "ci_config_path": "", + "homepage": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git" + }, + "time_change": 0, + "total_time_spent": 0, + "url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp/-/merge_requests/3", + "work_in_progress": false, + "approval_rules": [], + "action": "update" + }, + "labels": [ + { + "id": 41869666, + "title": "good first issue", + "color": "#7057ff", + "project_id": 72081820, + "created_at": "2025-07-30 00:40:00 UTC", + "updated_at": "2025-07-30 00:40:00 UTC", + "template": false, + "description": null, + "type": "ProjectLabel", + "group_id": null + } + ], + "changes": { + "milestone_id": { + "previous": null, + "current": 6088906 + }, + "updated_at": { + "previous": "2025-08-06 01:25:34 UTC", + "current": "2025-08-06 01:27:00 UTC" + } + }, + "repository": { + "name": "test_ci_tmp", + "url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "description": null, + "homepage": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp" + }, + "assignees": [ + { + "id": 29352624, + "name": "demoaccount2-commits", + "username": "demoaccount2-commits", + "avatar_url": "https://secure.gravatar.com/avatar/510e64831d3748ef1d2143c4a9766c30684f17991b31ee23ece8bb2f26a35fc2?s=80&d=identicon", + "email": "[REDACTED]" + } + ] +} diff --git a/server/forge/gitlab/fixtures/HookPullRequestOpened.json b/server/forge/gitlab/fixtures/HookPullRequestOpened.json new file mode 100644 index 00000000000..486927878ee --- /dev/null +++ b/server/forge/gitlab/fixtures/HookPullRequestOpened.json @@ -0,0 +1,179 @@ +{ + "object_kind": "merge_request", + "event_type": "merge_request", + "user": { + "id": 4575606, + "name": "6543", + "username": "real6543", + "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/4575606/avatar.png", + "email": "[REDACTED]" + }, + "project": { + "id": 72081820, + "name": "test_ci_tmp", + "description": null, + "web_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "avatar_url": null, + "git_ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "git_http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git", + "namespace": "demoaccount2-commits-group", + "visibility_level": 0, + "path_with_namespace": "demoaccount2-commits-group/test_ci_tmp", + "default_branch": "main", + "ci_config_path": "", + "homepage": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git" + }, + "object_attributes": { + "assignee_id": 4575606, + "author_id": 4575606, + "created_at": "2025-08-05 21:48:25 UTC", + "description": ":tada: text that you might read eventually", + "draft": false, + "head_pipeline_id": null, + "id": 405095454, + "iid": 3, + "last_edited_at": null, + "last_edited_by_id": null, + "merge_commit_sha": null, + "merge_error": null, + "merge_params": { + "force_remove_source_branch": "0" + }, + "merge_status": "checking", + "merge_user_id": null, + "merge_when_pipeline_succeeds": false, + "milestone_id": 6088906, + "source_branch": "real6543-main-patch-42541", + "source_project_id": 72081820, + "state_id": 1, + "target_branch": "main", + "target_project_id": 72081820, + "time_estimate": 0, + "title": "Edit README.md for more text to read", + "updated_at": "2025-08-05 21:48:27 UTC", + "updated_by_id": null, + "prepared_at": "2025-08-05 21:48:27 UTC", + "assignee_ids": [4575606], + "blocking_discussions_resolved": true, + "detailed_merge_status": "checking", + "first_contribution": true, + "human_time_change": null, + "human_time_estimate": null, + "human_total_time_spent": null, + "labels": [ + { + "id": 41869663, + "title": "documentation", + "color": "#0075ca", + "project_id": 72081820, + "created_at": "2025-07-30 00:40:00 UTC", + "updated_at": "2025-07-30 00:40:00 UTC", + "template": false, + "description": null, + "type": "ProjectLabel", + "group_id": null + } + ], + "last_commit": { + "id": "2f7670508b771e7e77839402be8b34b13787aba8", + "message": "Edit README.md", + "title": "Edit README.md", + "timestamp": "2025-08-05T21:45:58+00:00", + "url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp/-/commit/2f7670508b771e7e77839402be8b34b13787aba8", + "author": { + "name": "6543", + "email": "[REDACTED]" + } + }, + "reviewer_ids": [], + "source": { + "id": 72081820, + "name": "test_ci_tmp", + "description": null, + "web_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "avatar_url": null, + "git_ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "git_http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git", + "namespace": "demoaccount2-commits-group", + "visibility_level": 0, + "path_with_namespace": "demoaccount2-commits-group/test_ci_tmp", + "default_branch": "main", + "ci_config_path": "", + "homepage": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git" + }, + "state": "opened", + "target": { + "id": 72081820, + "name": "test_ci_tmp", + "description": null, + "web_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "avatar_url": null, + "git_ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "git_http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git", + "namespace": "demoaccount2-commits-group", + "visibility_level": 0, + "path_with_namespace": "demoaccount2-commits-group/test_ci_tmp", + "default_branch": "main", + "ci_config_path": "", + "homepage": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git" + }, + "time_change": 0, + "total_time_spent": 0, + "url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp/-/merge_requests/3", + "work_in_progress": false, + "approval_rules": [], + "action": "open" + }, + "labels": [ + { + "id": 41869663, + "title": "documentation", + "color": "#0075ca", + "project_id": 72081820, + "created_at": "2025-07-30 00:40:00 UTC", + "updated_at": "2025-07-30 00:40:00 UTC", + "template": false, + "description": null, + "type": "ProjectLabel", + "group_id": null + } + ], + "changes": { + "merge_status": { + "previous": "preparing", + "current": "checking" + }, + "updated_at": { + "previous": "2025-08-05 21:48:25 UTC", + "current": "2025-08-05 21:48:27 UTC" + }, + "prepared_at": { + "previous": null, + "current": "2025-08-05 21:48:27 UTC" + } + }, + "repository": { + "name": "test_ci_tmp", + "url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "description": null, + "homepage": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp" + }, + "assignees": [ + { + "id": 4575606, + "name": "6543", + "username": "real6543", + "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/4575606/avatar.png", + "email": "[REDACTED]" + } + ] +} diff --git a/server/forge/gitlab/fixtures/HookPullRequestReviewRequestDel.json b/server/forge/gitlab/fixtures/HookPullRequestReviewRequestDel.json new file mode 100644 index 00000000000..f5896152901 --- /dev/null +++ b/server/forge/gitlab/fixtures/HookPullRequestReviewRequestDel.json @@ -0,0 +1,170 @@ +{ + "object_kind": "merge_request", + "event_type": "merge_request", + "user": { + "id": 4575606, + "name": "6543", + "username": "real6543", + "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/4575606/avatar.png", + "email": "[REDACTED]" + }, + "project": { + "id": 72081820, + "name": "test_ci_tmp", + "description": null, + "web_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "avatar_url": null, + "git_ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "git_http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git", + "namespace": "demoaccount2-commits-group", + "visibility_level": 0, + "path_with_namespace": "demoaccount2-commits-group/test_ci_tmp", + "default_branch": "main", + "ci_config_path": "", + "homepage": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git" + }, + "object_attributes": { + "assignee_id": null, + "author_id": 4575606, + "created_at": "2025-08-05 21:48:25 UTC", + "description": ":tada: text that you might read eventually.", + "draft": false, + "head_pipeline_id": null, + "id": 405095454, + "iid": 3, + "last_edited_at": "2025-08-05 22:01:30 UTC", + "last_edited_by_id": 4575606, + "merge_commit_sha": null, + "merge_error": null, + "merge_params": { + "force_remove_source_branch": "0" + }, + "merge_status": "can_be_merged", + "merge_user_id": null, + "merge_when_pipeline_succeeds": false, + "milestone_id": 6088906, + "source_branch": "real6543-main-patch-42541", + "source_project_id": 72081820, + "state_id": 1, + "target_branch": "main", + "target_project_id": 72081820, + "time_estimate": 0, + "title": "Edit README for more text to read", + "updated_at": "2025-08-06 01:18:10 UTC", + "updated_by_id": 4575606, + "prepared_at": "2025-08-05 21:48:27 UTC", + "assignee_ids": [], + "blocking_discussions_resolved": true, + "detailed_merge_status": "mergeable", + "first_contribution": true, + "human_time_change": null, + "human_time_estimate": null, + "human_total_time_spent": null, + "labels": [ + { + "id": 41869663, + "title": "documentation", + "color": "#0075ca", + "project_id": 72081820, + "created_at": "2025-07-30 00:40:00 UTC", + "updated_at": "2025-07-30 00:40:00 UTC", + "template": false, + "description": null, + "type": "ProjectLabel", + "group_id": null + } + ], + "last_commit": { + "id": "2f7670508b771e7e77839402be8b34b13787aba8", + "message": "Edit README.md", + "title": "Edit README.md", + "timestamp": "2025-08-05T21:45:58+00:00", + "url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp/-/commit/2f7670508b771e7e77839402be8b34b13787aba8", + "author": { + "name": "6543", + "email": "[REDACTED]" + } + }, + "reviewer_ids": [], + "source": { + "id": 72081820, + "name": "test_ci_tmp", + "description": null, + "web_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "avatar_url": null, + "git_ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "git_http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git", + "namespace": "demoaccount2-commits-group", + "visibility_level": 0, + "path_with_namespace": "demoaccount2-commits-group/test_ci_tmp", + "default_branch": "main", + "ci_config_path": "", + "homepage": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git" + }, + "state": "opened", + "target": { + "id": 72081820, + "name": "test_ci_tmp", + "description": null, + "web_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "avatar_url": null, + "git_ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "git_http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git", + "namespace": "demoaccount2-commits-group", + "visibility_level": 0, + "path_with_namespace": "demoaccount2-commits-group/test_ci_tmp", + "default_branch": "main", + "ci_config_path": "", + "homepage": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git" + }, + "time_change": 0, + "total_time_spent": 0, + "url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp/-/merge_requests/3", + "work_in_progress": false, + "approval_rules": [], + "action": "update" + }, + "labels": [ + { + "id": 41869663, + "title": "documentation", + "color": "#0075ca", + "project_id": 72081820, + "created_at": "2025-07-30 00:40:00 UTC", + "updated_at": "2025-07-30 00:40:00 UTC", + "template": false, + "description": null, + "type": "ProjectLabel", + "group_id": null + } + ], + "changes": { + "reviewers": { + "previous": [ + { + "id": 4575606, + "name": "6543", + "username": "real6543", + "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/4575606/avatar.png", + "email": "[REDACTED]" + } + ], + "current": [] + } + }, + "repository": { + "name": "test_ci_tmp", + "url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "description": null, + "homepage": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp" + } +} diff --git a/server/forge/gitlab/fixtures/HookPullRequestReviewRequested.json b/server/forge/gitlab/fixtures/HookPullRequestReviewRequested.json new file mode 100644 index 00000000000..35a109fd226 --- /dev/null +++ b/server/forge/gitlab/fixtures/HookPullRequestReviewRequested.json @@ -0,0 +1,183 @@ +{ + "object_kind": "merge_request", + "event_type": "merge_request", + "user": { + "id": 4575606, + "name": "6543", + "username": "real6543", + "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/4575606/avatar.png", + "email": "[REDACTED]" + }, + "project": { + "id": 72081820, + "name": "test_ci_tmp", + "description": null, + "web_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "avatar_url": null, + "git_ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "git_http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git", + "namespace": "demoaccount2-commits-group", + "visibility_level": 0, + "path_with_namespace": "demoaccount2-commits-group/test_ci_tmp", + "default_branch": "main", + "ci_config_path": "", + "homepage": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git" + }, + "object_attributes": { + "assignee_id": null, + "author_id": 4575606, + "created_at": "2025-08-05 21:48:25 UTC", + "description": ":tada: text that you might read eventually.", + "draft": false, + "head_pipeline_id": null, + "id": 405095454, + "iid": 3, + "last_edited_at": "2025-08-05 22:01:30 UTC", + "last_edited_by_id": 4575606, + "merge_commit_sha": null, + "merge_error": null, + "merge_params": { + "force_remove_source_branch": "0" + }, + "merge_status": "can_be_merged", + "merge_user_id": null, + "merge_when_pipeline_succeeds": false, + "milestone_id": 6088906, + "source_branch": "real6543-main-patch-42541", + "source_project_id": 72081820, + "state_id": 1, + "target_branch": "main", + "target_project_id": 72081820, + "time_estimate": 0, + "title": "Edit README for more text to read", + "updated_at": "2025-08-06 01:11:08 UTC", + "updated_by_id": 4575606, + "prepared_at": "2025-08-05 21:48:27 UTC", + "assignee_ids": [], + "blocking_discussions_resolved": true, + "detailed_merge_status": "mergeable", + "first_contribution": true, + "human_time_change": null, + "human_time_estimate": null, + "human_total_time_spent": null, + "labels": [ + { + "id": 41869663, + "title": "documentation", + "color": "#0075ca", + "project_id": 72081820, + "created_at": "2025-07-30 00:40:00 UTC", + "updated_at": "2025-07-30 00:40:00 UTC", + "template": false, + "description": null, + "type": "ProjectLabel", + "group_id": null + } + ], + "last_commit": { + "id": "2f7670508b771e7e77839402be8b34b13787aba8", + "message": "Edit README.md", + "title": "Edit README.md", + "timestamp": "2025-08-05T21:45:58+00:00", + "url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp/-/commit/2f7670508b771e7e77839402be8b34b13787aba8", + "author": { + "name": "6543", + "email": "[REDACTED]" + } + }, + "reviewer_ids": [4575606], + "source": { + "id": 72081820, + "name": "test_ci_tmp", + "description": null, + "web_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "avatar_url": null, + "git_ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "git_http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git", + "namespace": "demoaccount2-commits-group", + "visibility_level": 0, + "path_with_namespace": "demoaccount2-commits-group/test_ci_tmp", + "default_branch": "main", + "ci_config_path": "", + "homepage": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git" + }, + "state": "opened", + "target": { + "id": 72081820, + "name": "test_ci_tmp", + "description": null, + "web_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "avatar_url": null, + "git_ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "git_http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git", + "namespace": "demoaccount2-commits-group", + "visibility_level": 0, + "path_with_namespace": "demoaccount2-commits-group/test_ci_tmp", + "default_branch": "main", + "ci_config_path": "", + "homepage": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git" + }, + "time_change": 0, + "total_time_spent": 0, + "url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp/-/merge_requests/3", + "work_in_progress": false, + "approval_rules": [], + "action": "update" + }, + "labels": [ + { + "id": 41869663, + "title": "documentation", + "color": "#0075ca", + "project_id": 72081820, + "created_at": "2025-07-30 00:40:00 UTC", + "updated_at": "2025-07-30 00:40:00 UTC", + "template": false, + "description": null, + "type": "ProjectLabel", + "group_id": null + } + ], + "changes": { + "updated_at": { + "previous": "2025-08-06 01:09:39 UTC", + "current": "2025-08-06 01:11:08 UTC" + }, + "reviewers": { + "previous": [], + "current": [ + { + "id": 4575606, + "name": "6543", + "username": "real6543", + "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/4575606/avatar.png", + "email": "[REDACTED]" + } + ] + } + }, + "repository": { + "name": "test_ci_tmp", + "url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "description": null, + "homepage": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp" + }, + "reviewers": [ + { + "id": 4575606, + "name": "6543", + "username": "real6543", + "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/4575606/avatar.png", + "email": "[REDACTED]" + } + ] +} diff --git a/server/forge/gitlab/fixtures/HookPullRequestUnapproved.json b/server/forge/gitlab/fixtures/HookPullRequestUnapproved.json new file mode 100644 index 00000000000..8c62425d720 --- /dev/null +++ b/server/forge/gitlab/fixtures/HookPullRequestUnapproved.json @@ -0,0 +1,166 @@ +{ + "object_kind": "merge_request", + "event_type": "merge_request", + "user": { + "id": 4575606, + "name": "6543", + "username": "real6543", + "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/4575606/avatar.png", + "email": "[REDACTED]" + }, + "project": { + "id": 72081820, + "name": "test_ci_tmp", + "description": null, + "web_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "avatar_url": null, + "git_ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "git_http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git", + "namespace": "demoaccount2-commits-group", + "visibility_level": 0, + "path_with_namespace": "demoaccount2-commits-group/test_ci_tmp", + "default_branch": "main", + "ci_config_path": "", + "homepage": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git" + }, + "object_attributes": { + "assignee_id": 29352624, + "author_id": 4575606, + "created_at": "2025-08-05 21:48:25 UTC", + "description": ":tada: text that you might read eventually.", + "draft": false, + "head_pipeline_id": null, + "id": 405095454, + "iid": 3, + "last_edited_at": "2025-08-05 22:01:30 UTC", + "last_edited_by_id": 4575606, + "merge_commit_sha": null, + "merge_error": null, + "merge_params": { + "force_remove_source_branch": "0" + }, + "merge_status": "can_be_merged", + "merge_user_id": null, + "merge_when_pipeline_succeeds": false, + "milestone_id": 6088906, + "source_branch": "real6543-main-patch-42541", + "source_project_id": 72081820, + "state_id": 1, + "target_branch": "main", + "target_project_id": 72081820, + "time_estimate": 0, + "title": "Edit README for more text to read", + "updated_at": "2025-08-06 01:28:57 UTC", + "updated_by_id": 4575606, + "prepared_at": "2025-08-05 21:48:27 UTC", + "assignee_ids": [29352624], + "blocking_discussions_resolved": true, + "detailed_merge_status": "mergeable", + "first_contribution": true, + "human_time_change": null, + "human_time_estimate": null, + "human_total_time_spent": null, + "labels": [ + { + "id": 41869666, + "title": "good first issue", + "color": "#7057ff", + "project_id": 72081820, + "created_at": "2025-07-30 00:40:00 UTC", + "updated_at": "2025-07-30 00:40:00 UTC", + "template": false, + "description": null, + "type": "ProjectLabel", + "group_id": null + } + ], + "last_commit": { + "id": "2f7670508b771e7e77839402be8b34b13787aba8", + "message": "Edit README.md", + "title": "Edit README.md", + "timestamp": "2025-08-05T21:45:58+00:00", + "url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp/-/commit/2f7670508b771e7e77839402be8b34b13787aba8", + "author": { + "name": "6543", + "email": "[REDACTED]" + } + }, + "reviewer_ids": [], + "source": { + "id": 72081820, + "name": "test_ci_tmp", + "description": null, + "web_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "avatar_url": null, + "git_ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "git_http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git", + "namespace": "demoaccount2-commits-group", + "visibility_level": 0, + "path_with_namespace": "demoaccount2-commits-group/test_ci_tmp", + "default_branch": "main", + "ci_config_path": "", + "homepage": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git" + }, + "state": "opened", + "target": { + "id": 72081820, + "name": "test_ci_tmp", + "description": null, + "web_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "avatar_url": null, + "git_ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "git_http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git", + "namespace": "demoaccount2-commits-group", + "visibility_level": 0, + "path_with_namespace": "demoaccount2-commits-group/test_ci_tmp", + "default_branch": "main", + "ci_config_path": "", + "homepage": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git" + }, + "time_change": 0, + "total_time_spent": 0, + "url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp/-/merge_requests/3", + "work_in_progress": false, + "approval_rules": [], + "action": "unapproved" + }, + "labels": [ + { + "id": 41869666, + "title": "good first issue", + "color": "#7057ff", + "project_id": 72081820, + "created_at": "2025-07-30 00:40:00 UTC", + "updated_at": "2025-07-30 00:40:00 UTC", + "template": false, + "description": null, + "type": "ProjectLabel", + "group_id": null + } + ], + "changes": {}, + "repository": { + "name": "test_ci_tmp", + "url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "description": null, + "homepage": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp" + }, + "assignees": [ + { + "id": 29352624, + "name": "demoaccount2-commits", + "username": "demoaccount2-commits", + "avatar_url": "https://secure.gravatar.com/avatar/510e64831d3748ef1d2143c4a9766c30684f17991b31ee23ece8bb2f26a35fc2?s=80&d=identicon", + "email": "[REDACTED]" + } + ] +} diff --git a/server/forge/gitlab/fixtures/HookPullRequestUnassigned.json b/server/forge/gitlab/fixtures/HookPullRequestUnassigned.json new file mode 100644 index 00000000000..74605db122e --- /dev/null +++ b/server/forge/gitlab/fixtures/HookPullRequestUnassigned.json @@ -0,0 +1,187 @@ +{ + "object_kind": "merge_request", + "event_type": "merge_request", + "user": { + "id": 4575606, + "name": "6543", + "username": "real6543", + "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/4575606/avatar.png", + "email": "[REDACTED]" + }, + "project": { + "id": 72081820, + "name": "test_ci_tmp", + "description": null, + "web_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "avatar_url": null, + "git_ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "git_http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git", + "namespace": "demoaccount2-commits-group", + "visibility_level": 0, + "path_with_namespace": "demoaccount2-commits-group/test_ci_tmp", + "default_branch": "main", + "ci_config_path": "", + "homepage": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git" + }, + "object_attributes": { + "assignee_id": 29352624, + "author_id": 4575606, + "created_at": "2025-08-05 21:48:25 UTC", + "description": ":tada: text that you might read eventually.", + "draft": false, + "head_pipeline_id": null, + "id": 405095454, + "iid": 3, + "last_edited_at": "2025-08-05 22:01:30 UTC", + "last_edited_by_id": 4575606, + "merge_commit_sha": null, + "merge_error": null, + "merge_params": { + "force_remove_source_branch": "0" + }, + "merge_status": "can_be_merged", + "merge_user_id": null, + "merge_when_pipeline_succeeds": false, + "milestone_id": 6088906, + "source_branch": "real6543-main-patch-42541", + "source_project_id": 72081820, + "state_id": 1, + "target_branch": "main", + "target_project_id": 72081820, + "time_estimate": 0, + "title": "Edit README for more text to read", + "updated_at": "2025-08-06 01:24:11 UTC", + "updated_by_id": 4575606, + "prepared_at": "2025-08-05 21:48:27 UTC", + "assignee_ids": [29352624], + "blocking_discussions_resolved": true, + "detailed_merge_status": "mergeable", + "first_contribution": true, + "human_time_change": null, + "human_time_estimate": null, + "human_total_time_spent": null, + "labels": [ + { + "id": 41869666, + "title": "good first issue", + "color": "#7057ff", + "project_id": 72081820, + "created_at": "2025-07-30 00:40:00 UTC", + "updated_at": "2025-07-30 00:40:00 UTC", + "template": false, + "description": null, + "type": "ProjectLabel", + "group_id": null + } + ], + "last_commit": { + "id": "2f7670508b771e7e77839402be8b34b13787aba8", + "message": "Edit README.md", + "title": "Edit README.md", + "timestamp": "2025-08-05T21:45:58+00:00", + "url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp/-/commit/2f7670508b771e7e77839402be8b34b13787aba8", + "author": { + "name": "6543", + "email": "[REDACTED]" + } + }, + "reviewer_ids": [], + "source": { + "id": 72081820, + "name": "test_ci_tmp", + "description": null, + "web_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "avatar_url": null, + "git_ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "git_http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git", + "namespace": "demoaccount2-commits-group", + "visibility_level": 0, + "path_with_namespace": "demoaccount2-commits-group/test_ci_tmp", + "default_branch": "main", + "ci_config_path": "", + "homepage": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git" + }, + "state": "opened", + "target": { + "id": 72081820, + "name": "test_ci_tmp", + "description": null, + "web_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "avatar_url": null, + "git_ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "git_http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git", + "namespace": "demoaccount2-commits-group", + "visibility_level": 0, + "path_with_namespace": "demoaccount2-commits-group/test_ci_tmp", + "default_branch": "main", + "ci_config_path": "", + "homepage": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git" + }, + "time_change": 0, + "total_time_spent": 0, + "url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp/-/merge_requests/3", + "work_in_progress": false, + "approval_rules": [], + "action": "update" + }, + "labels": [ + { + "id": 41869666, + "title": "good first issue", + "color": "#7057ff", + "project_id": 72081820, + "created_at": "2025-07-30 00:40:00 UTC", + "updated_at": "2025-07-30 00:40:00 UTC", + "template": false, + "description": null, + "type": "ProjectLabel", + "group_id": null + } + ], + "changes": { + "assignees": { + "previous": [ + { + "id": 4575606, + "name": "6543", + "username": "real6543", + "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/4575606/avatar.png", + "email": "[REDACTED]" + } + ], + "current": [ + { + "id": 29352624, + "name": "demoaccount2-commits", + "username": "demoaccount2-commits", + "avatar_url": "https://secure.gravatar.com/avatar/510e64831d3748ef1d2143c4a9766c30684f17991b31ee23ece8bb2f26a35fc2?s=80&d=identicon", + "email": "[REDACTED]" + } + ] + } + }, + "repository": { + "name": "test_ci_tmp", + "url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "description": null, + "homepage": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp" + }, + "assignees": [ + { + "id": 29352624, + "name": "demoaccount2-commits", + "username": "demoaccount2-commits", + "avatar_url": "https://secure.gravatar.com/avatar/510e64831d3748ef1d2143c4a9766c30684f17991b31ee23ece8bb2f26a35fc2?s=80&d=identicon", + "email": "[REDACTED]" + } + ] +} diff --git a/server/forge/gitlab/fixtures/HookPullRequestUnsupportedAction.json b/server/forge/gitlab/fixtures/HookPullRequestUnsupportedAction.json new file mode 100644 index 00000000000..f3a32517821 --- /dev/null +++ b/server/forge/gitlab/fixtures/HookPullRequestUnsupportedAction.json @@ -0,0 +1,164 @@ +{ + "object_kind": "merge_request", + "event_type": "merge_request", + "user": { + "id": 4575606, + "name": "6543", + "username": "real6543", + "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/4575606/avatar.png", + "email": "[REDACTED]" + }, + "project": { + "id": 72081820, + "name": "test_ci_tmp", + "description": null, + "web_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "avatar_url": null, + "git_ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "git_http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git", + "namespace": "demoaccount2-commits-group", + "visibility_level": 0, + "path_with_namespace": "demoaccount2-commits-group/test_ci_tmp", + "default_branch": "main", + "ci_config_path": "", + "homepage": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git" + }, + "object_attributes": { + "assignee_id": null, + "author_id": 29352663, + "created_at": "2025-07-29 20:00:54 UTC", + "description": "yeaaa", + "draft": false, + "head_pipeline_id": null, + "id": 403287663, + "iid": 1, + "last_edited_at": null, + "last_edited_by_id": null, + "merge_commit_sha": null, + "merge_error": null, + "merge_params": {}, + "merge_status": "can_be_merged", + "merge_user_id": null, + "merge_when_pipeline_succeeds": false, + "milestone_id": null, + "source_branch": "6543-patch-1", + "source_project_id": 72081820, + "state_id": 1, + "target_branch": "main", + "target_project_id": 72081820, + "time_estimate": 0, + "title": "Some ned more AAAA", + "updated_at": "2025-07-30 00:46:56 UTC", + "updated_by_id": null, + "prepared_at": null, + "assignee_ids": [], + "blocking_discussions_resolved": true, + "detailed_merge_status": "mergeable", + "first_contribution": true, + "human_time_change": null, + "human_time_estimate": null, + "human_total_time_spent": null, + "labels": [ + { + "id": 41869663, + "title": "documentation", + "color": "#0075ca", + "project_id": 72081820, + "created_at": "2025-07-30 00:40:00 UTC", + "updated_at": "2025-07-30 00:40:00 UTC", + "template": false, + "description": null, + "type": "ProjectLabel", + "group_id": null + } + ], + "last_commit": { + "id": "36b5813240a9d2daa29b05046d56a53e18f39a3e", + "message": "Some ned more AAAA\n", + "title": "Some ned more AAAA", + "timestamp": "2025-07-29T16:45:02+02:00", + "url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp/-/commit/36b5813240a9d2daa29b05046d56a53e18f39a3e", + "author": { + "name": "6543", + "email": "[REDACTED]" + } + }, + "reviewer_ids": [29352668], + "source": { + "id": 72081820, + "name": "test_ci_tmp", + "description": null, + "web_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "avatar_url": null, + "git_ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "git_http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git", + "namespace": "demoaccount2-commits-group", + "visibility_level": 0, + "path_with_namespace": "demoaccount2-commits-group/test_ci_tmp", + "default_branch": "main", + "ci_config_path": "", + "homepage": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git" + }, + "state": "opened", + "target": { + "id": 72081820, + "name": "test_ci_tmp", + "description": null, + "web_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "avatar_url": null, + "git_ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "git_http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git", + "namespace": "demoaccount2-commits-group", + "visibility_level": 0, + "path_with_namespace": "demoaccount2-commits-group/test_ci_tmp", + "default_branch": "main", + "ci_config_path": "", + "homepage": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp", + "url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "ssh_url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "http_url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp.git" + }, + "time_change": 0, + "total_time_spent": 0, + "url": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp/-/merge_requests/1", + "work_in_progress": false, + "approval_rules": [], + "action": "action_we_do_not_support" + }, + "labels": [ + { + "id": 41869663, + "title": "documentation", + "color": "#0075ca", + "project_id": 72081820, + "created_at": "2025-07-30 00:40:00 UTC", + "updated_at": "2025-07-30 00:40:00 UTC", + "template": false, + "description": null, + "type": "ProjectLabel", + "group_id": null + } + ], + "changes": {}, + "repository": { + "name": "test_ci_tmp", + "url": "git@gitlab.com:demoaccount2-commits-group/test_ci_tmp.git", + "description": null, + "homepage": "https://gitlab.com/demoaccount2-commits-group/test_ci_tmp" + }, + "reviewers": [ + { + "id": 29352668, + "name": "Placeholder github Source User", + "username": "demoaccount2commits_placeholder_6s82rp", + "avatar_url": "https://secure.gravatar.com/avatar/6d8b40c6bd417e69e359e712b55471dfc72af88c732fed9fe8d276a210aa5dd8?s=80&d=identicon", + "email": "[REDACTED]" + } + ] +} diff --git a/server/forge/gitlab/fixtures/HookPullRequest.json b/server/forge/gitlab/fixtures/HookPullRequestUpdated.json similarity index 100% rename from server/forge/gitlab/fixtures/HookPullRequest.json rename to server/forge/gitlab/fixtures/HookPullRequestUpdated.json diff --git a/server/forge/gitlab/fixtures/hooks.go b/server/forge/gitlab/fixtures/hooks.go index 6002d2eae8a..5e1a0306452 100644 --- a/server/forge/gitlab/fixtures/hooks.go +++ b/server/forge/gitlab/fixtures/hooks.go @@ -35,6 +35,11 @@ var ( "User-Agent": []string{"GitLab/14.3.0"}, "X-Gitlab-Event": []string{"Release Hook"}, } + MergeRequestHookHeaders = http.Header{ + "Content-Type": []string{"application/json"}, + "User-Agent": []string{"GitLab/18.3.0-pre"}, + "X-Gitlab-Event": []string{"Merge Request Hook"}, + } ) // HookPush is payload of a push event @@ -49,8 +54,11 @@ var HookTag []byte // HookPullRequest is payload of a PULL_REQUEST event // -//go:embed HookPullRequest.json -var HookPullRequest []byte +//go:embed HookPullRequestUpdated.json +var HookPullRequestUpdated []byte + +//go:embed HookPullRequestOpened.json +var HookPullRequestOpened []byte //go:embed HookPullRequestWithoutChanges.json var HookPullRequestWithoutChanges []byte @@ -58,6 +66,9 @@ var HookPullRequestWithoutChanges []byte //go:embed HookPullRequestApproved.json var HookPullRequestApproved []byte +//go:embed HookPullRequestEdited.json +var HookPullRequestEdited []byte + //go:embed HookPullRequestClosed.json var HookPullRequestClosed []byte @@ -69,3 +80,36 @@ var WebhookReleaseBody []byte //go:embed HookPullRequestReopened.json var HookPullRequestReopened []byte + +//go:embed HookPullRequestUnsupportedAction.json +var HookPullRequestUnsupportedAction []byte + +//go:embed HookPullRequestReviewRequested.json +var HookPullRequestReviewRequested []byte + +//go:embed HookPullRequestReviewRequestDel.json +var HookPullRequestReviewRequestDel []byte + +//go:embed HookPullRequestAssigned.json +var HookPullRequestAssigned []byte + +//go:embed HookPullRequestDemilestoned.json +var HookPullRequestDemilestoned []byte + +//go:embed HookPullRequestLabelsAdded.json +var HookPullRequestLabelsAdded []byte + +//go:embed HookPullRequestLabelsCleared.json +var HookPullRequestLabelsCleared []byte + +//go:embed HookPullRequestLabelsUpdated.json +var HookPullRequestLabelsUpdated []byte + +//go:embed HookPullRequestMilestoned.json +var HookPullRequestMilestoned []byte + +//go:embed HookPullRequestUnapproved.json +var HookPullRequestUnapproved []byte + +//go:embed HookPullRequestUnassigned.json +var HookPullRequestUnassigned []byte diff --git a/server/forge/gitlab/gitlab.go b/server/forge/gitlab/gitlab.go index cf46d32cd4a..e991312f336 100644 --- a/server/forge/gitlab/gitlab.go +++ b/server/forge/gitlab/gitlab.go @@ -642,14 +642,6 @@ func (g *GitLab) Hook(ctx context.Context, req *http.Request) (*model.Repo, *mod switch event := parsed.(type) { case *gitlab.MergeEvent: - // https://docs.gitlab.com/ee/user/project/integrations/webhook_events.html#merge-request-events - if event.ObjectAttributes.OldRev == "" && - event.ObjectAttributes.Action != "open" && - event.ObjectAttributes.Action != "close" && - event.ObjectAttributes.Action != "merge" && - event.ObjectAttributes.Action != "reopen" { - return nil, nil, &forge_types.ErrIgnoreEvent{Event: string(eventType), Reason: "no code changes"} - } mergeID, milestoneID, repo, pipeline, err := convertMergeRequestHook(event, req) if err != nil { return nil, nil, err diff --git a/server/forge/gitlab/gitlab_test.go b/server/forge/gitlab/gitlab_test.go index 7f56ac9a0e9..f47d95856c2 100644 --- a/server/forge/gitlab/gitlab_test.go +++ b/server/forge/gitlab/gitlab_test.go @@ -122,180 +122,424 @@ func Test_GitLab(t *testing.T) { assert.NoError(t, err) }) - // Test hook method - t.Run("parse push hook", func(t *testing.T) { - req, _ := http.NewRequest( - fixtures.ServiceHookMethod, - fixtures.ServiceHookURL.String(), - bytes.NewReader(fixtures.HookPush), - ) - req.Header = fixtures.ServiceHookHeaders - - hookRepo, pipeline, err := client.Hook(ctx, req) - assert.NoError(t, err) - if assert.NotNil(t, hookRepo) && assert.NotNil(t, pipeline) { - assert.Equal(t, pipeline.Event, model.EventPush) - assert.Equal(t, "test", hookRepo.Owner) - assert.Equal(t, "woodpecker", hookRepo.Name) - assert.Equal(t, "http://example.com/uploads/project/avatar/555/Outh-20-Logo.jpg", hookRepo.Avatar) - assert.Equal(t, "develop", hookRepo.Branch) - assert.Equal(t, "refs/heads/main", pipeline.Ref) - assert.Equal(t, []string{"cmd/cli/main.go"}, pipeline.ChangedFiles) - assert.Equal(t, model.EventPush, pipeline.Event) - } - }) + t.Run("test parse webhook", func(t *testing.T) { + // Test hook method + t.Run("parse push", func(t *testing.T) { + req, _ := http.NewRequest( + fixtures.ServiceHookMethod, + fixtures.ServiceHookURL.String(), + bytes.NewReader(fixtures.HookPush), + ) + req.Header = fixtures.ServiceHookHeaders + + hookRepo, pipeline, err := client.Hook(ctx, req) + assert.NoError(t, err) + if assert.NotNil(t, hookRepo) && assert.NotNil(t, pipeline) { + assert.Equal(t, pipeline.Event, model.EventPush) + assert.Equal(t, "test", hookRepo.Owner) + assert.Equal(t, "woodpecker", hookRepo.Name) + assert.Equal(t, "http://example.com/uploads/project/avatar/555/Outh-20-Logo.jpg", hookRepo.Avatar) + assert.Equal(t, "develop", hookRepo.Branch) + assert.Equal(t, "refs/heads/main", pipeline.Ref) + assert.Equal(t, []string{"cmd/cli/main.go"}, pipeline.ChangedFiles) + assert.Equal(t, model.EventPush, pipeline.Event) + assert.Empty(t, pipeline.EventReason) + } + }) - t.Run("tag push hook", func(t *testing.T) { - req, _ := http.NewRequest( - fixtures.ServiceHookMethod, - fixtures.ServiceHookURL.String(), - bytes.NewReader(fixtures.HookTag), - ) - req.Header = fixtures.ServiceHookHeaders + t.Run("tag push", func(t *testing.T) { + req, _ := http.NewRequest( + fixtures.ServiceHookMethod, + fixtures.ServiceHookURL.String(), + bytes.NewReader(fixtures.HookTag), + ) + req.Header = fixtures.ServiceHookHeaders - hookRepo, pipeline, err := client.Hook(ctx, req) - assert.NoError(t, err) - if assert.NotNil(t, hookRepo) && assert.NotNil(t, pipeline) { - assert.Equal(t, "test", hookRepo.Owner) - assert.Equal(t, "woodpecker", hookRepo.Name) - assert.Equal(t, "http://example.com/uploads/project/avatar/555/Outh-20-Logo.jpg", hookRepo.Avatar) - assert.Equal(t, "develop", hookRepo.Branch) - assert.Equal(t, "refs/tags/v22", pipeline.Ref) - assert.Len(t, pipeline.ChangedFiles, 0) - assert.Equal(t, model.EventTag, pipeline.Event) - } - }) + hookRepo, pipeline, err := client.Hook(ctx, req) + assert.NoError(t, err) + if assert.NotNil(t, hookRepo) && assert.NotNil(t, pipeline) { + assert.Equal(t, "test", hookRepo.Owner) + assert.Equal(t, "woodpecker", hookRepo.Name) + assert.Equal(t, "http://example.com/uploads/project/avatar/555/Outh-20-Logo.jpg", hookRepo.Avatar) + assert.Equal(t, "develop", hookRepo.Branch) + assert.Equal(t, "refs/tags/v22", pipeline.Ref) + assert.Len(t, pipeline.ChangedFiles, 0) + assert.Equal(t, model.EventTag, pipeline.Event) + assert.Empty(t, pipeline.EventReason) + } + }) - t.Run("merge request hook", func(t *testing.T) { - req, _ := http.NewRequest( - fixtures.ServiceHookMethod, - fixtures.ServiceHookURL.String(), - bytes.NewReader(fixtures.HookPullRequest), - ) - req.Header = fixtures.ServiceHookHeaders + t.Run("merge request", func(t *testing.T) { + req, _ := http.NewRequest( + fixtures.ServiceHookMethod, + fixtures.ServiceHookURL.String(), + bytes.NewReader(fixtures.HookPullRequestUpdated), + ) + req.Header = fixtures.ServiceHookHeaders - // TODO: insert fake store into context to retrieve user & repo, this will activate fetching of ChangedFiles - hookRepo, pipeline, err := client.Hook(ctx, req) - assert.NoError(t, err) - if assert.NotNil(t, hookRepo) && assert.NotNil(t, pipeline) { - assert.Equal(t, "http://example.com/uploads/project/avatar/555/Outh-20-Logo.jpg", hookRepo.Avatar) - assert.Equal(t, "main", hookRepo.Branch) - assert.Equal(t, "anbraten", hookRepo.Owner) - assert.Equal(t, "woodpecker", hookRepo.Name) - assert.Equal(t, "Update client.go 🎉", pipeline.Title) - assert.Len(t, pipeline.ChangedFiles, 0) // see L217 - assert.Equal(t, model.EventPull, pipeline.Event) - } - }) + // TODO: insert fake store into context to retrieve user & repo, this will activate fetching of ChangedFiles + hookRepo, pipeline, err := client.Hook(ctx, req) + assert.NoError(t, err) + if assert.NotNil(t, hookRepo) && assert.NotNil(t, pipeline) { + assert.Equal(t, "http://example.com/uploads/project/avatar/555/Outh-20-Logo.jpg", hookRepo.Avatar) + assert.Equal(t, "main", hookRepo.Branch) + assert.Equal(t, "anbraten", hookRepo.Owner) + assert.Equal(t, "woodpecker", hookRepo.Name) + assert.Equal(t, "Update client.go 🎉", pipeline.Title) + assert.Len(t, pipeline.ChangedFiles, 0) // see L217 + assert.Equal(t, model.EventPull, pipeline.Event) + assert.Empty(t, pipeline.EventReason) + } + }) - t.Run("merge request reopened", func(t *testing.T) { - req, _ := http.NewRequest( - fixtures.ServiceHookMethod, - fixtures.ServiceHookURL.String(), - bytes.NewReader(fixtures.HookPullRequestReopened), - ) - req.Header = fixtures.ServiceHookHeaders + t.Run("merge request new opened", func(t *testing.T) { + req, _ := http.NewRequest( + fixtures.ServiceHookMethod, + fixtures.ServiceHookURL.String(), + bytes.NewReader(fixtures.HookPullRequestOpened), + ) + req.Header = fixtures.MergeRequestHookHeaders - hookRepo, pipeline, err := client.Hook(ctx, req) - assert.NoError(t, err) - if assert.NotNil(t, hookRepo) && assert.NotNil(t, pipeline) { - assert.Equal(t, "main", hookRepo.Branch) - assert.Equal(t, "demoaccount2-commits-group", hookRepo.Owner) - assert.Equal(t, "test_ci_tmp", hookRepo.Name) - assert.Equal(t, "Some ned more AAAA", pipeline.Title) - assert.Len(t, pipeline.ChangedFiles, 0) - assert.Equal(t, model.EventPull, pipeline.Event) - } - }) + // TODO: insert fake store into context to retrieve user & repo, this will activate fetching of ChangedFiles + hookRepo, pipeline, err := client.Hook(ctx, req) + assert.NoError(t, err) + if assert.NotNil(t, hookRepo) && assert.NotNil(t, pipeline) { + assert.Equal(t, "main", hookRepo.Branch) + assert.Equal(t, "demoaccount2-commits-group", hookRepo.Owner) + assert.Equal(t, "test_ci_tmp", hookRepo.Name) + assert.Equal(t, "Edit README.md for more text to read", pipeline.Title) + assert.Len(t, pipeline.ChangedFiles, 0) // see L217 + assert.Equal(t, model.EventPull, pipeline.Event) + assert.Empty(t, pipeline.EventReason) + } + }) - t.Run("ignore merge request hook without changes", func(t *testing.T) { - req, _ := http.NewRequest( - fixtures.ServiceHookMethod, - fixtures.ServiceHookURL.String(), - bytes.NewReader(fixtures.HookPullRequestWithoutChanges), - ) - req.Header = fixtures.ServiceHookHeaders - - // TODO: insert fake store into context to retrieve user & repo, this will activate fetching of ChangedFiles - hookRepo, pipeline, err := client.Hook(ctx, req) - assert.Nil(t, hookRepo) - assert.Nil(t, pipeline) - assert.ErrorIs(t, err, &types.ErrIgnoreEvent{}) - }) + t.Run("ignore merge request hook without changes", func(t *testing.T) { + req, _ := http.NewRequest( + fixtures.ServiceHookMethod, + fixtures.ServiceHookURL.String(), + bytes.NewReader(fixtures.HookPullRequestWithoutChanges), + ) + req.Header = fixtures.ServiceHookHeaders + + hookRepo, pipeline, err := client.Hook(ctx, req) + assert.Nil(t, hookRepo) + assert.Nil(t, pipeline) + if assert.ErrorIs(t, err, &types.ErrIgnoreEvent{}) { + assert.EqualValues(t, + "explicit ignored event 'Merge Request Hook', reason: Action 'update' no supported changes detected", + err.Error()) + } + }) - t.Run("ignore merge request approval", func(t *testing.T) { - req, _ := http.NewRequest( - fixtures.ServiceHookMethod, - fixtures.ServiceHookURL.String(), - bytes.NewReader(fixtures.HookPullRequestApproved), - ) - req.Header = fixtures.ServiceHookHeaders - - // TODO: insert fake store into context to retrieve user & repo, this will activate fetching of ChangedFiles - hookRepo, pipeline, err := client.Hook(ctx, req) - assert.Nil(t, hookRepo) - assert.Nil(t, pipeline) - assert.ErrorIs(t, err, &types.ErrIgnoreEvent{}) - }) + t.Run("ignore unsupported action", func(t *testing.T) { + req, _ := http.NewRequest( + fixtures.ServiceHookMethod, + fixtures.ServiceHookURL.String(), + bytes.NewReader(fixtures.HookPullRequestUnsupportedAction), + ) + req.Header = fixtures.ServiceHookHeaders + + hookRepo, pipeline, err := client.Hook(ctx, req) + assert.Nil(t, hookRepo) + assert.Nil(t, pipeline) + if assert.ErrorIs(t, err, &types.ErrIgnoreEvent{}) { + assert.EqualValues(t, + "explicit ignored event 'Merge Request Hook', reason: Action 'action_we_do_not_support' not supported", + err.Error()) + } + }) - t.Run("parse merge request closed", func(t *testing.T) { - req, _ := http.NewRequest( - fixtures.ServiceHookMethod, - fixtures.ServiceHookURL.String(), - bytes.NewReader(fixtures.HookPullRequestClosed), - ) - req.Header = fixtures.ServiceHookHeaders + t.Run("parse merge request closed", func(t *testing.T) { + req, _ := http.NewRequest( + fixtures.ServiceHookMethod, + fixtures.ServiceHookURL.String(), + bytes.NewReader(fixtures.HookPullRequestClosed), + ) + req.Header = fixtures.ServiceHookHeaders - // TODO: insert fake store into context to retrieve user & repo, this will activate fetching of ChangedFiles - hookRepo, pipeline, err := client.Hook(ctx, req) - assert.NoError(t, err) - if assert.NotNil(t, hookRepo) && assert.NotNil(t, pipeline) { - assert.Equal(t, "main", hookRepo.Branch) - assert.Equal(t, "anbraten", hookRepo.Owner) - assert.Equal(t, "woodpecker-test", hookRepo.Name) - assert.Equal(t, "Add new file", pipeline.Title) - assert.Len(t, pipeline.ChangedFiles, 0) // see L217 - assert.Equal(t, model.EventPullClosed, pipeline.Event) - } - }) + // TODO: insert fake store into context to retrieve user & repo, this will activate fetching of ChangedFiles + hookRepo, pipeline, err := client.Hook(ctx, req) + assert.NoError(t, err) + if assert.NotNil(t, hookRepo) && assert.NotNil(t, pipeline) { + assert.Equal(t, "main", hookRepo.Branch) + assert.Equal(t, "anbraten", hookRepo.Owner) + assert.Equal(t, "woodpecker-test", hookRepo.Name) + assert.Equal(t, "Add new file", pipeline.Title) + assert.Len(t, pipeline.ChangedFiles, 0) // see L217 + assert.Equal(t, model.EventPullClosed, pipeline.Event) + } + }) - t.Run("parse merge request merged", func(t *testing.T) { - req, _ := http.NewRequest( - fixtures.ServiceHookMethod, - fixtures.ServiceHookURL.String(), - bytes.NewReader(fixtures.HookPullRequestMerged), - ) - req.Header = fixtures.ServiceHookHeaders + t.Run("merge request reopened", func(t *testing.T) { + req, _ := http.NewRequest( + fixtures.ServiceHookMethod, + fixtures.ServiceHookURL.String(), + bytes.NewReader(fixtures.HookPullRequestReopened), + ) + req.Header = fixtures.ServiceHookHeaders - // TODO: insert fake store into context to retrieve user & repo, this will activate fetching of ChangedFiles - hookRepo, pipeline, err := client.Hook(ctx, req) - assert.NoError(t, err) - if assert.NotNil(t, hookRepo) && assert.NotNil(t, pipeline) { - assert.Equal(t, "main", hookRepo.Branch) - assert.Equal(t, "anbraten", hookRepo.Owner) - assert.Equal(t, "woodpecker-test", hookRepo.Name) - assert.Equal(t, "Add new file", pipeline.Title) - assert.Len(t, pipeline.ChangedFiles, 0) // see L217 - assert.Equal(t, model.EventPullClosed, pipeline.Event) - } - }) + hookRepo, pipeline, err := client.Hook(ctx, req) + assert.NoError(t, err) + if assert.NotNil(t, hookRepo) && assert.NotNil(t, pipeline) { + assert.Equal(t, "main", hookRepo.Branch) + assert.Equal(t, "demoaccount2-commits-group", hookRepo.Owner) + assert.Equal(t, "test_ci_tmp", hookRepo.Name) + assert.Equal(t, "Some ned more AAAA", pipeline.Title) + assert.Len(t, pipeline.ChangedFiles, 0) + assert.Equal(t, model.EventPull, pipeline.Event) + } + }) - t.Run("release hook", func(t *testing.T) { - req, _ := http.NewRequest( - fixtures.ServiceHookMethod, - fixtures.ServiceHookURL.String(), - bytes.NewReader(fixtures.WebhookReleaseBody), - ) - req.Header = fixtures.ReleaseHookHeaders + t.Run("parse merge request merged", func(t *testing.T) { + req, _ := http.NewRequest( + fixtures.ServiceHookMethod, + fixtures.ServiceHookURL.String(), + bytes.NewReader(fixtures.HookPullRequestMerged), + ) + req.Header = fixtures.ServiceHookHeaders - hookRepo, pipeline, err := client.Hook(ctx, req) - assert.NoError(t, err) - if assert.NotNil(t, hookRepo) && assert.NotNil(t, pipeline) { - assert.Equal(t, "refs/tags/0.0.2", pipeline.Ref) - assert.Equal(t, "ci", hookRepo.Name) - assert.Equal(t, "created release Awesome version 0.0.2", pipeline.Message) - assert.Equal(t, model.EventRelease, pipeline.Event) - } + // TODO: insert fake store into context to retrieve user & repo, this will activate fetching of ChangedFiles + hookRepo, pipeline, err := client.Hook(ctx, req) + assert.NoError(t, err) + if assert.NotNil(t, hookRepo) && assert.NotNil(t, pipeline) { + assert.Equal(t, "main", hookRepo.Branch) + assert.Equal(t, "anbraten", hookRepo.Owner) + assert.Equal(t, "woodpecker-test", hookRepo.Name) + assert.Equal(t, "Add new file", pipeline.Title) + assert.Len(t, pipeline.ChangedFiles, 0) // see L217 + assert.Equal(t, model.EventPullClosed, pipeline.Event) + } + }) + + t.Run("merge request title and description edited", func(t *testing.T) { + req, _ := http.NewRequest( + fixtures.ServiceHookMethod, + fixtures.ServiceHookURL.String(), + bytes.NewReader(fixtures.HookPullRequestEdited), + ) + req.Header = fixtures.MergeRequestHookHeaders + + // TODO: insert fake store into context to retrieve user & repo, this will activate fetching of ChangedFiles + hookRepo, pipeline, err := client.Hook(ctx, req) + assert.NoError(t, err) + if assert.NotNil(t, hookRepo) && assert.NotNil(t, pipeline) { + assert.Equal(t, "main", hookRepo.Branch) + assert.Equal(t, "demoaccount2-commits-group", hookRepo.Owner) + assert.Equal(t, "test_ci_tmp", hookRepo.Name) + assert.Equal(t, "Edit README for more text to read", pipeline.Title) + assert.Len(t, pipeline.ChangedFiles, 0) // see L217 + assert.Equal(t, model.EventPullMetadata, pipeline.Event) + assert.Equal(t, []string{"title_edited", "description_edited"}, pipeline.EventReason) + } + }) + + t.Run("release", func(t *testing.T) { + req, _ := http.NewRequest( + fixtures.ServiceHookMethod, + fixtures.ServiceHookURL.String(), + bytes.NewReader(fixtures.WebhookReleaseBody), + ) + req.Header = fixtures.ReleaseHookHeaders + + hookRepo, pipeline, err := client.Hook(ctx, req) + assert.NoError(t, err) + if assert.NotNil(t, hookRepo) && assert.NotNil(t, pipeline) { + assert.Equal(t, "refs/tags/0.0.2", pipeline.Ref) + assert.Equal(t, "ci", hookRepo.Name) + assert.Equal(t, "created release Awesome version 0.0.2", pipeline.Message) + assert.Equal(t, model.EventRelease, pipeline.Event) + } + }) + + t.Run("merge request review approved", func(t *testing.T) { + req, _ := http.NewRequest( + fixtures.ServiceHookMethod, + fixtures.ServiceHookURL.String(), + bytes.NewReader(fixtures.HookPullRequestApproved), + ) + req.Header = fixtures.MergeRequestHookHeaders + + hookRepo, pipeline, err := client.Hook(ctx, req) + assert.ErrorIs(t, err, &types.ErrIgnoreEvent{}) + assert.Nil(t, hookRepo) + assert.Nil(t, pipeline) + }) + + t.Run("merge request review requested", func(t *testing.T) { + req, _ := http.NewRequest( + fixtures.ServiceHookMethod, + fixtures.ServiceHookURL.String(), + bytes.NewReader(fixtures.HookPullRequestReviewRequested), + ) + req.Header = fixtures.MergeRequestHookHeaders + + hookRepo, pipeline, err := client.Hook(ctx, req) + assert.NoError(t, err) + if assert.NotNil(t, hookRepo) && assert.NotNil(t, pipeline) { + assert.Equal(t, "main", hookRepo.Branch) + assert.Equal(t, "demoaccount2-commits-group", hookRepo.Owner) + assert.Equal(t, "test_ci_tmp", hookRepo.Name) + assert.Equal(t, "Edit README for more text to read", pipeline.Title) + assert.Len(t, pipeline.ChangedFiles, 0) + assert.Equal(t, model.EventPullMetadata, pipeline.Event) + assert.Equal(t, []string{"review_requested"}, pipeline.EventReason) + } + }) + + t.Run("merge request assigned", func(t *testing.T) { + req, _ := http.NewRequest( + fixtures.ServiceHookMethod, + fixtures.ServiceHookURL.String(), + bytes.NewReader(fixtures.HookPullRequestAssigned), + ) + req.Header = fixtures.MergeRequestHookHeaders + + hookRepo, pipeline, err := client.Hook(ctx, req) + assert.NoError(t, err) + if assert.NotNil(t, hookRepo) && assert.NotNil(t, pipeline) { + assert.Equal(t, "main", hookRepo.Branch) + assert.Equal(t, "demoaccount2-commits-group", hookRepo.Owner) + assert.Equal(t, "test_ci_tmp", hookRepo.Name) + assert.Len(t, pipeline.ChangedFiles, 0) + assert.Equal(t, model.EventPullMetadata, pipeline.Event) + assert.Equal(t, []string{"assigned"}, pipeline.EventReason) + } + }) + + t.Run("merge request unassigned", func(t *testing.T) { + req, _ := http.NewRequest( + fixtures.ServiceHookMethod, + fixtures.ServiceHookURL.String(), + bytes.NewReader(fixtures.HookPullRequestUnassigned), + ) + req.Header = fixtures.MergeRequestHookHeaders + + hookRepo, pipeline, err := client.Hook(ctx, req) + assert.NoError(t, err) + if assert.NotNil(t, hookRepo) && assert.NotNil(t, pipeline) { + assert.Equal(t, "main", hookRepo.Branch) + assert.Equal(t, "demoaccount2-commits-group", hookRepo.Owner) + assert.Equal(t, "test_ci_tmp", hookRepo.Name) + assert.Len(t, pipeline.ChangedFiles, 0) + assert.Equal(t, model.EventPullMetadata, pipeline.Event) + assert.Equal(t, []string{"assigned", "unassigned"}, pipeline.EventReason) + } + }) + + t.Run("merge request milestoned", func(t *testing.T) { + req, _ := http.NewRequest( + fixtures.ServiceHookMethod, + fixtures.ServiceHookURL.String(), + bytes.NewReader(fixtures.HookPullRequestMilestoned), + ) + req.Header = fixtures.MergeRequestHookHeaders + + hookRepo, pipeline, err := client.Hook(ctx, req) + assert.NoError(t, err) + if assert.NotNil(t, hookRepo) && assert.NotNil(t, pipeline) { + assert.Equal(t, "main", hookRepo.Branch) + assert.Equal(t, "demoaccount2-commits-group", hookRepo.Owner) + assert.Equal(t, "test_ci_tmp", hookRepo.Name) + assert.Len(t, pipeline.ChangedFiles, 0) + assert.Equal(t, model.EventPullMetadata, pipeline.Event) + assert.Equal(t, []string{"milestoned"}, pipeline.EventReason) + } + }) + + t.Run("merge request demilestoned", func(t *testing.T) { + req, _ := http.NewRequest( + fixtures.ServiceHookMethod, + fixtures.ServiceHookURL.String(), + bytes.NewReader(fixtures.HookPullRequestDemilestoned), + ) + req.Header = fixtures.MergeRequestHookHeaders + + hookRepo, pipeline, err := client.Hook(ctx, req) + assert.NoError(t, err) + if assert.NotNil(t, hookRepo) && assert.NotNil(t, pipeline) { + assert.Equal(t, "main", hookRepo.Branch) + assert.Equal(t, "demoaccount2-commits-group", hookRepo.Owner) + assert.Equal(t, "test_ci_tmp", hookRepo.Name) + assert.Len(t, pipeline.ChangedFiles, 0) + assert.Equal(t, model.EventPullMetadata, pipeline.Event) + assert.Equal(t, []string{"demilestoned"}, pipeline.EventReason) + } + }) + + t.Run("merge request labels added", func(t *testing.T) { + req, _ := http.NewRequest( + fixtures.ServiceHookMethod, + fixtures.ServiceHookURL.String(), + bytes.NewReader(fixtures.HookPullRequestLabelsAdded), + ) + req.Header = fixtures.MergeRequestHookHeaders + + hookRepo, pipeline, err := client.Hook(ctx, req) + assert.NoError(t, err) + if assert.NotNil(t, hookRepo) && assert.NotNil(t, pipeline) { + assert.Equal(t, "main", hookRepo.Branch) + assert.Equal(t, "demoaccount2-commits-group", hookRepo.Owner) + assert.Equal(t, "test_ci_tmp", hookRepo.Name) + assert.Len(t, pipeline.ChangedFiles, 0) + assert.Equal(t, model.EventPullMetadata, pipeline.Event) + assert.Equal(t, []string{"label_added"}, pipeline.EventReason) + } + }) + + t.Run("merge request labels cleared", func(t *testing.T) { + req, _ := http.NewRequest( + fixtures.ServiceHookMethod, + fixtures.ServiceHookURL.String(), + bytes.NewReader(fixtures.HookPullRequestLabelsCleared), + ) + req.Header = fixtures.MergeRequestHookHeaders + + hookRepo, pipeline, err := client.Hook(ctx, req) + assert.NoError(t, err) + if assert.NotNil(t, hookRepo) && assert.NotNil(t, pipeline) { + assert.Equal(t, "main", hookRepo.Branch) + assert.Equal(t, "demoaccount2-commits-group", hookRepo.Owner) + assert.Equal(t, "test_ci_tmp", hookRepo.Name) + assert.Len(t, pipeline.ChangedFiles, 0) + assert.Equal(t, model.EventPullMetadata, pipeline.Event) + assert.Equal(t, []string{"label_cleared"}, pipeline.EventReason) + } + }) + + t.Run("merge request labels updated", func(t *testing.T) { + req, _ := http.NewRequest( + fixtures.ServiceHookMethod, + fixtures.ServiceHookURL.String(), + bytes.NewReader(fixtures.HookPullRequestLabelsUpdated), + ) + req.Header = fixtures.MergeRequestHookHeaders + + hookRepo, pipeline, err := client.Hook(ctx, req) + assert.NoError(t, err) + if assert.NotNil(t, hookRepo) && assert.NotNil(t, pipeline) { + assert.Equal(t, "main", hookRepo.Branch) + assert.Equal(t, "demoaccount2-commits-group", hookRepo.Owner) + assert.Equal(t, "test_ci_tmp", hookRepo.Name) + assert.Len(t, pipeline.ChangedFiles, 0) + assert.Equal(t, model.EventPullMetadata, pipeline.Event) + assert.Equal(t, []string{"label_updated"}, pipeline.EventReason) + } + }) + + t.Run("merge request unapproved", func(t *testing.T) { + req, _ := http.NewRequest( + fixtures.ServiceHookMethod, + fixtures.ServiceHookURL.String(), + bytes.NewReader(fixtures.HookPullRequestUnapproved), + ) + req.Header = fixtures.MergeRequestHookHeaders + + hookRepo, pipeline, err := client.Hook(ctx, req) + assert.ErrorIs(t, err, &types.ErrIgnoreEvent{}) + assert.Nil(t, hookRepo) + assert.Nil(t, pipeline) + }) }) } diff --git a/server/forge/types/errors.go b/server/forge/types/errors.go index b155f6021f1..e4c7890cda0 100644 --- a/server/forge/types/errors.go +++ b/server/forge/types/errors.go @@ -29,7 +29,10 @@ type ErrIgnoreEvent struct { } func (err *ErrIgnoreEvent) Error() string { - return fmt.Sprintf("explicit ignored event '%s', reason: %s", err.Event, err.Reason) + if err.Reason != "" { + return fmt.Sprintf("explicit ignored event '%s', reason: %s", err.Event, err.Reason) + } + return fmt.Sprintf("explicit ignored event '%s'", err.Event) } func (*ErrIgnoreEvent) Is(target error) bool { diff --git a/server/model/const.go b/server/model/const.go index 2137da4c2d4..6b35782c042 100644 --- a/server/model/const.go +++ b/server/model/const.go @@ -23,14 +23,15 @@ import ( type WebhookEvent string // @name WebhookEvent const ( - EventPush WebhookEvent = "push" - EventPull WebhookEvent = "pull_request" - EventPullClosed WebhookEvent = "pull_request_closed" - EventTag WebhookEvent = "tag" - EventRelease WebhookEvent = "release" - EventDeploy WebhookEvent = "deployment" - EventCron WebhookEvent = "cron" - EventManual WebhookEvent = "manual" + EventPush WebhookEvent = "push" + EventPull WebhookEvent = "pull_request" + EventPullClosed WebhookEvent = "pull_request_closed" + EventPullMetadata WebhookEvent = "pull_request_metadata" + EventTag WebhookEvent = "tag" + EventRelease WebhookEvent = "release" + EventDeploy WebhookEvent = "deployment" + EventCron WebhookEvent = "cron" + EventManual WebhookEvent = "manual" ) type WebhookEventList []WebhookEvent @@ -43,7 +44,7 @@ var ErrInvalidWebhookEvent = errors.New("invalid webhook event") func (s WebhookEvent) Validate() error { switch s { - case EventPush, EventPull, EventPullClosed, EventTag, EventRelease, EventDeploy, EventCron, EventManual: + case EventPush, EventPull, EventPullClosed, EventPullMetadata, EventTag, EventRelease, EventDeploy, EventCron, EventManual: return nil default: return fmt.Errorf("%w: %s", ErrInvalidWebhookEvent, s) diff --git a/server/model/pipeline.go b/server/model/pipeline.go index c4a9d18043a..6dbae5008ad 100644 --- a/server/model/pipeline.go +++ b/server/model/pipeline.go @@ -26,6 +26,7 @@ type Pipeline struct { Author string `json:"author" xorm:"INDEX 'author'"` Parent int64 `json:"parent" xorm:"parent"` Event WebhookEvent `json:"event" xorm:"event"` + EventReason []string `json:"event_reason" xorm:"json 'event_reason'"` Status StatusValue `json:"status" xorm:"INDEX 'status'"` Errors []*types.PipelineError `json:"errors" xorm:"json 'errors'"` Created int64 `json:"created" xorm:"'created' NOT NULL DEFAULT 0 created"` @@ -75,6 +76,11 @@ func (p Pipeline) IsMultiPipeline() bool { return len(p.Workflows) > 1 } +// IsPullRequest checks if it's a PR event. +func (p Pipeline) IsPullRequest() bool { + return p.Event == EventPull || p.Event == EventPullClosed || p.Event == EventPullMetadata +} + type PipelineOptions struct { Branch string `json:"branch"` Variables map[string]string `json:"variables"` diff --git a/server/pipeline/create.go b/server/pipeline/create.go index 8c126c6eeab..14c648d9b5c 100644 --- a/server/pipeline/create.go +++ b/server/pipeline/create.go @@ -41,7 +41,7 @@ func Create(ctx context.Context, _store store.Store, repo *model.Repo, pipeline return nil, errors.New(msg) } - if pipeline.Event == model.EventPush || pipeline.Event == model.EventPull || pipeline.Event == model.EventPullClosed { + if pipeline.Event == model.EventPush || pipeline.IsPullRequest() { skipMatch := skipPipelineRegex.FindString(pipeline.Message) if len(skipMatch) > 0 { ref := pipeline.Commit diff --git a/server/pipeline/gated.go b/server/pipeline/gated.go index 9c46d35e7c6..5276e957799 100644 --- a/server/pipeline/gated.go +++ b/server/pipeline/gated.go @@ -48,13 +48,13 @@ func needsApproval(repo *model.Repo, pipeline *model.Pipeline) bool { // repository requires approval for pull requests from forks case model.RequireApprovalForks: - if (pipeline.Event == model.EventPull || pipeline.Event == model.EventPullClosed) && pipeline.FromFork { + if pipeline.IsPullRequest() && pipeline.FromFork { return true } // repository requires approval for pull requests case model.RequireApprovalPullRequests: - if pipeline.Event == model.EventPull || pipeline.Event == model.EventPullClosed { + if pipeline.IsPullRequest() { return true } diff --git a/server/pipeline/gated_test.go b/server/pipeline/gated_test.go index c429c9a0393..3209875d576 100644 --- a/server/pipeline/gated_test.go +++ b/server/pipeline/gated_test.go @@ -59,6 +59,17 @@ func TestSetGatedState(t *testing.T) { }, expectBlocked: true, }, + { + name: "require approval for edited PRs", + repo: &model.Repo{ + RequireApproval: model.RequireApprovalPullRequests, + }, + pipeline: &model.Pipeline{ + Event: model.EventPullMetadata, + FromFork: false, + }, + expectBlocked: true, + }, { name: "require approval for everything", repo: &model.Repo{ diff --git a/server/pipeline/stepbuilder/metadata.go b/server/pipeline/stepbuilder/metadata.go index db549678e6a..3d82e770a76 100644 --- a/server/pipeline/stepbuilder/metadata.go +++ b/server/pipeline/stepbuilder/metadata.go @@ -111,16 +111,17 @@ func metadataPipelineFromModelPipeline(pipeline *model.Pipeline, includeParent b } return metadata.Pipeline{ - Number: pipeline.Number, - Parent: parent, - Created: pipeline.Created, - Started: pipeline.Started, - Finished: pipeline.Finished, - Status: string(pipeline.Status), - Event: string(pipeline.Event), - ForgeURL: pipeline.ForgeURL, - DeployTo: pipeline.DeployTo, - DeployTask: pipeline.DeployTask, + Number: pipeline.Number, + Parent: parent, + Created: pipeline.Created, + Started: pipeline.Started, + Finished: pipeline.Finished, + Status: string(pipeline.Status), + Event: string(pipeline.Event), + EventReason: pipeline.EventReason, + ForgeURL: pipeline.ForgeURL, + DeployTo: pipeline.DeployTo, + DeployTask: pipeline.DeployTask, Commit: metadata.Commit{ Sha: pipeline.Commit, Ref: pipeline.Ref, diff --git a/web/src/assets/locales/en.json b/web/src/assets/locales/en.json index d849c1ba38c..79858dbc6c8 100644 --- a/web/src/assets/locales/en.json +++ b/web/src/assets/locales/en.json @@ -239,6 +239,7 @@ "tag": "Tag", "pr": "Pull Request", "pr_closed": "Pull Request merged/closed", + "pr_metadata": "Pull Request metadata changed", "deploy": "Deploy", "cron": "Cron", "manual": "Manual", diff --git a/web/src/components/atomic/Icon.vue b/web/src/components/atomic/Icon.vue index 932dc5dde51..8901d6f3239 100644 --- a/web/src/components/atomic/Icon.vue +++ b/web/src/components/atomic/Icon.vue @@ -5,6 +5,7 @@ + @@ -179,6 +180,7 @@ export type IconNames = | 'branch' | 'pull-request' | 'pull-request-closed' + | 'pull-request-metadata' | 'manual-pipeline' | 'tag' | 'deployment' diff --git a/web/src/components/repo/pipeline/PipelineItem.vue b/web/src/components/repo/pipeline/PipelineItem.vue index 061302d4b82..4ffc3e7d9ae 100644 --- a/web/src/components/repo/pipeline/PipelineItem.vue +++ b/web/src/components/repo/pipeline/PipelineItem.vue @@ -43,6 +43,7 @@ + @@ -105,6 +106,8 @@ const pipelineEventTitle = computed(() => { return t('repo.pipeline.event.pr'); case 'pull_request_closed': return t('repo.pipeline.event.pr_closed'); + case 'pull_request_metadata': + return t('repo.pipeline.event.pr_metadata'); case 'deployment': return t('repo.pipeline.event.deploy'); case 'tag': diff --git a/web/src/components/repo/pipeline/PipelineStepList.vue b/web/src/components/repo/pipeline/PipelineStepList.vue index 82112f4f6f0..39ab922d110 100644 --- a/web/src/components/repo/pipeline/PipelineStepList.vue +++ b/web/src/components/repo/pipeline/PipelineStepList.vue @@ -11,7 +11,13 @@ {{ pipeline.author }} diff --git a/web/src/compositions/usePipeline.ts b/web/src/compositions/usePipeline.ts index 3937dfa8364..61142149d37 100644 --- a/web/src/compositions/usePipeline.ts +++ b/web/src/compositions/usePipeline.ts @@ -94,7 +94,11 @@ export default (pipeline: Ref) => { return pipeline.value.ref.replaceAll('refs/tags/', ''); } - if (pipeline.value?.event === 'pull_request' || pipeline.value?.event === 'pull_request_closed') { + if ( + pipeline.value?.event === 'pull_request' || + pipeline.value?.event === 'pull_request_closed' || + pipeline.value?.event === 'pull_request_metadata' + ) { return `#${pipeline.value.ref .replaceAll('refs/pull/', '') .replaceAll('refs/merge-requests/', '') diff --git a/web/src/lib/api/types/pipeline.ts b/web/src/lib/api/types/pipeline.ts index 2ca9ccf0d84..0016176a1ed 100644 --- a/web/src/lib/api/types/pipeline.ts +++ b/web/src/lib/api/types/pipeline.ts @@ -19,6 +19,8 @@ export interface Pipeline { event: WebhookEvents; + event_reason: string[]; + // The current status of the pipeline. status: PipelineStatus; diff --git a/web/src/lib/api/types/webhook.ts b/web/src/lib/api/types/webhook.ts index e7310f6ed27..686e1b51072 100644 --- a/web/src/lib/api/types/webhook.ts +++ b/web/src/lib/api/types/webhook.ts @@ -5,6 +5,7 @@ export enum WebhookEvents { Release = 'release', PullRequest = 'pull_request', PullRequestClosed = 'pull_request_closed', + PullRequestMetadata = 'pull_request_metadata', Deploy = 'deployment', Cron = 'cron', Manual = 'manual', diff --git a/web/src/views/repo/RepoBranch.vue b/web/src/views/repo/RepoBranch.vue index 959c4c3bcdd..33c74613aef 100644 --- a/web/src/views/repo/RepoBranch.vue +++ b/web/src/views/repo/RepoBranch.vue @@ -23,7 +23,11 @@ const repo = requiredInject('repo'); const allPipelines = requiredInject('pipelines'); const pipelines = computed(() => allPipelines.value.filter( - (b) => b.branch === branch.value && b.event !== 'pull_request' && b.event !== 'pull_request_closed', + (b) => + b.branch === branch.value && + b.event !== 'pull_request' && + b.event !== 'pull_request_closed' && + b.event !== 'pull_request_metadata', ), ); diff --git a/web/src/views/repo/RepoPullRequest.vue b/web/src/views/repo/RepoPullRequest.vue index d179f854bcf..db4d35900fa 100644 --- a/web/src/views/repo/RepoPullRequest.vue +++ b/web/src/views/repo/RepoPullRequest.vue @@ -26,7 +26,7 @@ const allPipelines = requiredInject('pipelines'); const pipelines = computed(() => allPipelines.value.filter( (b) => - (b.event === 'pull_request' || b.event === 'pull_request_closed') && + (b.event === 'pull_request' || b.event === 'pull_request_closed' || b.event === 'pull_request_metadata') && b.ref .replaceAll('refs/pull/', '') .replaceAll('refs/merge-requests/', '') diff --git a/woodpecker-go/woodpecker/const.go b/woodpecker-go/woodpecker/const.go index 06dfe324ae7..eb7e7d46cd2 100644 --- a/woodpecker-go/woodpecker/const.go +++ b/woodpecker-go/woodpecker/const.go @@ -16,14 +16,15 @@ package woodpecker // Event values. const ( - EventPush = "push" - EventPull = "pull_request" - EventPullClosed = "pull_request_closed" - EventTag = "tag" - EventRelease = "release" - EventDeploy = "deployment" - EventCron = "cron" - EventManual = "manual" + EventPush = "push" + EventPull = "pull_request" + EventPullClosed = "pull_request_closed" + EventPullMetadata = "pull_request_metadata" + EventTag = "tag" + EventRelease = "release" + EventDeploy = "deployment" + EventCron = "cron" + EventManual = "manual" ) // Status values. diff --git a/woodpecker-go/woodpecker/types.go b/woodpecker-go/woodpecker/types.go index 99b3099fc1a..7b071ba6c57 100644 --- a/woodpecker-go/woodpecker/types.go +++ b/woodpecker-go/woodpecker/types.go @@ -96,32 +96,33 @@ type ( // Pipeline defines a pipeline object. Pipeline struct { - ID int64 `json:"id"` - Number int64 `json:"number"` - Parent int64 `json:"parent"` - Event string `json:"event"` - Status string `json:"status"` - Errors []*PipelineError `json:"errors"` - Created int64 `json:"created"` - Updated int64 `json:"updated"` - Started int64 `json:"started"` - Finished int64 `json:"finished"` - Deploy string `json:"deploy_to"` - Commit string `json:"commit"` - Branch string `json:"branch"` - Ref string `json:"ref"` - Refspec string `json:"refspec"` - Title string `json:"title"` - Message string `json:"message"` - Timestamp int64 `json:"timestamp"` - Sender string `json:"sender"` - Author string `json:"author"` - Avatar string `json:"author_avatar"` - Email string `json:"author_email"` - ForgeURL string `json:"forge_url"` - Reviewer string `json:"reviewed_by"` - Reviewed int64 `json:"reviewed"` - Workflows []*Workflow `json:"workflows,omitempty"` + ID int64 `json:"id"` + Number int64 `json:"number"` + Parent int64 `json:"parent"` + Event string `json:"event"` + EventReason []string `json:"event_reason"` + Status string `json:"status"` + Errors []*PipelineError `json:"errors"` + Created int64 `json:"created"` + Updated int64 `json:"updated"` + Started int64 `json:"started"` + Finished int64 `json:"finished"` + Deploy string `json:"deploy_to"` + Commit string `json:"commit"` + Branch string `json:"branch"` + Ref string `json:"ref"` + Refspec string `json:"refspec"` + Title string `json:"title"` + Message string `json:"message"` + Timestamp int64 `json:"timestamp"` + Sender string `json:"sender"` + Author string `json:"author"` + Avatar string `json:"author_avatar"` + Email string `json:"author_email"` + ForgeURL string `json:"forge_url"` + Reviewer string `json:"reviewed_by"` + Reviewed int64 `json:"reviewed"` + Workflows []*Workflow `json:"workflows,omitempty"` } // Workflow represents a workflow in the pipeline.