Class: Jets::Git::Info

Inherits:
Object
  • Object
show all
Extended by:
Memoist
Defined in:
lib/jets/git/info.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Info

Not using options but trying to future proof initialize



5
6
7
# File 'lib/jets/git/info.rb', line 5

def initialize(options = {})
  @options = options
end

Instance Method Details

#paramsObject

Best effort to get git info



15
16
17
18
# File 'lib/jets/git/info.rb', line 15

def params
  return {} if ENV["JETS_GIT_DISABLED"]
  strategy_class.new.params
end

#strategy_classObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/jets/git/info.rb', line 20

def strategy_class
  return Saved if File.exist?(".jets/gitinfo.yml")

  env_map = {
    BITBUCKET_COMMIT: Bitbucket,
    CIRCLECI: Circleci,
    CODEBUILD_CI: Codebuild,
    GITHUB_ACTIONS: Github,
    GITLAB_CI: Gitlab,
    JETS_GIT_CUSTOM: Custom,
    SYSTEM_TEAMFOUNDATIONSERVERURI: Azure
  }
  found = env_map.find do |env_key, strategy_class|
    ENV[env_key.to_s]
  end
  found ? found[1] : Local
end

#userObject



9
10
11
# File 'lib/jets/git/info.rb', line 9

def user
  User.new
end