Module: Atlassian::Stash::Git

Defined in:
lib/atlassian/stash/git.rb

Instance Method Summary collapse

Instance Method Details

#create_git_aliasObject



31
32
33
# 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!Object



23
24
25
26
27
28
29
# 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_branchObject



6
7
8
# File 'lib/atlassian/stash/git.rb', line 6

def get_current_branch
  %x(git symbolic-ref HEAD)[/refs\/heads\/(.*)/, 1]
end

#get_remote_urlObject



18
19
20
21
# File 'lib/atlassian/stash/git.rb', line 18

def get_remote_url
  origin = get_remotes.split("\n").collect { |r| r.strip }.grep(/^origin.*\(push\)$/).first
  URI.extract(origin).first
end

#get_remotesObject



14
15
16
# File 'lib/atlassian/stash/git.rb', line 14

def get_remotes
  %x(git remote -v)
end

#is_in_git_repository?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/atlassian/stash/git.rb', line 10

def is_in_git_repository?
  system('git rev-parse')
end