Skip to content

Validate branch/tag-names and references WebUI, API

Matthias Käppler requested to merge github/fork/Razer6/git_ref_validation into master

Created by: Razer6

What does this MR do?

This PR adds validation for invalid input for branch and tag names. Validating a name is done using the git subcommand git check-ref-format. If an error occurs, an error message is shown indicating a wrong input.

This behavior is also added to the API. If an error occurs a 405 error responded.

Why was this MR needed?

Currently when entering an invalid name for branch or invalid reference name GitLab fails silently or raises a 500 error. This behavior also applies if the branch already exists.

What are the relevant issue numbers / Feature requests?

This PR fixes:

TODO

  • Add support for tag validation

Many thanks to @jvanbaarsen for his help for a ruby beginner.

@randx Creating a new branch within the spinach test doesn't work. The current testcases passes because the branch already exists in the test repository. @jvanbaarsen also looked at this problem, but doesn't know what's going on here.

Something similar happens on specs. Since there is now an explicit return value when creating a new branch, this fails and returns an error. Have you any thoughts why creating a branch doesn't work within the testsuite?

/cc @cirosantilli

Merge request reports

Loading