Class: Commit

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

Instance Attribute Summary

Attributes inherited from Array

#env

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Array

#add, #add_passive, #add_quiet, #execute, #has_command?, #initialize, #log_debug_info, #to_html

Constructor Details

This class inherits a constructor from Array

Class Method Details

.reset_commit_messageObject


47
48
49
# File 'lib/tasks/commit.rb', line 47

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

Instance Method Details

#updateObject


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/tasks/commit.rb', line 11

def update
  message = ""
  message = IO.read("commit.message").strip if File.exist?("commit.message")

  if File.exist?(".git") && `git config --list`.include?("user.name=") && Git.user_email.length.positive? && (!`git status`.include?("nothing to commit") &&
                                                                                                              !`git status`.include?("untracked files present") &&
                                                                                                              !`git status`.include?("no changes add to commit"))
    if message.length.zero?
      if defined?(REQUIRE_COMMIT_MESSAGE)
        Commit.reset_commit_message
        raise "commit.message required to perform commit"
      else
        add_passive "git commit -m'all'"
      end
    else
      add_quiet "git commit -a -v --file commit.message"
      add_quiet "<%Commit.reset_commit_message%>"
    end
  end
  if File.exist?(".svn")
    if message.length.zero?
      if defined?(REQUIRE_COMMIT_MESSAGE)
        Commit.reset_commit_message
        raise "commit.message required to perform commit"
      else
        add_quiet 'svn commit -m"commit all"'
      end
    else
      add_quiet "svn commit --file commit.message"
      add_quiet "<%Commit.reset_commit_message%>"
    end
  end

  log_debug_info("Commit") if defined?(DEBUG)
end