Class GitSource
java.lang.Object
network.ike.docs.plugin.diff.GitSource
- All Implemented Interfaces:
AutoCloseable
Read-only access to both sides of a doc-diff comparison
(ike-issues#649): any two commits, or a commit and the working tree.
The to side accepts the pseudo-ref WORKTREE, meaning the
uncommitted working tree — the default review case. Rename detection
is on, so a moved fragment is compared across the move rather than
reported as delete-plus-add.
All paths are repository-relative with forward slashes, as JGit reports them.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordOne changed file between the two sides.static final recordMetadata of one commit in a compared range, for change-entity derivation from trailers (ike-issues#652) and stamp endnotes (ike-issues#656). -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionblameInRange(String toRef, String path, Set<String> rangeCommitIds) Attribute each line of a file's to-side text to the range commit that introduced it (ike-issues#656).branch()The current branch name — the git-era analogue of the STAMP path coordinate.List the files that differ between the two sides, with rename detection, filtered to a path prefix and suffix.voidclose()commitsBetween(String fromRef, String toRef) Walk the commits reachable fromtoRefand not fromfromRef(i.e.Find the first path on a side that ends with the given suffix — used to discover the topic-registry source root from an assembly module (ike-issues#649 subproject scoping).List the immediate.yamlchildren of a directory on a side — used to enumerate per-domain registry files on both sides of the comparison.static GitSourceOpen the repository that contains the given directory, walking upward to find the git dir (a module's basedir is typically below the repository root).Read one file's text from a side.userName()The configured user name, used as the author of uncommitted (working-tree) stamps.workTree()The repository's working-tree root.
-
Field Details
-
WORKTREE
Pseudo-ref naming the uncommitted working tree as a side.- See Also:
-
UNCOMMITTED
Attribution value for working-tree lines not yet committed.- See Also:
-
-
Method Details
-
open
Open the repository that contains the given directory, walking upward to find the git dir (a module's basedir is typically below the repository root).- Parameters:
within- a directory inside the repository- Returns:
- an open source; close it when done
- Throws:
IOException- when no repository contains the directory
-
workTree
-
changes
public List<GitSource.Change> changes(String fromRef, String toRef, String pathPrefix, String suffix) throws IOException List the files that differ between the two sides, with rename detection, filtered to a path prefix and suffix.- Parameters:
fromRef- the from-side ref (any committish)toRef- the to-side ref, orWORKTREEpathPrefix- repository-relative prefix filter (may be empty)suffix- file-name suffix filter, e.g..adoc(may be empty)- Returns:
- the matching changes in path order
- Throws:
IOException- on repository access failure
-
read
Read one file's text from a side.- Parameters:
ref- a committish, orWORKTREEpath- the repository-relative path- Returns:
- the file text, or
nullwhen absent on that side - Throws:
IOException- on repository access failure
-
listYaml
List the immediate.yamlchildren of a directory on a side — used to enumerate per-domain registry files on both sides of the comparison.- Parameters:
ref- a committish, orWORKTREEdir- the repository-relative directory- Returns:
- the repository-relative file paths found
- Throws:
IOException- on repository access failure
-
findPath
Find the first path on a side that ends with the given suffix — used to discover the topic-registry source root from an assembly module (ike-issues#649 subproject scoping).- Parameters:
ref- a committish, orWORKTREEsuffix- the path suffix to match, e.g.src/docs/asciidoc/topic-registry.yaml- Returns:
- the first matching repository-relative path in walk
order, or
nullwhen none matches - Throws:
IOException- on repository access failure
-
branch
The current branch name — the git-era analogue of the STAMP path coordinate.- Returns:
- the branch name, or the abbreviated detached-head id
- Throws:
IOException- on repository access failure
-
userName
The configured user name, used as the author of uncommitted (working-tree) stamps.- Returns:
- the configured
user.name, or"(local)"
-
blameInRange
public List<String> blameInRange(String toRef, String path, Set<String> rangeCommitIds) throws IOException Attribute each line of a file's to-side text to the range commit that introduced it (ike-issues#656). Lines introduced beforefromRefmap tonull(unmarked context never asks for a stamp); working-tree lines not yet committed map toUNCOMMITTED.- Parameters:
toRef- the to side (WORKTREEor committish)path- the repository-relative file pathrangeCommitIds- abbreviated ids of the commits in range- Returns:
- one attribution per to-side line: an abbreviated commit
id,
UNCOMMITTED, ornull - Throws:
IOException- on repository access failure
-
commitsBetween
Walk the commits reachable fromtoRefand not fromfromRef(i.e.fromRef..toRef), oldest first, with each commit's touched files.- Parameters:
fromRef- the exclusive lower bound (committish)toRef- the inclusive upper bound (committish; notWORKTREE)- Returns:
- commit metadata, oldest first
- Throws:
IOException- on repository access failure
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-