Sha256: d7a84e630ad10b833dac67804859cef9fa3852d44144c936d4a74d64ba73d0d8

Contents?: true

Size: 2 KB

Versions: 2

Compression:

Stored size: 2 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:')
                return true if `git status`.include?('new file:')
            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 --bare`
               #File.open('.gitignore','w'){|f|
               #    f.puts '### Mac ###'
               #    f.puts '*.DS_Store'
               #}
               #{}`git add .gitignore`
               #{}`git commit -m'added .gitignore'`
            end
        end
    end

    def self.tag directory,version
        directory=Dir.pwd if directory.length == 0
        Dir.chdir(directory) do
            `git pull`
            tags=`git tag`
            if(!tags.include?(version))
                puts 'tagging branch'
                puts `git tag version -m'#{version}'`
                puts 'committing'
                puts `git commit -m'#{version}'`
                puts 'pushing'
                puts `git push --tags`
                puts `git push`
            end
        end
    end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dev-2.0.63 lib/dev_git.rb
dev-2.0.62 lib/dev_git.rb