Module: Prick::Git::Branch

Defined in:
lib/prick/local/git.rb

Class Method Summary collapse

Class Method Details

.checkout(branch) ⇒ Object



147
148
149
# File 'lib/prick/local/git.rb', line 147

def self.checkout(branch)
  Command.command "git checkout --quiet #{branch}"
end

.create(branch, id = nil, set_upstream: true) ⇒ Object



122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/prick/local/git.rb', line 122

def self.create(branch, id = nil, set_upstream: true)
  if set_upstream
    current = Git.branch.current
    Command.command %(
      git checkout --quiet -b #{branch} #{id}
      git push --quiet --set-upstream origin #{branch}
      git checkout --quiet #{current}
    )
  else
    Command.command "git branch #{branch} #{id}"
  end
end

.currentObject



143
144
145
# File 'lib/prick/local/git.rb', line 143

def self.current()
  Command.command("git branch --show-current").first
end

.drop(branch) ⇒ Object



135
136
137
# File 'lib/prick/local/git.rb', line 135

def self.drop(branch)
  Command.command "git branch -D #{branch}"
end

.exist?(branch) ⇒ Boolean

Returns:

  • (Boolean)


118
119
120
# File 'lib/prick/local/git.rb', line 118

def self.exist?(branch)
  Command.command? "git show-ref --verify --quiet refs/heads/#{branch}"
end

.listObject



139
140
141
# File 'lib/prick/local/git.rb', line 139

def self.list()
  Command.command "git for-each-ref --format='%(refname:short)' refs/heads/*"
end