Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove merge request from GitLab server

I created a merge request on gitlab (local) server. Now whenever I click on the merge request, the request times out with error 500. Before that I used to get an error code 504 and I applied the change mentioned in this gitlab support topic.

All I want to do is remove the merge request. Is there a manual way of doing this?

like image 408
Sanj Avatar asked Aug 25 '15 02:08

Sanj


People also ask

How do I cancel a merge request?

How do I cancel a git merge? Use git-reset or git merge --abort to cancel a merge that had conflicts. Please note that all the changes will be reset, and this operation cannot be reverted, so make sure to commit or git-stash all your changes before you start a merge.

How do I delete a merged pull request?

Under your repository name, click Pull requests. Click Closed to see a list of closed pull requests. In the list of pull requests, click the pull request that's associated with the branch that you want to delete. Near the bottom of the pull request, click Delete branch.

How do I delete a merge request in github?

Under your repository name, click Pull requests. In the "Pull Requests" list, click the pull request you'd like to close. At the bottom of the pull request, below the comment box, click Close pull request. Optionally, delete the branch.


3 Answers

Web UI Option

Today I discovered a way to do this with the Web UI.

So for Merge Request 14

https://gitlab.example.com/MyGroup/MyProject/merge_requests/14/edit

On the bottom Right you should see a red Delete button.

Gitlab Delete Merge Request Screen Shot

PowerShell Option

Invoke-RestMethod -Method Delete -Uri 'https://gitlab.example.com/api/v4/projects/PROJECT_ID_GOES_HERE/merge_requests/14' -Headers @{'PRIVATE-TOKEN'='PRIVATE_TOKEN_GOES_HERE'}

like image 72
Eric D. Johnson Avatar answered Oct 12 '22 09:10

Eric D. Johnson


Yes, there is.... I could not find a way to remove the merge request in the user interface, but you can simply delete it from the database.

(Please note, that I only tested this on gitlab CE 8.4.0-ce.0 on Ubuntu 14.04.3 LTS.. Other versions may have a different database structure)

At a command prompt, execute the following command (as root):

sudo -u gitlab-psql /opt/gitlab/embedded/bin/psql -h /var/opt/gitlab/postgresql -d gitlabhq_production

This will bring up a PostgreSQL command terminal. Next, you'll have to find the merge request you'd like to delete. Type the following at the PostgreSQL command terminal:

select id, title from merge_requests;

You'll get a list of merge request ids and titles. Find the one you'd like to delete and note the id

OK, let's say you've found the merge request you'd like to delete and the id is 5. You're simply going to delete all the data associated with that merge request using the following SQL commands. (Substitute 5 in the commands below with your actual merge request id)

delete from merge_requests where id = 5;
delete from merge_request_diffs where merge_request_id = 5;
delete from notes where noteable_type = 'MergeRequest' and noteable_id = 5;

You can now exit out of the PostgreSQL command terminal by typing:

\q

Your merge request should now be gone from the web interface.

like image 39
Ray Perea Avatar answered Oct 12 '22 08:10

Ray Perea


I don't know if this works with CE as well, but at least EE has an API endpoint to delete merge requests:

curl --request DELETE --header "PRIVATE-TOKEN: <private_token>" https://gitlab.example.com/api/v3/projects/4/merge_request/85
like image 11
Thomas Keller Avatar answered Oct 12 '22 10:10

Thomas Keller