GitHawkApp / GitHawk

The (second) best iOS app for GitHub.
http://githawk.com
MIT License
2.88k stars 384 forks source link

Improving GitHawk's git diff viewer #1697

Open SD10 opened 6 years ago

SD10 commented 6 years ago

I've been working on a git diff parser for another project and wondered if it could be of any benefit to GitHawk. I've been too busy to contribute lately but if I can kill two birds with this stone, that would be šŸ˜Ž

I'm thinking this could give us richer text highlighting and you also would have access to line numbers.

Library is still in progress, will be fully unit tested over the next couple of days.

We just need to download the raw diff file from the PR url then it gets parsed into the following model:

public struct GitDiff: Codable {
    public var previousFilePath: String
    public var updatedFilePath: String
    public var index: GitIndex
    public var hunks: [GitHunk]
}

public struct GitHunk: Codable {
    public var oldLineStart: Int
    public var oldLineSpan: Int
    public var newLineStart: Int
    public var newLineSpan: Int
    public var changes: [GitDiffLine]
}

public struct GitIndex: Codable {
    public let id: String
    public let commitHead: String
    public let commitTail: String
}

public struct GitDiffLine: Codable {
    public var type: String
    public var text: String
    public var oldLine: Int
    public var newLine: Int
    public var noNewLine: Bool = false
}
rnystrom commented 6 years ago

YESSSS this would be awesome! I was thinking something similar the other day when I realized that GitHub.com shows you the rest of the file context w/ the patch applied. If we typed the diff hunk out we could do so many more fun UI things!

weyert commented 6 years ago

We already had a simplified version of this here but back then there was no interest: https://github.com/weyert/GitHawk/tree/code-text-view https://github.com/weyert/GitHawk/blob/code-text-view/Classes/Utility/Parsers/DiffParser.swift https://github.com/weyert/GitHawk/blob/code-text-view/Classes/Issues/Files/IssuePatchContentViewController.swift

Maybe it's useful to have a look at it again?

NoahTheDuke commented 6 years ago

Iā€™d love this.

rnystrom commented 6 years ago

@SD10 any update here?

Sent with GitHawk

SD10 commented 6 years ago

@rnystrom Unfortunately no šŸ˜¢ Occasionally, I think about fixing the few edge cases in GitDiffSwift and then transferring it to the GitHawk organization -- but I'm pretty swamped with work right now

jdisho commented 6 years ago

@SD10 If you need any help, I am happy to help you šŸ˜Š

Sent with GitHawk