Class: AccuHook::Accurev::Commit

Inherits:
Object
  • Object
show all
Defined in:
lib/accuhook/commit.rb

Instance Method Summary collapse

Constructor Details

#initialize(repository, commit_object) ⇒ Commit

Returns a new instance of Commit.



9
10
11
12
13
# File 'lib/accuhook/commit.rb', line 9

def initialize(repository, commit_object)
  @command = AccuHook::Accurev::Command.new
  puts commit_object.inspect
  commit!(commit_object, repository)
end

Instance Method Details

#commit!(commit_object, repository) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/accuhook/commit.rb', line 15

def commit!(commit_object, repository)
  commit_object.each do |commit|
    commit.show.each do |diff|
      case
      when diff.new_file # Accurev add, then keep
        @command.add("#{repository.working_dir}/#{diff.a_path}")
        @command.keep("#{repository.working_dir}/#{diff.a_path}", commit.message)
      when diff.deleted_file # accurev defunct
        @command.defunct("#{repository.working_dir}/#{diff.a_path}", commit.message)
      when diff.renamed_file # accurev defunct a_path, then add b_path (then keep)
        puts "Renamed file detected"
        @command.defunct("#{repository.working_dir}/#{diff.a_path}", commit.message)
        @command.add("#{repository.working_dir}/#{diff.b_path}")
        @command.keep("#{repository.working_dir}/#{diff.b_path}", commit.message)
      else # Accurev regular keep
        puts "Modified file detected"
        @command.keep("#{repository.working_dir}/#{diff.a_path}", commit.message)
      end
    end
  end
end