git-semaphore 2.1.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,98 +2,98 @@ module Git
2
2
  module Semaphore
3
3
  class API
4
4
 
5
- def self.projects auth_token
5
+ def self.projects(auth_token)
6
6
  get_json projects_uri(auth_token)
7
7
  end
8
8
 
9
- def self.branches project_hash_id, auth_token
9
+ def self.branches(project_hash_id, auth_token)
10
10
  get_json branches_uri(project_hash_id, auth_token)
11
11
  end
12
12
 
13
- def self.status project_hash_id, branch_id, auth_token
13
+ def self.status(project_hash_id, branch_id, auth_token)
14
14
  get_json status_uri(project_hash_id, branch_id, auth_token)
15
15
  end
16
16
 
17
- def self.history project_hash_id, branch_id, auth_token
17
+ def self.history(project_hash_id, branch_id, auth_token)
18
18
  get_paginated_response(history_uri(project_hash_id, branch_id, auth_token)) do |previous_page, next_page|
19
19
  previous_page['builds'] += next_page['builds']
20
20
  end
21
21
  end
22
22
 
23
- def self.information project_hash_id, branch_id, build_number, auth_token
23
+ def self.information(project_hash_id, branch_id, build_number, auth_token)
24
24
  get_json information_uri(project_hash_id, branch_id, build_number, auth_token)
25
25
  end
26
26
 
27
- def self.log project_hash_id, branch_id, build_number, auth_token
27
+ def self.log(project_hash_id, branch_id, build_number, auth_token)
28
28
  get_json log_uri(project_hash_id, branch_id, build_number, auth_token)
29
29
  end
30
30
 
31
- def self.rebuild project_hash_id, branch_id, auth_token
31
+ def self.rebuild(project_hash_id, branch_id, auth_token)
32
32
  get_json last_revision_uri(project_hash_id, branch_id, auth_token), :post
33
33
  end
34
34
 
35
35
  # private helper functions
36
36
 
37
- def self.projects_uri auth_token
37
+ def self.projects_uri(auth_token)
38
38
  # https://semaphoreci.com/docs/projects-api.html
39
39
  # GET /api/v1/projects
40
- request_uri(auth_token, :path => File.join('projects'))
40
+ request_uri(auth_token, path: File.join('projects'))
41
41
  end
42
42
 
43
43
  private_class_method :projects_uri
44
44
 
45
- def self.branches_uri project_hash_id, auth_token
45
+ def self.branches_uri(project_hash_id, auth_token)
46
46
  # https://semaphoreci.com/docs/branches-and-builds-api.html#project_branches
47
47
  # GET /api/v1/projects/:hash_id/branches
48
- request_uri(auth_token, :path => File.join('projects', project_hash_id, 'branches'))
48
+ request_uri(auth_token, path: File.join('projects', project_hash_id, 'branches'))
49
49
  end
50
50
 
51
51
  private_class_method :branches_uri
52
52
 
53
- def self.status_uri project_hash_id, branch_id, auth_token
53
+ def self.status_uri(project_hash_id, branch_id, auth_token)
54
54
  # https://semaphoreci.com/docs/branches-and-builds-api.html#branch_status
55
55
  # GET /api/v1/projects/:hash_id/:id/status
56
- request_uri(auth_token, :path => File.join('projects', project_hash_id, branch_id, 'status'))
56
+ request_uri(auth_token, path: File.join('projects', project_hash_id, branch_id, 'status'))
57
57
  end
58
58
 
59
59
  private_class_method :status_uri
60
60
 
61
- def self.history_uri project_hash_id, branch_id, auth_token, page = 1
61
+ def self.history_uri(project_hash_id, branch_id, auth_token, page = 1)
62
62
  # https://semaphoreci.com/docs/branches-and-builds-api.html#branch_history
63
63
  # GET /api/v1/projects/:hash_id/:id
64
- request_uri(auth_token, :path => File.join('projects', project_hash_id, branch_id), :page => page)
64
+ request_uri(auth_token, path: File.join('projects', project_hash_id, branch_id), page: page)
65
65
  end
66
66
 
67
67
  private_class_method :history_uri
68
68
 
69
- def self.information_uri project_hash_id, branch_id, build_number, auth_token
69
+ def self.information_uri(project_hash_id, branch_id, build_number, auth_token)
70
70
  # https://semaphoreci.com/docs/branches-and-builds-api.html#build_information
71
71
  # GET /api/v1/projects/:hash_id/:id/builds/:number
72
- request_uri(auth_token, :path => File.join('projects', project_hash_id, branch_id, 'builds', build_number))
72
+ request_uri(auth_token, path: File.join('projects', project_hash_id, branch_id, 'builds', build_number))
73
73
  end
74
74
 
75
75
  private_class_method :information_uri
76
76
 
77
- def self.log_uri project_hash_id, branch_id, build_number, auth_token
77
+ def self.log_uri(project_hash_id, branch_id, build_number, auth_token)
78
78
  # https://semaphoreci.com/docs/branches-and-builds-api.html#build_log
79
79
  # GET /api/v1/projects/:hash_id/:id/builds/:number/log
80
- request_uri(auth_token, :path => File.join('projects', project_hash_id, branch_id, 'builds', build_number, 'log'))
80
+ request_uri(auth_token, path: File.join('projects', project_hash_id, branch_id, 'builds', build_number, 'log'))
81
81
  end
82
82
 
83
83
  private_class_method :log_uri
84
84
 
85
- def self.last_revision_uri project_hash_id, branch_id, auth_token
85
+ def self.last_revision_uri(project_hash_id, branch_id, auth_token)
86
86
  # https://semaphoreci.com/docs/branches-and-builds-api.html#rebuild
87
87
  # POST /api/v1/projects/:project_hash_id/:branch_id/build
88
- request_uri(auth_token, :path => File.join('projects', project_hash_id, branch_id, 'build'))
88
+ request_uri(auth_token, path: File.join('projects', project_hash_id, branch_id, 'build'))
89
89
  end
90
90
 
91
91
  private_class_method :last_revision_uri
92
92
 
93
93
  # more private helper functions
94
94
 
95
- def self.get_response uri, action = :get
96
- response = ::Net::HTTP.start(uri.host, uri.port, :use_ssl => (uri.scheme == 'https'), :verify_mode => ::OpenSSL::SSL::VERIFY_NONE) do |net_http|
95
+ def self.get_response(uri, action = :get)
96
+ response = ::Net::HTTP.start(uri.host, uri.port, use_ssl: (uri.scheme == 'https'), verify_mode: ::OpenSSL::SSL::VERIFY_NONE) do |net_http|
97
97
  case action
98
98
  when :get
99
99
  net_http.get uri.request_uri
@@ -105,7 +105,9 @@ module Git
105
105
  end
106
106
 
107
107
  def response.json_body
108
- raise "JSON response expected" unless self['content-type'] =~ %r{application/json}
108
+ unless self['content-type'].match?(%r{application/json})
109
+ raise 'JSON response expected'
110
+ end
109
111
  JSON.parse(body)
110
112
  end
111
113
 
@@ -114,7 +116,7 @@ module Git
114
116
 
115
117
  private_class_method :get_response
116
118
 
117
- def self.get_paginated_response uri, action = :get
119
+ def self.get_paginated_response(uri, action = :get)
118
120
  response = get_response(uri, action)
119
121
  body = response.json_body
120
122
  loop do
@@ -131,7 +133,7 @@ module Git
131
133
 
132
134
  private_class_method :get_paginated_response
133
135
 
134
- def self.get_json uri, action = :get
136
+ def self.get_json(uri, action = :get)
135
137
  get_response(uri, action).json_body
136
138
  end
137
139
 
@@ -141,7 +143,7 @@ module Git
141
143
  SEMAPHORE_API_HOST = 'semaphoreci.com'.freeze
142
144
  SEMAPHORE_API_URI = '/api/v1/'.freeze
143
145
 
144
- def self.request_uri auth_token, options = {}
146
+ def self.request_uri(auth_token, options = {})
145
147
  page = options.delete(:page) # API pagination
146
148
  options[:host] ||= SEMAPHORE_API_HOST
147
149
  options[:path].prepend SEMAPHORE_API_URI
@@ -3,38 +3,38 @@ module Git
3
3
  class API
4
4
  class Cache
5
5
 
6
- def self.projects auth_token
7
- @projects ||= Git::Semaphore.from_json_cache(projects_cache) do
6
+ def self.projects(refresh, auth_token)
7
+ @projects ||= Git::Semaphore.from_json_cache(projects_cache, refresh) do
8
8
  API::Enrich.projects auth_token
9
9
  end
10
10
  end
11
11
 
