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
# File 'lib/shards/repo.rb', line 28

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

#autocommit_messageObject



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

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

#diffObject



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

def diff
  git.add all: true
  git.diff
end

#live_branchObject



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

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