Sha256: e60334fa37ede13ba2774b1685d5e8f30f93cf551a8fbf64f3970968553c9aeb

Contents?: true

Size: 1.48 KB

Versions: 22

Compression:

Stored size: 1.48 KB

Contents

class Terraspace::Cloud::Vcs::LocalGit
  class Azure < Base
    def vars
      super.merge(
        host: host,
        full_repo: full_repo,
      )
    end

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

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

    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

    # 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.
    def pr_url
      "#{host}/#{full_repo}/pull-requests/#{pr_number}" if pr_number
    end

    # override to remove ssh
    # https://ssh.dev.azure.com => https://dev.azure.com
    def host
      "https://dev.azure.com"
    end

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

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

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

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

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

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
terraspace-2.2.17 lib/terraspace/cloud/vcs/local_git/azure.rb
terraspace-2.2.16 lib/terraspace/cloud/vcs/local_git/azure.rb
terraspace-2.2.15 lib/terraspace/cloud/vcs/local_git/azure.rb
terraspace-2.2.14 lib/terraspace/cloud/vcs/local_git/azure.rb
terraspace-2.2.13 lib/terraspace/cloud/vcs/local_git/azure.rb
terraspace-2.2.12 lib/terraspace/cloud/vcs/local_git/azure.rb
terraspace-2.2.11 lib/terraspace/cloud/vcs/local_git/azure.rb
terraspace-2.2.10 lib/terraspace/cloud/vcs/local_git/azure.rb
terraspace-2.2.9 lib/terraspace/cloud/vcs/local_git/azure.rb
terraspace-2.2.8 lib/terraspace/cloud/vcs/local_git/azure.rb
terraspace-2.2.7 lib/terraspace/cloud/vcs/local_git/azure.rb
terraspace-2.2.6 lib/terraspace/cloud/vcs/local_git/azure.rb
terraspace-2.2.5 lib/terraspace/cloud/vcs/local_git/azure.rb
terraspace-2.2.4 lib/terraspace/cloud/vcs/local_git/azure.rb
terraspace-2.2.3 lib/terraspace/cloud/vcs/local_git/azure.rb
terraspace-2.2.2 lib/terraspace/cloud/vcs/local_git/azure.rb
terraspace-2.2.1 lib/terraspace/cloud/vcs/local_git/azure.rb
terraspace-2.2.0 lib/terraspace/cloud/vcs/local_git/azure.rb
terraspace-2.1.7 lib/terraspace/cloud/vcs/local_git/azure.rb
terraspace-2.1.6 lib/terraspace/cloud/vcs/local_git/azure.rb