12
- def self.branches project_hash_id, auth_token
13
- @branches ||= Git::Semaphore.from_json_cache(branches_cache(project_hash_id)) do
12
+ def self.branches(project_hash_id, refresh, auth_token)
13
+ @branches ||= Git::Semaphore.from_json_cache(branches_cache(project_hash_id), refresh) do
14
14
  API.branches project_hash_id, auth_token
15
15
  end
16
16
  end
17
17
 
18
- def self.status project_hash_id, branch_id, auth_token
19
- @status ||= Git::Semaphore.from_json_cache(status_cache(project_hash_id, branch_id)) do
18
+ def self.status(project_hash_id, branch_id, refresh, auth_token)
19
+ @status ||= Git::Semaphore.from_json_cache(status_cache(project_hash_id, branch_id), refresh) do
20
20
  API.status project_hash_id, branch_id, auth_token
21
21
  end
22
22
  end
23
23
 
24
- def self.history project_hash_id, branch_id, auth_token
25
- @history ||= Git::Semaphore.from_json_cache(history_cache(project_hash_id, branch_id)) do
24
+ def self.history(project_hash_id, branch_id, refresh, auth_token)
25
+ @history ||= Git::Semaphore.from_json_cache(history_cache(project_hash_id, branch_id), refresh) do
26
26
  API::Enrich.history project_hash_id, branch_id, auth_token
27
27
  end
28
28
  end
29
29
 
30
- def self.information project_hash_id, branch_id, build_number, auth_token
31
- @information ||= Git::Semaphore.from_json_cache(information_cache(project_hash_id, branch_id, build_number)) do
30
+ def self.information(project_hash_id, branch_id, build_number, refresh, auth_token)
31
+ @information ||= Git::Semaphore.from_json_cache(information_cache(project_hash_id, branch_id, build_number), refresh) do
32
32
  API.information project_hash_id, branch_id, build_number, auth_token
33
33
  end
34
34
  end
35
35
 
36
- def self.log project_hash_id, branch_id, build_number, auth_token
37
- @log ||= Git::Semaphore.from_json_cache(log_cache(project_hash_id, branch_id, build_number)) do
36
+ def self.log(project_hash_id, branch_id, build_number, refresh, auth_token)
37
+ @log ||= Git::Semaphore.from_json_cache(log_cache(project_hash_id, branch_id, build_number), refresh) do
38
38
  API.log project_hash_id, branch_id, build_number, auth_token
39
39
  end
40
40
  end
@@ -47,31 +47,31 @@ module Git
47
47
 
48
48
  private_class_method :projects_cache
49
49
 
50
- def self.branches_cache project_hash_id
50
+ def self.branches_cache(project_hash_id)
51
51
  File.join(Git::Semaphore.cache_dir_for(project_hash_id), 'branches.json')
52
52
  end
53
53
 
54
54
  private_class_method :branches_cache
55
55
 
56
- def self.status_cache project_hash_id, branch_id
56
+ def self.status_cache(project_hash_id, branch_id)
57
57
  File.join(Git::Semaphore.cache_dir_for(project_hash_id), "#{branch_id}_status.json")
58
58
  end
59
59
 
60
60
  private_class_method :status_cache
61
61
 
62
- def self.history_cache project_hash_id, branch_id
62
+ def self.history_cache(project_hash_id, branch_id)
63
63
  File.join(Git::Semaphore.cache_dir_for(project_hash_id), "#{branch_id}_history.json")
64
64
  end
65
65
 
66
66
  private_class_method :history_cache
67
67
 
68
- def self.information_cache project_hash_id, branch_id, build_number
68
+ def self.information_cache(project_hash_id, branch_id, build_number)
69
69
  File.join(Git::Semaphore.cache_dir_for(project_hash_id), "#{branch_id}_#{build_number}_information.json")
70
70
  end
71
71
 
72
72
  private_class_method :information_cache
73
73
 
74
- def self.log_cache project_hash_id, branch_id, build_number
74
+ def self.log_cache(project_hash_id, branch_id, build_number)
75
75
  File.join(Git::Semaphore.cache_dir_for(project_hash_id), "#{branch_id}_#{build_number}_log.json")
76
76
  end
77
77
 
@@ -3,7 +3,7 @@ module Git
3
3
  class API
4
4
  class Enrich
5
5
 
6
- def self.projects auth_token
6
+ def self.projects(auth_token)
7
7
  API.projects(auth_token).tap do |results|
