Sha256: 65d727aa954ca86d44632dbacd8978a01ea9c1cb241ccec1a62d0defc6c61782

Contents?: true

Size: 1.39 KB

Versions: 13

Compression:

Stored size: 1.39 KB

Contents

class Git
	def self.branch directory=''
        directory=Dir.pwd if directory.length == 0
        Dir.chdir(directory) do
    		begin
    		  `git branch`.scan(/\* ([.\w-]+)/)[0][0] if(File.exists?('.git'))
    	    rescue
    	    	''
    	    end
        end
    end

    def self.remote_origin directory=''
    	url=''
    	directory=Dir.pwd if directory.length == 0
    	Dir.chdir(directory) do
    		begin
    			url=`git remote show origin`.scan(/Fetch URL: ([\.\-:\/\w\d]+)/)[0][0] if(File.exists?('.git'))
    		rescue
    			url=''
    		end
    	end
    	url
    end

    def self.has_changes? directory=''
        directory=Dir.pwd if directory.length==0
        Dir.chdir(directory) do
            if(File.exists?('.git'))
                return true if `git status`.include?('modified:')
            end
        end
        false
    end

    def self.init directory=''
        directory=Dir.pwd if directory.length==0
        FileUtils.mkpath directory if !File.exists?(directory)
        if(!File.exists?("#{directory}/.git"))
            Dir.chdir(directory) do
               `git init`
               File.open('.gitignore','w'){|f|
                   f.puts '### Mac ###'
                   f.puts '*.DS_Store'
               }
               `git add .gitignore`
               `git commit -m'added .gitignore'`
            end
        end
    end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
dev-2.0.59 lib/dev_git.rb
dev-2.0.58 lib/dev_git.rb
dev-2.0.57 lib/dev_git.rb
dev-2.0.56 lib/dev_git.rb
dev-2.0.55 lib/dev_git.rb
dev-2.0.54 lib/dev_git.rb
dev-2.0.53 lib/dev_git.rb
dev-2.0.52 lib/dev_git.rb
dev-2.0.51 lib/dev_git.rb
dev-2.0.50 lib/dev_git.rb
dev-2.0.49 lib/dev_git.rb
dev-2.0.48 lib/dev_git.rb
dev-2.0.47 lib/dev_git.rb