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_ssh_key, #identify_using_user, #identify_with_cache

Constructor Details

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

Returns a new instance of GitPostReceive.


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

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.


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

def changes
  @changes
end

#containerObject (readonly)

Returns the value of attribute container.


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

def container
  @container
end

#identifierObject (readonly)

Returns the value of attribute identifier.


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

def identifier
  @identifier
end

#push_optionsObject (readonly)

Returns the value of attribute push_options.


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

def push_options
  @push_options
end

Instance Method Details

#identifyObject


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

def identify
  super(identifier)
end

#includes_branches?Boolean

Returns:

  • (Boolean)

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

def includes_branches?
  changes.includes_branches?
end

#includes_default_branch?Boolean

Returns:

  • (Boolean)

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

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)

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

def includes_tags?
  changes.includes_tags?
end