Sha256: 65b64c7660237fe874cf1a4883d492e5ff147332af5ab21fff89c10943429961

Contents?: true

Size: 758 Bytes

Versions: 4

Compression:

Stored size: 758 Bytes

Contents


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

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

      def get_remotes
        %x(git remote -v)
      end

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

      def ensure_within_git!
        if is_in_git_repository?
          yield
        else
          raise "fatal: Not a git repository"
        end
      end

      def create_git_alias
        %x(git config --global alias.create-pull-request "\!sh -c 'stash pull-request \\$0'")
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
atlassian-stash-0.2.0 lib/atlassian/stash/git.rb
atlassian-stash-0.1.9 lib/atlassian/stash/git.rb
atlassian-stash-0.1.8 lib/atlassian/stash/git.rb
atlassian-stash-0.1.6 lib/atlassian/stash/git.rb