Module: GGSM::Token

Included in:
MR
Defined in:
lib/ggsm/mr/token.rb

Instance Method Summary collapse

Instance Method Details

#check_tokenObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/ggsm/mr/token.rb', line 3

def check_token
  ggsm_path = '.git/ggsm'
  unless File.exist?(ggsm_path)
    Dir.mkdir(ggsm_path)
  end

  config_path = "#{ggsm_path}/TOKEN"

  if !File.exist?(config_path) || '' == IO.read(config_path).strip || IO.readlines(config_path)[0].strip == ''
    file = File.new(config_path, 'w')
    file << "\n# 请输入GitLab private-token"
    file.close
    return false
  end

  return true
end