8
8
  results.each do |project|
9
9
  # full repository name on github.com: 'pvdb/git-semaphore'
@@ -14,21 +14,21 @@ module Git
14
14
  end
15
15
  end
16
16
 
17
- def self.history project_hash_id, branch_id, auth_token
17
+ def self.history(project_hash_id, branch_id, auth_token)
18
18
  API.history(project_hash_id, branch_id, auth_token).tap do |results|
19
19
  results['builds'].each do |build|
20
20
  # build['result'] = "passed", "failed", "stopped" or "pending"
21
- next unless started_at = build['started_at']
22
- next unless finished_at = build['finished_at']
23
- started_at = DateTime.parse(started_at).to_time
24
- finished_at = DateTime.parse(finished_at).to_time
21
+ next unless (started_at = build['started_at'])
22
+ next unless (finished_at = build['finished_at'])
23
+ started_at = Time.parse(started_at)
24
+ finished_at = Time.parse(finished_at)
25
25
  build['date'] = {
26
- :started_at => started_at.to_date,
27
- :finished_at => finished_at.to_date,
26
+ started_at: started_at.to_date,
27
+ finished_at: finished_at.to_date,
28
28
  }
29
29
  build['duration'] = {
30
- :seconds => (finished_at - started_at).to_i,
31
- :minutes => "%0.2f" % ((finished_at - started_at) / 60),
30
+ seconds: (finished_at - started_at).to_i,
31
+ minutes: format('%0.2f', (finished_at - started_at) / 60).to_f,
32
32
  }
33
33
  end
34
34
  end
