Class: GitCommitNotifier::Executor

Inherits:
Object
  • Object
show all
Defined in:
lib/git_commit_notifier/executor.rb

Overview

binaries code

Class Method Summary collapse

Class Method Details

.run!(args) ⇒ nil

runs git commit notifier life



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
# File 'lib/git_commit_notifier/executor.rb', line 14

def self.run!(args)
  case args.length
  when 0
    GitCommitNotifier::CommitHook.show_error("You have to add a path to the config file for git-commit-notifier")
    puts "Usage:  git-commit-notifier config-script [oldrev newrev [ref]]"
  when 1
    if $stdin.eof?
      GitCommitNotifier::CommitHook.show_error("No data given on standard input")
      return
    end

    # Note that there may be multiple lines on stdin, such
    # as in the case of multiple tags being pushed
    $stdin.each_line do |line|
      oldrev, newrev, ref = line.strip.split
      GitCommitNotifier::CommitHook.run args.first, oldrev, newrev, ref
    end

  when 2
    GitCommitNotifier::CommitHook.run args.first, args.last, args.last, ""
  when 3
    GitCommitNotifier::CommitHook.run args.first, args[1], args.last, ""
  else
    GitCommitNotifier::CommitHook.run args.first, args[1], args[2], args[3]
  end
  nil
end