Skip to content
Snippets Groups Projects

Move GitHooksService into Gitlab::Git

Merged Jacob Vosmaer (GitLab) requested to merge git-operation-user into master
All threads resolved!

What does this MR do?

  • move GitHooksService in to Gitlab::Git
  • decouple GitHooksService from User and Project
  • make gl_repository an attribute of Gitlab::Git::Repository

Are there points in the code the reviewer needs to double check?

Why was this MR needed?

We want to move the code that creates commits and updates refs in repositories into Gitlab::Git.

Screenshots (if relevant)

Does this MR meet the acceptance criteria?

What are the relevant issue numbers?

Edited by Jacob Vosmaer (GitLab)

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Jacob Vosmaer (GitLab) unmarked as a Work In Progress

    unmarked as a Work In Progress

  • This MR doesn't make that much sense on its own, but I find myself making so many changes that it seems useful to submit them as I go.

  • changed milestone to %10.0

  • added 2 commits

    Compare with previous version

  • Failed because of a rubocop violation in a file I didn't touch. Rebased on master.

  • added 101 commits

    Compare with previous version

  • @jacobvosmaer-gitlab thanks! Couple of questions.

  • added 1 commit

    Compare with previous version

  • mentioned in merge request !13773 (merged)

  • Waiting for a1a91499 to show up in the diff.

  • Assigning to self until diffs are up to date.

  • added 1 commit

    Compare with previous version

  • added 1 commit

    Compare with previous version

  • username-removed-443319 resolved all discussions

    resolved all discussions

  • username-removed-443319 approved this merge request

    approved this merge request

  • mentioned in commit e46a3d2f

  • This appears to have introduced a failure on master:

      1) Gitlab::Git::Repository#branch_count with local and remote branches returns the count of local branches
         Failure/Error:
                 def initialize(storage, relative_path, gl_repository)
                   @storage = storage
                   @relative_path = relative_path
                   @gl_repository = gl_repository
    
                   storage_path = Gitlab.config.repositories.storages[@storage]['path']
                   @path = File.join(storage_path, @relative_path)
                   @name = @relative_path.split("/").last
                   @attributes = Gitlab::Git::Attributes.new(path)
                 end
    
         ArgumentError:
           wrong number of arguments (given 2, expected 3)
         # ./lib/gitlab/git/repository.rb:56:in `initialize'
         # ./spec/lib/gitlab/git/repository_spec.rb:983:in `new'
         # ./spec/lib/gitlab/git/repository_spec.rb:983:in `block (4 levels) in <top (required)>'
         # ./spec/lib/gitlab/git/repository_spec.rb:987:in `block (4 levels) in <top (required)>'
         # -e:1:in `<main>'
    
    
      2) Gitlab::Git::Repository#branch_count with local and remote branches with Gitaly disabled returns the count of local branches
         Failure/Error:
                 def initialize(storage, relative_path, gl_repository)
                   @storage = storage
                   @relative_path = relative_path
                   @gl_repository = gl_repository
    
                   storage_path = Gitlab.config.repositories.storages[@storage]['path']
                   @path = File.join(storage_path, @relative_path)
                   @name = @relative_path.split("/").last
                   @attributes = Gitlab::Git::Attributes.new(path)
                 end
    
         ArgumentError:
           wrong number of arguments (given 2, expected 3)
         # ./lib/gitlab/git/repository.rb:56:in `initialize'
         # ./spec/lib/gitlab/git/repository_spec.rb:983:in `new'
         # ./spec/lib/gitlab/git/repository_spec.rb:983:in `block (4 levels) in <top (required)>'
         # ./spec/lib/gitlab/git/repository_spec.rb:987:in `block (4 levels) in <top (required)>'
         # -e:1:in `<main>'
    
    Finished in 6.38 seconds (files took 0.83515 seconds to load)
    173 examples, 2 failures
    
    Failed examples:
    
    rspec ./spec/lib/gitlab/git/repository_spec.rb:996 # Gitlab::Git::Repository#branch_count with local and remote branches returns the count of local branches
    rspec ./spec/lib/gitlab/git/repository_spec.rb:1005 # Gitlab::Git::Repository#branch_count with local and remote branches with Gitaly disabled returns the count of local branches

    Traced back to this MR via git bisect.

  • I'm curious why, if the third argument to Gitlab::Git::Repository#initialize isn't actually required and we can get around this change by just passing '', why didn't we give it that as a default value and make it optional?

    Edited by Robert Speicher
  • @jacobvosmaer-gitlab I'm curious why, if the third argument to Gitlab::Git::Repository#initialize isn't actually required and we can get around this change by just passing '', why didn't we give it that as a default value and make it optional?

    @rspeicher this argument is used for hooks. We wouldn't want to make it optional, because that would break hooks, but specs never run hooks :disappointed:

  • Please register or sign in to reply
    Loading