Method: GitlabApi::ApiClient#project_id

Defined in:
lib/git/gitlab/apiclient.rb

#project_idObject



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/git/gitlab/apiclient.rb', line 44

def project_id
  pid = if @repository.config.keys.include? "gitlab.projectid"
      @repository.config["gitlab.projectid"].to_i
    else
      @repository.config["gitlab.project"]
    end

  if pid == nil
    raise "Please set 'git config gitlab.projectid ${Gitlab Project id}' of git config gitlab.project ${NAMESPACE/PROJECT}"
  end

  begin
    @client.project( URI.encode_www_form_component(pid.to_s)).id
  rescue Gitlab::Error::NotFound => e
    raise GitlabApi::Error::ProjectIdNotFound, "Can not find #{pid} Project."
  end

end