module Atlassian::Stash::Git

Public Instance Methods

create_git_alias() click to toggle source
# File lib/atlassian/stash/git.rb, line 31
def create_git_alias
  %x(git config --global alias.create-pull-request "\!sh -c 'stash pull-request \\$0'")
end
ensure_within_git!() { || ... } click to toggle source
# File lib/atlassian/stash/git.rb, line 23
def ensure_within_git!
  if is_in_git_repository?
    yield
  else
    raise "fatal: Not a git repository"
  end
end
get_current_branch() click to toggle source
# File lib/atlassian/stash/git.rb, line 6
def get_current_branch
  %x(git symbolic-ref HEAD)[/refs\/heads\/(.*)/, 1]
end
get_remote_url(remote = 'origin') click to toggle source
# File lib/atlassian/stash/git.rb, line 18
def get_remote_url(remote = 'origin')
  origin = get_remotes.split("\n").collect { |r| r.strip }.grep(/^#{remote}.*\(push\)$/).first
  URI.extract(origin).first
end
get_remotes() click to toggle source
# File lib/atlassian/stash/git.rb, line 14
def get_remotes
  %x(git remote -v)
end
is_in_git_repository?() click to toggle source
# File lib/atlassian/stash/git.rb, line 10
def is_in_git_repository?
  system('git rev-parse')
end