Class: Shards::Repo

Inherits:
Object
  • Object
show all
Defined in:
lib/shards/repo.rb

Constant Summary collapse

@@times =
0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRepo

Returns a new instance of Repo.



10
11
12
13
14
# File 'lib/shards/repo.rb', line 10

def initialize
  @root=ENV['ENGINEERING_ROOT_PATH']
  @git=Git.open root
  clean if @@times<1
end

Instance Attribute Details

#gitObject

Returns the value of attribute git.



8
9
10
# File 'lib/shards/repo.rb', line 8

def git
  @git
end

#messageObject

Returns the value of attribute message.



8
9
10
# File 'lib/shards/repo.rb', line 8

def message
  @message
end

#rootObject

Returns the value of attribute root.



8
9
10
# File 'lib/shards/repo.rb', line 8

def root
  @root
end

Instance Method Details

#autocommitObject



28
29
30
31
32
33
# File 'lib/shards/repo.rb', line 28

def autocommit
  git.add all: true
  git.commit autocommit_message
  git.pull 'origin', live_branch
  git.push 'origin', live_branch
end

#autocommit_messageObject



35
36
37
# File 'lib/shards/repo.rb', line 35

def autocommit_message
  "[AUTOCOMMIT] #{message}"
end

#cleanObject



20
21
22
23
24
25
26
# File 'lib/shards/repo.rb', line 20

def clean
  @@times+=1
  git.reset_hard
  git.clean force: true, d: true
  git.branch(live_branch).checkout
  git.pull 'origin', live_branch
end

#clean_passwdObject



44
45
46
# File 'lib/shards/repo.rb', line 44

def clean_passwd
  git.diff.to_s.gsub( /password:\ \w+/, "password: *************")
end

#diffObject



39
40
41
42
# File 'lib/shards/repo.rb', line 39

def diff
  git.add all: true
  clean_passwd
end

#live_branchObject



16
17
18
# File 'lib/shards/repo.rb', line 16

def live_branch
  ENV['LIVE_BRANCH'] || 'v5'
end