Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Gitserver: add StatusTypeChanged to supported statuses in ChangedFiles#62548

Merged
camdencheek merged 6 commits into
mainfrom
cc/amd-filter
May 9, 2024
Merged

Gitserver: add StatusTypeChanged to supported statuses in ChangedFiles#62548
camdencheek merged 6 commits into
mainfrom
cc/amd-filter

Conversation

@camdencheek

@camdencheek camdencheek commented May 8, 2024

Copy link
Copy Markdown
Member

This adds support for T statuses (type changed) to ChangedFiles. This was previously hard-erroring, which was causing problems for code insights and hybrid search.

Apologies for the large diff. Part of this required adding a "type changed" member to the StatusAMD enum, which would be confusing because AMD stands for "added, modified, deleted". I renamed StatusAMD to Status, renamed the members to a pattern like StatusAdded, and added StatusTypeChanged. I checked every consumer of this enum to ensure that it safely handled new values.

Because of the noise from the rename, I added comments to all the important bits of this PR.

Related Slack discussion

Test plan

Added test both to the git CLI backend and to hybrid search, which is a consumer of this API.

@graphite-app

graphite-app Bot commented May 8, 2024

Copy link
Copy Markdown

Graphite Automations

"Auto-assign PRs to author" took an action on this PR • (05/08/24)

3 assignees were added to this PR based on Geoffrey Gilmore's automation.

@camdencheek

Copy link
Copy Markdown
Member Author

Oops. Didn't mean to assign anyone yet. Still adding tests.

@eseliger

eseliger commented May 8, 2024

Copy link
Copy Markdown
Member

sorry, rogue automation

Comment thread cmd/gitserver/internal/git/gitcli/diff.go Outdated
@camdencheek camdencheek changed the title Gitserver: explicitly filter to added, modified, and deleted files Gitserver: add StatusTypeChanged to supported statuses in ChangedFiles May 8, 2024
Comment on lines +313 to 316
expectedChanges := []gitdomain.PathStatus{
{Path: "f1", Status: gitdomain.StatusTypeChanged},
{Path: "f2", Status: gitdomain.StatusAdded},
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Added a test that we correctly parse StatusTypeChange

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.

Thank you :comfy:

Comment thread cmd/searcher/internal/search/search.go Outdated

// GitChangedFiles returns an iterator that yields list of changed files that have changed in between commitA and commitB in the given
// repo.
// repo. The returned statuses will be one of StatusAdded, StatusRemoved, StatusModified, or StatusTypeChanged

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Documented which statuses can be returned by this function.

Comment on lines +43 to +48
StatusUnspecified Status = 'X'
StatusAdded Status = 'A'
StatusModified Status = 'M'
StatusDeleted Status = 'D'
StatusTypeChanged Status = 'T'
// TODO: add other possible statuses here (see man git-diff-tree)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Modified the type of status to be byte because 1) it's smaller, 2) it's directly comparable to what we get from Git, and 3) it's more decipherable when debugging.

STATUS_ADDED = 1;
STATUS_MODIFIED = 2;
STATUS_DELETED = 3;
STATUS_TYPE_CHANGED = 4;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Added an item to the enum. The rest of this seems to be output from buf format and my editor's comment wrapping (sorry)

{Status: gitdomain.StatusModified, Path: "changed.go"},
{Status: gitdomain.StatusAdded, Path: "added.md"},
{Status: gitdomain.StatusDeleted, Path: "removed.md"},
{Status: gitdomain.StatusTypeChanged, Path: "type_changed.md"},

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Added an entry to the iterator to ensure that the test output doesn't change with a T status

@camdencheek camdencheek requested a review from a team May 8, 2024 16:36
Comment thread cmd/worker/internal/embeddings/repo/handler.go
Comment thread cmd/symbols/internal/database/writer/writer.go
Comment thread internal/gitserver/gitdomain/log_test.go Outdated

@eseliger eseliger 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.

great work :)

Comment thread cmd/gitserver/internal/git/gitcli/diff.go
Comment thread cmd/searcher/internal/search/search.go Outdated
Comment on lines +313 to 316
expectedChanges := []gitdomain.PathStatus{
{Path: "f1", Status: gitdomain.StatusTypeChanged},
{Path: "f2", Status: gitdomain.StatusAdded},
}

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.

Thank you :comfy:

Co-authored-by: Erik Seliger <erikseliger@me.com>
Comment thread internal/rockskip/index.go
Comment thread internal/rockskip/index.go
// doesn't exist in "indexed"
unindexedSearch = append(unindexedSearch, c.Path)
default:
// ignore any other statuses

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.

I know this is preserving the previous behaviour, but I think it's clearer to say type change doesn't affect search results. Does it make sense from a style perspective to handle it but have a noop body?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yep, that's aligned with @ggilmore's comments too. Changed!

@camdencheek camdencheek merged commit f139408 into main May 9, 2024
@camdencheek camdencheek deleted the cc/amd-filter branch May 9, 2024 14:43
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants