Module: StillActive::GitlabClient

Extended by:
GitlabClient
Included in:
GitlabClient
Defined in:
lib/still_active/gitlab_client.rb

Constant Summary collapse

BASE_URI =
URI("https://gitlab.com/")

Instance Method Summary collapse

Instance Method Details

#archived(owner:, name:) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/still_active/gitlab_client.rb', line 12

def archived(owner:, name:)
  return if owner.nil? || name.nil?

  path = "/api/v4/projects/#{encode_project(owner, name)}"
  body = HttpHelper.get_json(BASE_URI, path, headers: auth_headers)
  return if body.nil?

  body["archived"] == true
end

#last_commit_date(owner:, name:) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/still_active/gitlab_client.rb', line 22

def last_commit_date(owner:, name:)
  return if owner.nil? || name.nil?

  path = "/api/v4/projects/#{encode_project(owner, name)}/repository/commits"
  body = HttpHelper.get_json(BASE_URI, path, headers: auth_headers, params: { per_page: 1 })
  return if body.nil? || body.empty?

  date = body.first["committed_date"]
  return unless date

  begin
    Time.parse(date)
  rescue ArgumentError
    $stderr.puts("warning: could not parse commit date for #{owner}/#{name}: #{date.inspect}")
    nil
  end
end