{"id":24176539,"url":"https://github.com/cropalato/mergesentinel","last_synced_at":"2025-09-03T12:46:16.885Z","repository":{"id":254465352,"uuid":"846604769","full_name":"cropalato/MergeSentinel","owner":"cropalato","description":"The application controls the approval of merge requests in GitLab Community Edition, ensuring they can only be approved when specific conditions are met.","archived":false,"fork":false,"pushed_at":"2025-01-31T21:17:18.000Z","size":227,"stargazers_count":8,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-21T12:35:24.317Z","etag":null,"topics":["approval","gitlab","gitlab-ce","golang","merge-request","rest-api","webhook"],"latest_commit_sha":null,"homepage":"https://hub.docker.com/r/cropalato/mergesentinel","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cropalato.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-08-23T15:00:27.000Z","updated_at":"2025-01-26T16:47:59.000Z","dependencies_parsed_at":"2024-08-25T20:27:11.029Z","dependency_job_id":"1797255b-ca33-448c-bf1d-37c480e23279","html_url":"https://github.com/cropalato/MergeSentinel","commit_stats":null,"previous_names":["cropalato/mergesentinel"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/cropalato/MergeSentinel","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cropalato%2FMergeSentinel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cropalato%2FMergeSentinel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cropalato%2FMergeSentinel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cropalato%2FMergeSentinel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cropalato","download_url":"https://codeload.github.com/cropalato/MergeSentinel/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cropalato%2FMergeSentinel/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273445913,"owners_count":25107150,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-03T02:00:09.631Z","response_time":76,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["approval","gitlab","gitlab-ce","golang","merge-request","rest-api","webhook"],"created_at":"2025-01-13T03:16:23.503Z","updated_at":"2025-09-03T12:46:16.820Z","avatar_url":"https://github.com/cropalato.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MergeSentinel\n\n**MergeSentinel** is a Go application designed to enhance the merge request (MR) process in GitLab. It listens for HTTP calls from GitLab project webhooks when a merge request action occurs. Depending on the rules configured, it will enable or disable the button used to accept the merge request, ensuring that all predefined criteria are met before a merge can be approved.\n\n## Features\n\n- **Webhook Listener:** Receives HTTP calls from GitLab project webhooks.\n- **Rule Enforcement:** Checks if specific rules are met before allowing a merge request to be accepted.\n- **Automatic Control:** Enables or disables the merge request button based on rule validation.\n\n## Installation\n\nTo set up **MergeSentinel** locally:\n\n1. **Clone the repository:**\n   ```bash\n   git clone https://github.com/cropalato/MergeSentinel.git\n   ```\n\n2. **Navigate to the project directory:**\n   ```bash\n   cd MergeSentinel\n   ```\n\n3. **Build the application:**\n   ```bash\n   # export CGO_ENABLED=0 # if you want to create a static build\n   go build -a -o bin ./...\n   ```\n\n4. Run the application:\n   ```bash\n   ./MergeSentinel\n   ```\n\n## Configuration\n\n**MergeSentinel** uses a JSON configuration file to manage its settings. Below is an example of the required structure:\n\n```json\n{\n  \"gitlab_token\": \"\u003ctoken\u003e\",\n  \"gitlab_url\": \"https://\u003cgitlab URL\u003e\",\n  \"webhook_token\": \"\u003cwebhook token\u003e\",\n  \"projects\": [\n    {\n      \"project_id\": \u003cID\u003e,\n      \"approvals\": [\"\u003cuser1\u003e\", \"\u003cuser2\u003e\", \"\u003cuser3\u003e\"],\n      \"webhook_token\": \"\u003cwebhook token\u003e\",\n      \"min_approv\": 2\n    }\n  ],\n  \"psql_conn_url\": \"postgres://\u003cuser\u003e:\u003cpass\u003e@\u003cgitlab PostgreSQL fqdn\u003e/gitlabhq_production?sslmode=disable\"\n}\n```\n\n### Configuration Fields\n\n- **`gitlab_token`**: The personal access token for authenticating API requests to GitLab.\n- **`gitlab_url`**: The base URL of your GitLab instance.\n- **`webhook_token`**: The webhook token used in gitlab webhook calls. If not defined in project level, this one will be used.\n- **`projects`**: An array of project-specific configurations:\n    - **`project_id`**: The ID of the GitLab project.\n    - **`approvals`**: A list of users required to approve the merge request.\n    - **`min_approv`**: The minimum number of approvals required to allow the merge request to proceed.\n    - **`webhook_token`**: The webhook token used in gitlab webhook calls.\n- **`psql_conn_url`**: The PostgreSQL connection URL for accessing the GitLab database, including user credentials, the fully qualified domain name (FQDN) of the GitLab PostgreSQL server, and the name of the database (**`gitlabhq_production`**).\n\n## Usage\n\nAfter setting up the application, configure your GitLab project to send webhook events to the MergeSentinel server.\n\nExample configuration:\n\n1. In your GitLab project, navigate to **Settings \u003e Webhooks\"\".\n2. Add the URL where **MergeSentinel** is hosted.\n3. Select the events you want to monitor, such as \"Merge Request Events.\"\n4. Save the webhook.\n\n**MergeSentinel** will now monitor merge requests and enforce your rules.\n\n## postgreSQL configuration\n\nMergeSentinel will call gitlab postgreSQL server to update merge request table. It will be a SELECT and an UPDATE query, like:\n```bash\nSELECT * FROM merge_requests WHERE iid = 1 AND target_project_id = 1;\n```\n```bash\nUPDATE merge_requests SET merge_status = 'cannot_be_merged', merge_error = ''Requires at least 2 approvals from [user1 user7]. WHERE iid = 1 AND target_project_id = 1;\n```\nYou can want to create a user for that. can be something like that:\n```bash\nCREATE USER merge_sentinel WITH PASSWORD 'zoohoo6T';\nGRANT SELECT, UPDATE (merge_status,merge_error) ON TABLE merge_requests TO merge_sentinel;\n```\n\n## Contributing\n\nContributions are welcome! Please follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) guidelines when making commits. Here's how you can contribute:\n\n1. **Fork the repository.**\n2. **Create a new branch:**\n   - Use a descriptive name that follows the Conventional Commits format, such as `feat/add-new-feature` or `fix/bug-description`.\n   - Example: \n     ```bash\n     git checkout -b feat/your-feature-name\n     ```\n3. **Make your changes.**\n   - Commit your changes using the Conventional Commits format:\n     - `feat:` for new features.\n     - `fix:` for bug fixes.\n     - `docs:` for documentation changes.\n     - `style:` for code style changes (e.g., formatting).\n     - `refactor:` for code refactoring.\n     - `test:` for adding or updating tests.\n     - `chore:` for other changes that don't modify src or test files.\n   - Example commit message:\n     ```bash\n     git commit -m \"feat: add ability to validate merge rules\"\n     ```\n4. **Push your changes:**\n   ```bash\n   git push origin feat/your-feature-name\n   ```\n5. **Open a pull request.**\n   Please ensure your code follows the project's coding standards and includes relevant tests. Reviewers will give feedback as soon as possible.\n   \n## License\n\nThis project is licensed under the MIT License. See the LICENSE file for details.\n\n## Contact\n\nIf you have any questions, issues, or suggestions, feel free to open an issue.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcropalato%2Fmergesentinel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcropalato%2Fmergesentinel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcropalato%2Fmergesentinel/lists"}