Class: Terraspace::Cloud::Vcs::LocalGit::Azure

Inherits:
Base
  • Object
show all
Defined in:
lib/terraspace/cloud/vcs/local_git/azure.rb

Instance Attribute Summary

Attributes inherited from Base

#git_url

Instance Method Summary collapse

Methods inherited from Base

#initialize, #pr_number, vars_method, vars_methods

Constructor Details

This class inherits a constructor from Terraspace::Cloud::Vcs::LocalGit::Base

Instance Method Details

#base_repo_urlObject



15
16
17
# File 'lib/terraspace/cloud/vcs/local_git/azure.rb', line 15

def base_repo_url
  "#{host}/#{org}/#{project}/_git/#{repo}"
end

#branch_urlObject



19
20
21
22
# File 'lib/terraspace/cloud/vcs/local_git/azure.rb', line 19

def branch_url
  # IE: https://dev.azure.com/tongueroo/infra-project/_git/infra-ci?version=GBmerge
  "#{base_repo_url}?verison=GB#{sha}" if sha
end

#commit_urlObject



10
11
12
13
# File 'lib/terraspace/cloud/vcs/local_git/azure.rb', line 10

def commit_url
  # IE: https://dev.azure.com/tongueroo/infra-project/_git/infra-ci/commit/aaa74f96d76053672ff1b91995c903605cd8a245
  "#{base_repo_url}/commits/#{sha}" if sha
end

#full_repoObject



52
53
54
55
# File 'lib/terraspace/cloud/vcs/local_git/azure.rb', line 52

def full_repo
  version, org, project, repo = url_info
  "#{org}/#{repo}"
end

#hostObject

override to remove ssh ssh.dev.azure.com => dev.azure.com



32
33
34
# File 'lib/terraspace/cloud/vcs/local_git/azure.rb', line 32

def host
  "https://dev.azure.com"
end

#orgObject



42
43
44
45
# File 'lib/terraspace/cloud/vcs/local_git/azure.rb', line 42

def org
  version, org, project, repo = url_info
  org
end

#pr_urlObject

Also computed in ci plugins which detects it from the ci env. Also handling here for case when user provides PR_NUMBER and GIT_REPO outside of normal CI env.



26
27
28
# File 'lib/terraspace/cloud/vcs/local_git/azure.rb', line 26

def pr_url
  "#{host}/#{full_repo}/pull-requests/#{pr_number}" if pr_number
end

#projectObject



57
58
59
60
# File 'lib/terraspace/cloud/vcs/local_git/azure.rb', line 57

def project
  version, org, project, repo = url_info
  project
end

#repoObject



47
48
49
50
# File 'lib/terraspace/cloud/vcs/local_git/azure.rb', line 47

def repo
  version, org, project, repo = url_info
  repo
end

#url_infoObject



36
37
38
39
40
# File 'lib/terraspace/cloud/vcs/local_git/azure.rb', line 36

def url_info
  uri = URI(git_url)
  # IE: v3/tongueroo/infra-project/infra-ci
  uri.path.sub(/^\//,'').split('/') # [version, org, project, repo]
end

#varsObject



3
4
5
6
7
8
# File 'lib/terraspace/cloud/vcs/local_git/azure.rb', line 3

def vars
  super.merge(
    host: host,
    full_repo: full_repo,
  )
end