Class: Yadecli::Client::GitlabClient
- Inherits:
-
Object
- Object
- Yadecli::Client::GitlabClient
- Defined in:
- lib/yadecli/client/gitlab_client.rb
Overview
gitlab client
Instance Method Summary collapse
-
#get_branch_names(repository_name) ⇒ Object
get branch names from gitlab project given by name.
-
#get_default_branch(repository_name) ⇒ Object
get branch names from gitlab project given by name.
-
#initialize ⇒ GitlabClient
constructor
request yade token.
Constructor Details
#initialize ⇒ GitlabClient
request yade token
13 14 15 16 17 18 |
# File 'lib/yadecli/client/gitlab_client.rb', line 13 def initialize Gitlab.configure do |config| config.endpoint = Yade::Common::Config::ComposerConfig[:git_api_url] config.private_token = Yade::Common::Config::ComposerConfig[:git_token] end end |
Instance Method Details
#get_branch_names(repository_name) ⇒ Object
get branch names from gitlab project given by name
21 22 23 24 25 26 27 28 29 |
# File 'lib/yadecli/client/gitlab_client.rb', line 21 def get_branch_names(repository_name) projects = Gitlab.projects(search: repository_name) project = projects.select { |p| repository_name == p.name }.first branches = Gitlab.branches(project.id) branches.map { |b| b.name } end |
#get_default_branch(repository_name) ⇒ Object
get branch names from gitlab project given by name
32 33 34 35 36 37 38 |
# File 'lib/yadecli/client/gitlab_client.rb', line 32 def get_default_branch(repository_name) projects = Gitlab.projects(search: repository_name) project = projects.select { |p| repository_name == p.name }.first project.default_branch end |