Class: Instapusher2::Git

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

Instance Method Summary collapse

Instance Method Details

#current_branchObject



3
4
5
6
7
8
9
10
# File 'lib/instapusher2/git.rb', line 3

def current_branch
  result = %x{git branch}.split("\n")
  if result.empty?
    raise "It seems your app is not a git repo"
  else
    result.select { |b| b =~ /^\*/ }.first.split(" ").last.strip
  end
end

#current_userObject



12
13
14
# File 'lib/instapusher2/git.rb', line 12

def current_user
  `git config user.name`.chop!
end

#project_nameObject



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

def project_name
  result = `git config remote.origin.url`.chop!.scan(/\/([^\/]+)?$/).flatten.first
  result.sub!(/\.git$/, '') if result
  result ||= File.basename(Dir.getwd)
  result
end

#repo_ownerObject



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

def repo_owner
  string = `git remote -v | grep fetch | grep origin`
  regex = /.*:(.*)\/.*/
  match_data = string.match(regex)
  match_data.to_a.last
end