Skip to content

Fix status parsing for renamed files - #494

Merged
joshaber merged 16 commits into
masterfrom
renames
Oct 7, 2016
Merged

joshaber merged 16 commits into
masterfrom
renames

Conversation

@niik

@niik niik commented Oct 6, 2016

Copy link
Copy Markdown
Member

I was trying out renamed files for #425 when I noticed that diffs wouldn't display. Turns out this is because git status --porcelain outputs a -> separator between the old and new path for a rename and we were happily parsing it all straight into FileChange.name.

This switches us over to using git status --porcelain -z so that we get null terminated fields. It also adds oldPath to FileChange and enables the rename icon in the changes list.

image

With this PR we'll at least display diffs but they're not exactly accurate. Since we run git diff --no-index we show a full addition diff for renames rather than just the lines that have changed. I don't have a good idea off the top of my head of how to fix that but it seems like that's out of scope for this PR anyway.

Comment thread app/src/lib/status-parser.ts Outdated
const fields = output.split('\0')
let field: string | undefined

while ((field = fields.shift())) {

This comment was marked as spam.

Comment thread app/test/unit/status-parser-test.ts Outdated
import { parsePorcelainStatus } from '../../src/lib/status-parser'

describe('parsePorcelainStatus', () => {
it('parses a standard status', async () => {

This comment was marked as spam.

@shiftkey

shiftkey commented Oct 7, 2016

Copy link
Copy Markdown
Member

Looking good:

screen shot 2016-10-07 at 3 14 01 pm

@shiftkey shiftkey left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just little things. Opened #495 to track the related diff change.

@niik

niik commented Oct 7, 2016

Copy link
Copy Markdown
Member Author

🚈

Comment thread app/src/ui/changes/changed-file.tsx Outdated
public render() {
const fileStatus = ChangedFile.mapStatus(this.props.status)
const path = this.props.status === FileStatus.Renamed && this.props.oldPath
? `${this.props.oldPath} -> ${this.props.path}`

This comment was marked as spam.

This comment was marked as spam.

@niik

niik commented Oct 7, 2016

Copy link
Copy Markdown
Member Author

🏷

@joshaber

joshaber commented Oct 7, 2016

Copy link
Copy Markdown
Contributor

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants