Skip to content
GitLab Next
  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • GitLab FOSS GitLab FOSS
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
    • Requirements
  • Merge requests 1
    • Merge requests 1
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Container Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Metrics
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • Code review
    • Insights
    • Issue
    • Repository
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • GitLab.org
  • GitLab FOSSGitLab FOSS
  • Merge requests
  • !18462

Fix errors on pushing/editing files on empty repositories

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Bob Van Landuyt requested to merge bvl-fix-maintainer-push-error into master Apr 18, 2018
  • Overview 29
  • Commits 2
  • Pipelines 11
  • Changes 16

What does this MR do?

  • In this branch we allow admins to push to empty projects, where the default branch is protected.
  • This fixes a crash when someone is not authorized.

The crash was initially caused by calling Gitlab::UserAccess#can_push_to_branch? without a project, we would end up there because a the user can_collaborate_with_project? since they can push_code. Then we'd check if they can push to the branch, but there is none yet, and we don't allow developers to create a new default branch, this needs to be done by owners or admins. So the @project_to_commit_into in CreatesCommit would be empty.

But in the case of a developer, they wouldn't actually be allowed to push to create the new default branch. So we're hiding the buttons

This MR hides the buttons if the user cannot push to the master branch, and hides the commands the user cannot perform.

Screenshots (if relevant)

User can push

Screen_Shot_2018-04-19_at_09.19.59

User can not push

Screen_Shot_2018-04-19_at_09.21.05

Does this MR meet the acceptance criteria?

  • Changelog entry added, if necessary
  • Documentation created/updated
  • API support added
  • Tests added for this feature/bug
  • Review
    • Has been reviewed by UX
    • Has been reviewed by Frontend
    • Has been reviewed by Backend
    • Has been reviewed by Database
  • Conform by the merge request performance guides
  • Conform by the style guides
  • Squashed related commits together
  • Internationalization required/considered
  • End-to-end tests pass (package-and-qa manual pipeline job)

What are the relevant issue numbers?

Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/44618 Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/42583

Edited Apr 20, 2018 by Michael Kozono
Assignee
Assign to
Reviewer
Request review from
Time tracking
Source branch: bvl-fix-maintainer-push-error