Sha256: 7a78095762f233bcd04ce17ac8f842048d33120642643f8339bfbedb74bbed4d

Contents?: true

Size: 909 Bytes

Versions: 22

Compression:

Stored size: 909 Bytes

Contents

class Terraspace::Cloud::Vcs::LocalGit
  class Base
    extend Memoist

    attr_reader :git_url
    def initialize(vars, git_url)
      @vars, @git_url = vars, git_url
    end

    def vars
      {
        commit_url: commit_url,  # implemented by subclass
        branch_url: branch_url,  # implemented by subclass
        # pr_url handled when PR_NUMBER set by user outside of ci env. ci plugin pr_url takes higher precedence though
        pr_number: pr_number,
        pr_url: pr_url,
      }
    end

    def pr_number
      ENV['TS_VCS_PR_NUMBER'] || ENV['PR_NUMBER'] || ENV['MR_NUMBER']
    end

    class << self
      def vars_methods(*names)
        names.each do |name|
          vars_method(name)
        end
      end

      def vars_method(name)
        define_method name do
          @vars[name]
        end
      end
    end

    vars_methods :host, :full_repo, :sha, :branch_name
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

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