Class: Txgh::GitRepo

Inherits:
Object
  • Object
show all
Defined in:
lib/txgh/git_repo.rb

Direct Known Subclasses

GithubRepo, GitlabRepo

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config, api) ⇒ GitRepo

Returns a new instance of GitRepo.



5
6
7
8
# File 'lib/txgh/git_repo.rb', line 5

def initialize(config, api)
  @config = config
  @api = api
end

Instance Attribute Details

#apiObject (readonly)

Returns the value of attribute api.



3
4
5
# File 'lib/txgh/git_repo.rb', line 3

def api
  @api
end

#configObject (readonly)

Returns the value of attribute config.



3
4
5
# File 'lib/txgh/git_repo.rb', line 3

def config
  @config
end

Instance Method Details

#branchObject



14
15
16
# File 'lib/txgh/git_repo.rb', line 14

def branch
  config['branch']
end

#commit_messageObject



74
75
76
# File 'lib/txgh/git_repo.rb', line 74

def commit_message
  config['commit_message']
end

#diff_pointObject



30
31
32
# File 'lib/txgh/git_repo.rb', line 30

def diff_point
  config['diff_point']
end

#git_config_branchObject



46
47
48
49
50
51
52
53
54
# File 'lib/txgh/git_repo.rb', line 46

def git_config_branch
  @git_config_branch ||= begin
    if process_all_branches?
      'all'
    else
      Utils.absolute_branch(branch || 'master')
    end
  end
end

#git_config_tagObject



56
57
58
59
60
61
62
63
64
# File 'lib/txgh/git_repo.rb', line 56

def git_config_tag
  @git_config_tag ||= begin
    if process_all_tags?
      'all'
    else
      Utils.absolute_branch(tag) if tag
    end
  end
end

#nameObject



10
11
12
# File 'lib/txgh/git_repo.rb', line 10

def name
  config['name']
end

#process_all_branches?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/txgh/git_repo.rb', line 22

def process_all_branches?
  branch == 'all'
end

#process_all_tags?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/txgh/git_repo.rb', line 34

def process_all_tags?
  tag == 'all'
end

#should_process_ref?(candidate) ⇒ Boolean

Returns:

  • (Boolean)


38
39
40
41
42
43
44
# File 'lib/txgh/git_repo.rb', line 38

def should_process_ref?(candidate)
  if Utils.is_tag?(candidate)
    should_process_tag?(candidate)
  else
    should_process_branch?(candidate)
  end
end

#tagObject



18
19
20
# File 'lib/txgh/git_repo.rb', line 18

def tag
  config['tag']
end

#upload_diffs?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/txgh/git_repo.rb', line 26

def upload_diffs?
  !(diff_point || '').empty?
end

#webhook_protected?Boolean

Returns:

  • (Boolean)


70
71
72
# File 'lib/txgh/git_repo.rb', line 70

def webhook_protected?
  !(webhook_secret || '').empty?
end

#webhook_secretObject



66
67
68
# File 'lib/txgh/git_repo.rb', line 66

def webhook_secret
  config['webhook_secret']
end