Class: Gitlab::GitPostReceive

Inherits:
Object
  • Object
show all
Includes:
Identifier
Defined in:
lib/gitlab/git_post_receive.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Identifier

#identification_cache, #identify_using_deploy_key, #identify_using_ssh_key, #identify_using_user, #identify_with_cache

Constructor Details

#initialize(container, identifier, changes, push_options = {}) ⇒ GitPostReceive

Returns a new instance of GitPostReceive.



9
10
11
12
13
14
# File 'lib/gitlab/git_post_receive.rb', line 9

def initialize(container, identifier, changes, push_options = {})
  @container = container
  @identifier = identifier
  @changes = parse_changes(changes)
  @push_options = push_options
end

Instance Attribute Details

#changesObject (readonly)

Returns the value of attribute changes.



7
8
9
# File 'lib/gitlab/git_post_receive.rb', line 7

def changes
  @changes
end

#containerObject (readonly)

Returns the value of attribute container.



7
8
9
# File 'lib/gitlab/git_post_receive.rb', line 7

def container
  @container
end

#identifierObject (readonly)

Returns the value of attribute identifier.



7
8
9
# File 'lib/gitlab/git_post_receive.rb', line 7

def identifier
  @identifier
end

#push_optionsObject (readonly)

Returns the value of attribute push_options.



7
8
9
# File 'lib/gitlab/git_post_receive.rb', line 7

def push_options
  @push_options
end

Instance Method Details

#identifyObject



16
17
18
# File 'lib/gitlab/git_post_receive.rb', line 16

def identify
  super(identifier) || identify_using_deploy_key(identifier)&.user
end

#includes_branches?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/gitlab/git_post_receive.rb', line 20

def includes_branches?
  changes.includes_branches?
end

#includes_default_branch?Boolean

Returns:

  • (Boolean)


28
29
30
31
32
33
34
35
36
# File 'lib/gitlab/git_post_receive.rb', line 28

def includes_default_branch?
  # If the branch doesn't have a default branch yet, we presume the
  # first branch pushed will be the default.
  return true unless container.default_branch.present?

  changes.branch_changes.any? do |change|
    Gitlab::Git.branch_name(change[:ref]) == container.default_branch
  end
end

#includes_tags?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/gitlab/git_post_receive.rb', line 24

def includes_tags?
  changes.includes_tags?
end