Module: Metaverse::Git

Included in:
Repo
Defined in:
lib/metaverse/git.rb

Instance Method Summary collapse

Instance Method Details

#branch(branch = '') ⇒ Object



30
31
32
33
# File 'lib/metaverse/git.rb', line 30

def branch branch = ''
  Dir.chdir(@path) do
  end
end

#checkout(branch) ⇒ Object



17
18
19
20
21
# File 'lib/metaverse/git.rb', line 17

def checkout branch
  Dir.chdir(@path) do
    puts `git checkout #{branch}`
  end
end

#countDiffBranches(branch1, branch2) ⇒ Object



65
66
67
68
69
# File 'lib/metaverse/git.rb', line 65

def countDiffBranches branch1, branch2
  Dir.chdir(@path) do
    `git rev-list --count #{branch1}..#{branch2}`
  end
end

#currentBranchObject



23
24
25
26
27
28
# File 'lib/metaverse/git.rb', line 23

def currentBranch
  Dir.chdir(@path) do
    branchName = `git rev-parse --abbrev-ref HEAD`;
    branchName.strip
  end
end

#dirty?Boolean

Returns:

  • (Boolean)


71
72
73
74
75
# File 'lib/metaverse/git.rb', line 71

def dirty?
  Dir.chdir(@path) do
    `git status --porcelain`.length != 0
  end
end

#fetch(remote) ⇒ Object



53
54
55
56
57
# File 'lib/metaverse/git.rb', line 53

def fetch remote
  Dir.chdir(@path) do
    puts `git fetch #{remote || @originRemote}`
  end
end

#load(path) ⇒ Object



6
7
8
9
10
11
# File 'lib/metaverse/git.rb', line 6

def load path
  if !File.directory? path + '/.git'
    raise "#{path} is not a git repo"
  end
  @path = path
end

#nameObject



13
14
15
# File 'lib/metaverse/git.rb', line 13

def name
  File.basename @path
end

#pull(remote) ⇒ Object



47
48
49
50
51
# File 'lib/metaverse/git.rb', line 47

def pull remote
  Dir.chdir(@path) do
    `git pull #{remote || @originRemote} #{currentBranch}:#{currentBranch}`
  end
end

#reset(branch) ⇒ Object



59
60
61
62
63
# File 'lib/metaverse/git.rb', line 59

def reset branch
  Dir.chdir(@path) do
    puts `git reset --hard #{branch}`
  end
end

#statusObject



35
36
37
38
39
# File 'lib/metaverse/git.rb', line 35

def status
  Dir.chdir(@path) do
    puts `git status`
  end
end

#tag(name) ⇒ Object



41
42
43
44
45
# File 'lib/metaverse/git.rb', line 41

def tag name
  Dir.chdir(@path) do
    puts `git tag #{name}`
  end
end