-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Validate branch/tag-names and references WebUI, API #7382
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
I've prepared a stage. Click to open. |
spec/requests/api/branches_spec.rb
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jvanbaarsen Should I fix them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah please do so
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your wish is my command
|
@Razer6 Thanks for the nice MR format 🍰 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you maybe also create a spec for this class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️
|
@jvanbaarsen I added a spec for the validator and also for validation for the tags page. One question: There are 2 syntax between spinach features and steps.
What to prefer? |
|
@Razer6 I dont think I understand? |
|
Compare https://github.com/gitlabhq/gitlabhq/blob/master/features/steps/project/browse_branches.rb with https://github.com/gitlabhq/gitlabhq/blob/master/features/steps/project/browse_commits.rb The first one uses step 'I click link "All"' do
click_link "All"
endthe second uses Given 'I click atom feed link' do
click_link "Feed"
end |
|
The tests fail because adding a branch/tag fails within the testsuite. I think the problem is, that there is no |
|
I also need to edit files / create branches on the tests for #7266 . This is a blocking issue for the feature. The following existing test is a false pass:
Because the "newly" created branch
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a falsely passing test because the deploy_keys branch already exists in the seed. Proposed solution at: step 'I submit new branch form' and step 'I submit new branch form' use a branch name that does not exist like not_yet_a_branch instead of deploy_keys.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
Additional, I needed to add whitespace stripping to find valid references. @randx Have you an idea how to implemement the tests here? |
|
With the refactored tests from @randx all testcases pass locally. @jvanbaarsen Can you review? |
|
For future reference, the commit that fixes the tests is: e09ef2f, and now no more huge .gz seed: a small test repo is cloned from https://gitlab.com/gitlab-org/gitlab-test once when the tests are run. WAY TO GO!! |
|
@randx rebases, all tests pass locally |
|
@Razer6 Can you please squash the commits? |
|
@jvanbaarsen I squashed the commits, but I still separated between branches and tags. |
|
@randx ping |
Add specs for GitRefValidator
886d275 to
3921139
Compare
|
@randx Rebased! |
|
looks good |
Validate branch/tag-names and references WebUI, API
|
Awesome functionality, thanks and congratulations @Razer6 ! @jvanbaarsen Thanks Marshal! |
|
Yeah, the first bigger PR i did ❤️ |
|
Yes, consider updating http://www.rschilling.net/ to include Ruby :-) |
|
@dosire Good catch 👍 |
|
@Razer6 Also kidding a bit, but awesome stuff! Secretly hoping it will keep raining in Austria for 2 years (except for January when I visit of course). |
|
@Razer6 Again kidding of course 💟 |
|
😏 When are coming to Austria? Skiing in the winter? I have a call with @randx tomorrow to discuss some things, expect awesomeness! |
|
@Razer6 Skiing, no that is for your people (kidding, I love that and snowboarding). But we crazy Dutch people prefer speed skating http://www.weissensee.nl/ I'll sign up for 200km at the end of January. |
|
@dosire There is a Dutch hompage for an Austrian lake 😲 😲? You are really crazy 😄 |
|
@Razer6 We are, you should see my finish video of last year, I was pretty happy to conclude my first year of iceskating http://live.ultimate.dk/video/front/?eventid=220108&language=nl&pid=7297&timefield=Lap&videoid=18&timeday=65173000&timerace=11:01:06&timingpoint=175%20km&timeid=14 |
|
OMG 😱 175km in one run? After 175km you can really be happy. Congrats 👍 |
|
@Razer6 Thanks! |
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
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