@@ -0,0 +1,13 @@
1
+ module Git
2
+ module Semaphore
3
+ PIM = <<~"PIM".freeze
4
+
5
+ The only required setting for \033[1mgit semaphore\33[0m is:
6
+
7
+ \tgit config --global --add \033[1msemaphore.authtoken\033[0m <your_semaphore_auth_token>
8
+
9
+ Thanks for using \033[1mgit semaphore\033[0m ... the ultimate Semaphore utility for git!
10
+
11
+ PIM
12
+ end
13
+ end
@@ -1,176 +1,189 @@
1
- class Git::Semaphore::Project
2
-
3
- def self.env_overrides
4
- ENV.to_h.select { |key, _| key.start_with? 'SEMAPHORE_' }
5
- end
6
-
7
- def self.from_repo git_repo
8
- self.from_config({
9
- 'SEMAPHORE_PROJECT_NAME' => git_repo.full_name,
10
- 'SEMAPHORE_BRANCH_NAME' => git_repo.head.name.split('/').last,
11
- 'SEMAPHORE_COMMIT_SHA' => git_repo.head.target.oid,
12
- 'SEMAPHORE_BUILD_NUMBER' => nil
13
- }.merge(env_overrides))
14
- end
15
-
16
- def self.from_config config
17
- self.new(
18
- config['SEMAPHORE_PROJECT_NAME'],
19
- config['SEMAPHORE_BRANCH_NAME'],
20
- {
21
- commit_sha: config['SEMAPHORE_COMMIT_SHA'],
22
- build_number: config['SEMAPHORE_BUILD_NUMBER'],
23
- }
24
- )
25
- end
26
-
27
- def initialize full_name, branch_name = nil, options = {}
28
- @auth_token = Git::Semaphore.auth_token
29
- @full_name = full_name
30
- @owner, @name = full_name.split('/')
31
- @branch_name = branch_name || 'master'
32
- @commit_sha = options[:commit_sha]
33
- @build_number = options[:build_number]
34
- end
35
-
36
- def settings
37
- {
38
- auth_token: @auth_token,
39
- project_name: @full_name,
40
- branch_name: @branch_name,
41
- commit_sha: @commit_sha,
42
- build_number: @build_number,
43
- }
44
- end
45
-
46
- def internals
47
- settings.merge({
48
- project: {
49
- owner: @owner,
50
- name: @name,
51
- full_name: @full_name,
52
- hash_id: project_hash_id,
53
- url: project_url,
54
- },
55
- branch: {
56
- name: @branch_name,
57
- id: branch_id,
58
- url: branch_url,
59
- },
60
- build: {
61
- number: build_number,
62
- result: build_result,
63
- url: build_url,
64
- },
65
- })
66
- end
67
-
68
- #
69
- # build-related queries: default to latest one...
70
- #
71
-
72
- def build_number
73
- @build_number ||= history['builds'].first['build_number'].to_s
74
- end
75
-
76
- def build_result
77
- @build_result ||= history['builds'].first['result']
78
- end
79
-
80
- #
81
- # direct links to semaphore.ci
82
- #
83
-
84
- def project_url
85
- project_hash['html_url']
86
- end
87
-
88
- def branch_url
89
- branch_hash = project_hash['branches'].find { |hash|
90
- hash['branch_name'] == @branch_name
91
- }
92
- branch_hash['branch_url']
93
- end
94
-
95
- def build_url
96
- build_hash = history['builds'].find { |hash|
97
- hash['build_number'].to_s == @build_number
98
- }
99
- build_hash['build_url']
100
- end
101
-
102
- #
103
- # API related queries
104
- #
105
-
106
- def self.all
107
- Git::Semaphore::API::Cache.projects(Git::Semaphore.auth_token)
108
- end
109
-
110
- class << self
111
- alias_method :projects, :all
112
- end
113
-
114
- def branches
115
- Git::Semaphore::API::Cache.branches(project_hash_id, @auth_token)
116
- end
117
-
118
- def status
119
- Git::Semaphore::API::Cache.status(project_hash_id, branch_id, @auth_token)
120
- end
121
-
122
- def history
123
- Git::Semaphore::API::Cache.history(project_hash_id, branch_id, @auth_token)
124
- end
125
-
126
- def information
127
- Git::Semaphore::API::Cache.information(project_hash_id, branch_id, build_number, @auth_token,)
1
+ module Git
2
+ module Semaphore
3
+ class Project
4
+
5
+ def self.env_overrides
6
+ ENV.to_h.select { |key, _| key.start_with? 'SEMAPHORE_' }
7
+ end
8
+
9
+ def self.from_repo(git_repo)
10
+ from_config({
11
+ 'SEMAPHORE_PROJECT_NAME' => git_repo.full_name,
12
+ 'SEMAPHORE_BRANCH_NAME' => git_repo.head.name.split('/').last,
13
+ 'SEMAPHORE_COMMIT_SHA' => git_repo.head.target.oid,
14
+ 'SEMAPHORE_BUILD_NUMBER' => nil
15
+ }.merge(env_overrides))
16
+ end
17
+
18
+ def self.from_config(config)
19
+ new(
20
+ config['SEMAPHORE_PROJECT_NAME'],
21
+ config['SEMAPHORE_BRANCH_NAME'],
22
+ commit_sha: config['SEMAPHORE_COMMIT_SHA'],
23
+ build_number: config['SEMAPHORE_BUILD_NUMBER'],
24
+ )
25
+ end
26
+
27
+ attr_accessor :owner, :name, :full_name
28
+
29
+ def initialize(full_name, branch_name = nil, options = {})
30
+ @auth_token = Git::Semaphore.auth_token
31
+ @full_name = full_name
32
+ @owner, @name = full_name&.split('/')
33
+ @branch_name = branch_name || 'master'
34
+ @commit_sha = options[:commit_sha]
35
+ @build_number = options[:build_number]
36
+ end
37
+
38
+ def exist?
39
+ !project_hash.nil?
40
+ end
41
+
42
+ def settings
43
+ {
44
+ auth_token: @auth_token,
45
+ project_name: @full_name,
46
+ branch_name: @branch_name,
47
+ commit_sha: @commit_sha,
48
+ build_number: @build_number,
49
+ }
50
+ end
51
+
52
+ def internals
53
+ settings.merge(
54
+ project: {
55
+ owner: @owner,
56
+ name: @name,
57
+ full_name: @full_name,
58
+ hash_id: project_hash_id,
59
+ url: project_url,
60
+ },
61
+ branch: {
62
+ name: @branch_name,
63
+ id: branch_id,
64
+ url: branch_url,
65
+ },
66
+ build: {
67
+ number: build_number,
68
+ result: build_result,
69
+ url: build_url,
70
+ },
71
+ )
72
+ end
73
+
74
+ #
75
+ # build-related queries: default to latest one...
76
+ #
77
+
78
+ def build_number
79
+ @build_number ||= history['builds'].first['build_number'].to_s
80
+ end
81
+
82
+ def build_result
83
+ @build_result ||= history['builds'].first['result']
84
+ end
85
+
86
+ #
87
+ # direct links to semaphore.ci
88
+ #
89
+
90
+ def project_url
91
+ project_hash['html_url']
92
+ end
93
+
94
+ def branch_url
95
+ branch_hash = project_hash['branches'].find { |hash|
96
+ hash['branch_name'] == @branch_name
97
+ }
98
+ branch_hash['branch_url']
99
+ end
100
+
101
+ def build_url
102
+ build_hash = history['builds'].find { |hash|
103
+ hash['build_number'].to_s == @build_number
104
+ }
105
+ build_hash['build_url']
106
+ end
107
+
108
+ #
109
+ # API related queries
110
+ #
111
+
112
+ def self.all(refresh = false)
113
+ Git::Semaphore::API::Cache.projects(refresh, Git::Semaphore.auth_token)
114
+ end
115
+
116
+ class << self
117
+ alias_method :projects, :all
118
+ end
119
+
120
+ def branches(refresh = false)
121
+ Git::Semaphore::API::Cache.branches(project_hash_id, refresh, @auth_token)
122
+ end
123
+
124
+ def status(refresh = false)
125
+ Git::Semaphore::API::Cache.status(project_hash_id, branch_id, refresh, @auth_token)
126
+ end
127
+
128
+ def history(refresh = false)
129
+ Git::Semaphore::API::Cache.history(project_hash_id, branch_id, refresh, @auth_token)
130
+ end
131
+
132
+ def information(refresh = false)
133
+ Git::Semaphore::API::Cache.information(project_hash_id, branch_id, build_number, refresh, @auth_token)
134
+ end
135
+
136
+ def log(refresh = false)
137
+ Git::Semaphore::API::Cache.log(project_hash_id, branch_id, build_number, refresh, @auth_token)
138
+ end
139
+
140
+ def rebuild
141
+ Git::Semaphore::API.rebuild(project_hash_id, branch_id, @auth_token)
142
+ end
143
+
144
+ def browse
145
+ `open #{branch_url}`
146
+ { url: branch_url }
147
+ end
148
+
149
+ private
150
+
151
+ def project_hash_for(owner, name)
152
+ self.class.projects.find { |project_hash|
153
+ project_hash['owner'] == owner && project_hash['name'] == name
154
+ }
155
+ end
156
+
157
+ def project_hash
158
+ project_hash_for(@owner, @name)
159
+ end
160
+
161
+ def project_hash_id_for(owner, name)
162
+ project_hash_for(owner, name)['hash_id']
163
+ end
164
+
165
+ def project_hash_id
166
+ project_hash_id_for(@owner, @name)
167
+ end
168
+
169
+ def branch_hash_for(branch_name)
170
+ branches.find { |branch_hash|
171
+ branch_hash['name'] == branch_name
172
+ }
173
+ end
174
+
175
+ def branch_hash
176
+ branch_hash_for(@branch_name)
177
+ end
178
+
179
+ def branch_id_for(branch_name)
180
+ branch_hash_for(branch_name)['id'].to_s
181
+ end
182
+
183
+ def branch_id
184
+ branch_id_for(@branch_name)
185
+ end
186
+
187
+ end
128
188
  end
129
-
130
- def log
131
- Git::Semaphore::API::Cache.log(project_hash_id, branch_id, build_number, @auth_token,)
132
- end
133
-
134
- def rebuild
135
- Git::Semaphore::API.rebuild(project_hash_id, branch_id, @auth_token)
136
- end
137
-
138
- private
139
-
140
- def project_hash_for owner, name
141
- self.class.projects.find { |project_hash|
142
- project_hash['owner'] == owner && project_hash['name'] == name
143
- }
144
- end
145
-
146
- def project_hash
147
- project_hash_for(@owner, @name)
148
- end
149
-
150
- def project_hash_id_for owner, name
151
- project_hash_for(owner, name)['hash_id']
152
- end
153
-
154
- def project_hash_id
155
- project_hash_id_for(@owner, @name)
156
- end
157
-
158
- def branch_hash_for branch_name
159
- branches.find { |branch_hash|
160
- branch_hash['name'] == branch_name
161
- }
162
- end
163
-
164
- def branch_hash
165
- branch_hash_for(@branch_name)
166
- end
167
-
168
- def branch_id_for branch_name
169
- branch_hash_for(branch_name)['id'].to_s
170
- end
171
-
172
- def branch_id
173
- branch_id_for(@branch_name)
174
- end
175
-
176
189
  end