Sha256: 95b969582d73a23137d9d6f957a51fcd7f0544a507f14b192c1baa059908bb68

Contents?: true

Size: 817 Bytes

Versions: 7

Compression:

Stored size: 817 Bytes

Contents

module Glman
  module Repos
    class GitRepo
      def remote_origin_ssh_url
        %x[git remote -v].split("\t").select{ |c| c.include?('(push)')}.first.gsub('(push)', '').gsub("\n", '').strip
      rescue
        nil
      end

      def repository_name
        remote_origin_ssh_url.split(':').last.gsub('.git','')
      rescue
        nil
      end

      def current_branch
        %x[git br].split("\n").select{ |c| c.include?('*')}.first.gsub('*','').strip
      rescue
        nil
      end

      def last_commit_message
        %x[git log -1].split("\n").select{|c| c.include?('Subject:')}.first.gsub('Subject:','').strip
      rescue
        nil
      end

      def push(origin, branch)
        cmd = "git push #{origin} #{branch}"
        %x[#{cmd}]
      rescue
        nil
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
glman-0.0.9 lib/glman/repos/git_repo.rb
glman-0.0.8 lib/glman/repos/git_repo.rb
glman-0.0.7 lib/glman/repos/git_repo.rb
glman-0.0.6 lib/glman/repos/git_repo.rb
glman-0.0.5 lib/glman/repos/git_repo.rb
glman-0.0.4 lib/glman/repos/git_repo.rb
glman-0.0.3 lib/glman/repos/git_repo.rb