Skip to content

feat(gitter): importer endpoints#5690

Open
Ly-Joey wants to merge 11 commits into
google:masterfrom
Ly-Joey:feat-gitter-importer-endpoints
Open

feat(gitter): importer endpoints#5690
Ly-Joey wants to merge 11 commits into
google:masterfrom
Ly-Joey:feat-gitter-importer-endpoints

Conversation

@Ly-Joey

@Ly-Joey Ly-Joey commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Adds:

  • /file-diffs: List file diffs from last_synced_commit to HEAD of target branch (defaults to remote's origin/HEAD if not provided in request)
  • /file-content: Given commit hash and file path, git cat-file the content of the file

Also did some small refactoring to move code that handles repo fetching, cloning, etc into git.go.

There will be a follow-up PR to update importer to use these new endpoints.

@Ly-Joey
Ly-Joey force-pushed the feat-gitter-importer-endpoints branch from 5225fef to f92281d Compare July 20, 2026 01:44
Comment thread go/cmd/gitter/git.go Dismissed
Comment thread go/cmd/gitter/git.go Dismissed
Comment thread go/cmd/gitter/git.go Dismissed
Comment thread go/cmd/gitter/git.go Dismissed
Comment thread go/cmd/gitter/git.go Dismissed
@Ly-Joey
Ly-Joey marked this pull request as ready for review July 20, 2026 05:30
Comment thread go/cmd/gitter/gitter.go Outdated
Comment thread go/cmd/gitter/gitter.go Outdated
Comment thread go/cmd/gitter/gitter.go Outdated
Comment thread go/cmd/gitter/repository.go Outdated
)

// getEmptyTreeHash calculates and caches the empty tree hash
func getEmptyTreeHash(ctx context.Context, repoPath string) string {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

huh is this meant to be difference from the fallback value?

Comment thread go/cmd/gitter/repository.go Outdated
}

/**
Possible status letters are:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Link to the docs here?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Also, I think this is actually copied from the wrong part of the doc, so is missing the B status.

See https://git-scm.com/docs/git-diff-tree (--name-status)

Show only the name(s) and status of each changed file. See the description of the --diff-filter option on what the status letters mean. Just like --name-only the file names are often encoded in UTF-8.

then see --diff-filter:

--diff-filter=[(A|C|D|M|R|T|U|X|B)...[*]]
Select only files that are Added (A), Copied (C), Deleted (D), Modified (M), Renamed (R), have their type (i.e. regular file, symlink, submodule, …​) changed (T), are Unmerged (U), are Unknown (X), or have had their pairing Broken (B). Any combination of the filter characters (including none) can be used. When * (All-or-none) is added to the combination, all paths are selected if there is any file that matches other criteria in the comparison; if there is no file that matches other criteria, nothing is selected.

Also, these upper-case letters can be downcased to exclude. E.g. --diff-filter=ad excludes added and deleted paths.

Note that not all diffs can feature all types. For instance, copied and renamed entries cannot appear if detection for those types is disabled.

But this part of the doc is from the raw git-diff-files command.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added doc link, it's actually from https://git-scm.com/docs/diff-format.
The diff-* (index / tree / files) commands all share this raw output format, so their respective docs link back to the same diff-format section via an include::. So, this status list would apply to git diff-tree as well.

Re: the "B" status:
TL;DR: In terms of output, "B" is never a real status that will show up.

It is associated with the -B (--break-rewrites) flag.
If enabled, it breaks large modifications into separate add (A) and delete (D) pairs. But later in the diffcore transformation, these broken-up pairs will either resolve as a rename (R) or merge back into a modified (M).
(ref: https://git-scm.com/docs/gitdiffcore)

While the B option in --diff-filter can be used to filter files with large modifications (thus "broken" at one point), the transformations within git diff will not be printed it as a "B" status in either the --name-status or --raw output.

Comment thread go/cmd/gitter/gitter.go Outdated
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