Class: Dockistrano::Git

Inherits:
Object
  • Object
show all
Defined in:
lib/dockistrano/git.rb

Class Method Summary collapse

Class Method Details

.branchObject



17
18
19
20
21
22
23
24
# File 'lib/dockistrano/git.rb', line 17

def self.branch
  if ENV['JANKY_BRANCH']
    ENV['JANKY_BRANCH'].gsub("/", "-")
  else
    branch = Cocaine::CommandLine.new("git rev-parse --abbrev-ref HEAD").run.strip
    branch.gsub("/", "-")
  end
end

.repository_nameObject



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/dockistrano/git.rb', line 5

def self.repository_name
  git_url = Cocaine::CommandLine.new("git config --get remote.origin.url").run.strip

  if git_url =~ /^[A-z0-9]+@[A-z0-9.:\-]+\/([A-z0-9\-_\.]+)(\.git)?$/
    $1.gsub(/\.git$/, "")
  elsif git_url =~ /^(git|https?):\/\/[a-z\-\.]+\/[a-z\-\.]+\/([A-z0-9.\-\_]+)$/
    $2.gsub(/\.git$/, "")
  else
    raise "Unknown git url '#{git_url}'"
  end
end