Class: XZGit::Command

Inherits:
CLAide::Command
  • Object
show all
Defined in:
lib/mrbin/command.rb

Direct Known Subclasses

XZDevGit, XZInteCommit, XZMr, XZUpVersion

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Command

Returns a new instance of Command.



20
21
22
# File 'lib/mrbin/command.rb', line 20

def initialize(argv)
    super
end

Class Method Details

.read_private_tokenObject



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/mrbin/command.rb', line 24

def self.read_private_token()
    if !ENV['GITAPITOKEN']
        puts "not found gitlab private token"
        exit(1)
    end
    if ENV['GITAPITOKEN'].empty?
        puts "gitlab private token is empty"
        exit(1)
    end
    XZGit.settoken(ENV['GITAPITOKEN'])
end

.read_remote_projectObject



36
37
38
39
40
41
42
# File 'lib/mrbin/command.rb', line 36

def self.read_remote_project()
    remote = `git config --get remote.origin.url`
    projecturl = remote.split(':')[1].split('.')[0]
    projecturl = projecturl.gsub("/","%2F")
    XZGit.setproject(projecturl)
    projecturl
end

.run(argv) ⇒ Object



13
14
15
16
17
18
# File 'lib/mrbin/command.rb', line 13

def self.run(argv)
    read_private_token()
    verify_git_repo()
    read_remote_project()
    super(argv)
end

.verify_git_repoObject



44
45
46
47
48
49
50
51
# File 'lib/mrbin/command.rb', line 44

def self.verify_git_repo()
    currentpath = Dir.pwd
    gitpath = "#{currentpath}/.git"
    if !File.directory?(gitpath)
        puts "can not found .git ,please check your path"
        exit(1)
    end
end