Sha256: 9ac3184121d9433cf2f659b3311d282be8b087cc5902e1ec143d5dde27d7f996

Contents?: true

Size: 780 Bytes

Versions: 2

Compression:

Stored size: 780 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(remote = 'origin')
        origin = get_remotes.split("\n").collect { |r| r.strip }.grep(/^#{remote}.*\(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

2 entries across 2 versions & 2 rubygems

Version Path
atlassian-stash-0.3.0 lib/atlassian/stash/git.rb
atlassian-stash-avisi-0.4.15 lib/atlassian/stash/git.rb