Class: Commit

Inherits:
Array show all
Defined in:
lib/commands/commit.rb

Overview

require_relative(‘internet.rb’)

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Array

#add, #execute, #to_html

Class Method Details

.reset_commit_messageObject



36
37
38
# File 'lib/commands/commit.rb', line 36

def self.reset_commit_message
	File.open('commit.message','w'){|f|f.write('')}
end

Instance Method Details

#updateObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/commands/commit.rb', line 4

def update
	if(File.exists?('.git') && `git config --list`.include?('user.name='))
		if(!`git status`.include?('nothing to commit') &&
		   !`git status`.include?('untracked files present'))
		  if(File.exists?('commit.message') && File.read('commit.message').gsub(/\s+/,"").length >0)
		  	add "git commit -a -v -m \"#{File.read('commit.message')}\""
		  else
		    add "git commit -m'all'"
		  end
		  #add "<%FileUtils.rm('commit.message')%>" if File.exists?('commit.message')
		  add "<%File.open('commit.message','w'){|f|f.write('')}%>"
	    end 		
	end
	if(File.exists?('.svn'))
		message=""
		message=IO.read('commit.message').strip if File.exists?('commit.message')
		if(!File.exists?('commit.message') || message.length==0)
			if(defined?(REQUIRE_COMMIT_MESSAGE))
				puts "commit.message required to perform commit"
				Commit.reset_commit_message
				raise "commit.message required to perform commit"
			else
				add 'svn commit -m"commit all"'
			end
		else
			add 'svn commit --file commit.message'
			add "<%Commit.reset_commit_message%>"
			#add "<%FileUtils.rm('commit.message')%>" if File.exists?('commit.message')
		end
	end
end