-
Notifications
You must be signed in to change notification settings - Fork 534
Conversation
Codecov Report
@@ Coverage Diff @@
## master #613 +/- ##
==========================================
- Coverage 78.3% 77.67% -0.63%
==========================================
Files 130 130
Lines 10231 10302 +71
==========================================
- Hits 8011 8002 -9
- Misses 1358 1448 +90
+ Partials 862 852 -10
Continue to review full report at Codecov.
|
@ajnavarro you was working with diff, maybe you can give a hand here. |
@darkowlzz about comparing the parent tree against void, just use a empty |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe is worth it to add this Stats()
method to the Patch
object. Doing this we can get Stats between any Commit that we want, or even between trees or files.
plumbing/object/commit.go
Outdated
|
||
for _, chunk := range fp.Chunks() { | ||
switch chunk.Type() { | ||
case 1: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should use the Operation
constants, just in case that they will change in the future:
plumbing/object/commit.go
Outdated
} | ||
|
||
// FileStats is a collection of FileStat. | ||
type FileStats []FileStat |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe FileStats should have a String()
method too
plumbing/object/commit.go
Outdated
totalChanges := fs.Addition + fs.Deletion | ||
adds := strings.Repeat("+", fs.Addition) | ||
dels := strings.Repeat("-", fs.Deletion) | ||
return fmt.Sprintf(" %s | %d %s%s", fs.Name, totalChanges, adds, dels) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This output is not correct. totalChanges
is correct, but the number of +
and -
is not. Should be the ratio of added and removed lines. See man diffstat
for more info.
Also: https://stackoverflow.com/questions/7024848/git-diff-stat-explanation
Yes, you're right. Rename is not actually supported. |
We can move it to |
9f101c0
to
d1414cf
Compare
emptyNoder := treeNoder{} | ||
parentCommit = &Commit{ | ||
Hash: emptyNoder.hash, | ||
// TreeHash: emptyNoder.parent.Hash, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mcuadros I think I'm not using it the way you meant.
This is for the first commit scenario, no parent commit.
Without assigning a TreeHash
I get panic: object not found
.
And if I uncomment the above line, it panics with invalid memory address
error.
Missing something really simple? 😅
Thanks for the review. I have moved Also, created |
Can you rebase @darkowlzz, thanks! |
Stats() is similar to `git show --stat <hash>`.
d1414cf
to
11162e1
Compare
Rebased! |
@ajnavarro PTAL |
Stats() is similar to
git show --stat <hash>
.This introduces a new type
FileStat
which stores the stats of a file patch. It can be printed to havegit cli style printing of addition and deletion.
Need help with:
merkletrie.Action
which supports"Insert"
,"Delete"
and"Modify"
only. And it made me assume file rename is not supported.fixes #482