Class: Jets::Git::Codebuild

Inherits:
Base
  • Object
show all
Defined in:
lib/jets/git/codebuild.rb

Instance Method Summary collapse

Methods inherited from Base

#base, #params, #user

Instance Method Details

#full_repoObject

ORG/REPO



36
37
38
39
40
# File 'lib/jets/git/codebuild.rb', line 36

def full_repo
  return unless repo_url
  uri = URI(repo_url)
  uri.path.sub(/^\//, "")
end

#git_branchObject



17
18
19
# File 'lib/jets/git/codebuild.rb', line 17

def git_branch
  ENV["CODEBUILD_SOURCE_VERSION"]
end

#git_shaObject



21
22
23
# File 'lib/jets/git/codebuild.rb', line 21

def git_sha
  ENV["CODEBUILD_RESOLVED_SOURCE_VERSION"]
end

#git_urlObject



25
26
27
# File 'lib/jets/git/codebuild.rb', line 25

def git_url
  "#{host}/#{full_repo}" if host && full_repo
end

#hostObject



29
30
31
32
33
# File 'lib/jets/git/codebuild.rb', line 29

def host
  return unless ENV["CODEBUILD_SOURCE_REPO_URL"]
  uri = URI(ENV["CODEBUILD_SOURCE_REPO_URL"]) # https://github.com/ORG/REPO
  "#{uri.scheme}://#{uri.host}"
end

#infoObject



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/jets/git/codebuild.rb', line 3

def info
  info = {
    git_system: "codebuild",
    git_branch: git_branch,
    git_sha: git_sha,
    git_dirty: false,
    git_url: git_url
    # git_message: nil,
    # git_version: nil,
  }
  info.delete_if { |k, v| v.nil? }
  info
end

#repo_urlObject



43
44
45
46
47
# File 'lib/jets/git/codebuild.rb', line 43

def repo_url
  return unless ENV["CODEBUILD_SOURCE_REPO_URL"]
  # https://github.com/ORG/REPO.git
  ENV["CODEBUILD_SOURCE_REPO_URL"].sub(".git", "")
end