Class: Disloku::Git::ChangeSetProvider
Instance Attribute Summary
#repository
Instance Method Summary
collapse
#initialize
Instance Method Details
#getChangeSets(from = nil, to = nil) ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/disloku/git/ChangeSetProvider.rb', line 23
def getChangeSets(from = nil, to = nil)
if (from == nil)
from = "HEAD"
end
dirtyPaths = {}
status = SysCmd.new("git status --untracked-files=no --porcelain #{repository.root}").execute()
status.output.each_line() do |line|
match = /^(.)(.)\s+"([^"]+)"/.match(line) || /^(.)(.)\s+([^ \n\r]+)/.match(line)
dirtyPaths[match[3]] = true
end
result = ChangeSet.new(@repository.getHashOfRefspec(from), to || @repository.getHashOfRefspec("HEAD"))
if (to == nil)
diff = SysCmd.new("git diff --name-status --staged #{from} #{repository.root}").execute()
else
raise NotImplementedError.new()
end
Log.instance.scope([:default, :logfile]) do
diff.output.each_line() do |line|
match = /^(.)\s+(.*)$/.match(line)
dirty = dirtyPaths.has_key?(match[2])
change = FileChange.new(repository, match[2], getChangeType(match[1]), dirty)
Log.instance.info(change.to_s())
result << change
end
end
return [result]
end
|
#getChangeType(changeChar) ⇒ Object
58
59
60
|
# File 'lib/disloku/git/ChangeSetProvider.rb', line 58
def getChangeType(changeChar)
return CHANGE_MAP[changeChar]
end
|