Class: Svenbot::Commit

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

Overview

Representation of a commit message

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, user, path_prefix, message) ⇒ Commit

Create a new commit.



14
15
16
17
18
19
# File 'lib/svenbot/commit.rb', line 14

def initialize(id, user, path_prefix, message)
  @id = id
  @user = user
  @path_prefix = path_prefix
  @message = message
end

Instance Attribute Details

#idObject (readonly)

Identifier for this commit



5
6
7
# File 'lib/svenbot/commit.rb', line 5

def id
  @id
end

#messageObject (readonly)

Why was this commit made?



11
12
13
# File 'lib/svenbot/commit.rb', line 11

def message
  @message
end

#path_prefixObject (readonly)

What part of the repository did this affect?



9
10
11
# File 'lib/svenbot/commit.rb', line 9

def path_prefix
  @path_prefix
end

#userObject (readonly)

Who made this commit?



7
8
9
# File 'lib/svenbot/commit.rb', line 7

def user
  @user
end

Class Method Details

.from(repo, id) ⇒ Object

Populate a new commit object from a repository



22
23
24
25
26
27
28
# File 'lib/svenbot/commit.rb', line 22

def self.from(repo, id)
  user = `svnlook author '#{repo.dir}' -r '#{id}'`.chomp
  message = `svnlook log '#{repo.dir}' -r '#{id}'`.chomp
  paths = `svnlook changed '#{repo.dir}' -r '#{id}'`.split(/\n/)
  paths.collect! { |p| p.sub(/^..../, '').chomp }
  return Commit.new(id, user, pick_prefix(paths), message)
end