-
Notifications
You must be signed in to change notification settings - Fork 543
How to get the line number of a diff? #806
Comments
@campoy I think you can use the All the logic that creates that hunks is on |
We could make textChunk public, so I can transform from Chunk to TextChunk and obtain that data. Another option is to create a new ChunkWithLines interface that textChunk satisfies. |
But type textChunk struct {
content string
op fdiff.Operation
}
func (t *textChunk) Content() string {
return t.content
}
func (t *textChunk) Type() fdiff.Operation {
return t.op
} We need to make type Hunk struct {
FromLine int
ToLine int
FromCount int
ToCount int
ctxPrefix string
ops []*op
} With func NewHunksGenerator(chunks []Chunk, ctxLines int) *HunksGenerator {
[...]
func (c *HunksGenerator) Generate() []*Hunk { |
Oh, I had debugged this some time ago and got the types mixed up, clearly. This seems quite complicated, but I have a pretty limited knowledge of the project, so I'll let @mcuadros and others decide on what the next move is. |
I also try to rewrite the code on @ajnavarro's recommendations, but it's very difficult. |
I don't have it, no. |
I'm currently trying to obtain the lines that are new code in a diff.
To do so I wrote the code below
This works and if called with
diffHeadAndPrevious("https://github.com/campoy/goodgopher", "pr")
it will print the content of the lines that changed:Unfortunately I'd like to know what lines are those in the destination file.
I spent a decent amount of time searching around the documentation but couldn't find anything.
Help, please.
The text was updated successfully, but these errors were encountered: