Skip to content

Add support for creation and removal of branches and tags.

Created by: thomasbiddle

This commit takes advantage of the commit I added to gitlab-shell.

Added API endpoints for POST (Create) and DELETE (Delete, duh.) of branch and tag resources. It takes advantage using Sidekiq to throw the actions into a background process as Gitlab does for many other actions; however Gitlab is setup to cache the branches and tags - So we need to expire the cache. There's a nice existing expire_cache method in the repository model to do this.

We can run into an issue with race conditions in which the expire_cache would be called before the branch was created, rendering it moot - But (Would need to double check this) I believe many other actions expire the cache anyhow - So on any active project it would be updated soon anyhow. I originally thought about passing along the repository object into Sidekiq but this caused Redis to lock up entirely and until I flushed all keys it wouldn't run any sidekiq jobs, even if I cleared them.

This is a very useful feature as personally I integrate with Gitlab and would like to create tags and branches upon different actions when deploying to various environments (Deploy to staging - Create a release candidate branch, deploy to prod - Create a tag)

See GitHub's API for a reference as they support a similar setup: http://developer.github.com/v3/git/refs/

Let me know if there is anything that could be improved!

Merge request reports

Loading