Class RepositoryService
java.lang.Object
io.github.jbastgen.stemma.app.git.RepositoryService
- All Implemented Interfaces:
AutoCloseable
Application service through which the UI uses the Git backend. All work runs on virtual threads, never on the
JavaFX thread, and operations on the same repository are executed one after the other: a push cannot overlap
with a commit, and a reload sees a consistent state.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionio.github.jbastgen.stemma.git.api.GitBackendbackend()The Git implementation in use.cloneAsync(String url, Path directory) Clones a repository and returns its snapshot.voidclose()CompletableFuture<io.github.jbastgen.stemma.git.api.CommitDetails> commitDetails(Path directory, String commitId) Reads the details of a commit: message body and changed files.CompletableFuture<io.github.jbastgen.stemma.git.api.FileDiff> Reads the diff of one file.Creates a repository and returns its snapshot.Creates a repository and returns its snapshot.Loads a snapshot synchronously.Loads a snapshot on a virtual thread.voidsetBackend(io.github.jbastgen.stemma.git.api.GitBackend backend) Switches the Git implementation; takes effect for the next operation.<T> CompletableFuture<T> Runsoperationon the repository indirectoryon a virtual thread, after earlier operations on the same repository have finished.summaryAsync(Path directory) Loads just enough for a library card: branch, changes, last commit, remotes and ahead/behind.
-
Field Details
-
HISTORY_LIMIT
public static final int HISTORY_LIMIT- See Also:
-
-
Constructor Details
-
RepositoryService
public RepositoryService(io.github.jbastgen.stemma.git.api.GitBackend backend) - Parameters:
backend- the Git implementation to use first; seesetBackend(io.github.jbastgen.stemma.git.api.GitBackend)
-
-
Method Details
-
backend
public io.github.jbastgen.stemma.git.api.GitBackend backend()The Git implementation in use. -
setBackend
public void setBackend(io.github.jbastgen.stemma.git.api.GitBackend backend) Switches the Git implementation; takes effect for the next operation. -
load
Loads a snapshot synchronously. Never call this on the JavaFX application thread. -
loadAsync
Loads a snapshot on a virtual thread. Completes exceptionally with aGitExceptionon failure. -
summaryAsync
Loads just enough for a library card: branch, changes, last commit, remotes and ahead/behind. Much cheaper thanloadAsync(java.nio.file.Path), so a library of many repositories opens quickly. -
submit
public <T> CompletableFuture<T> submit(Path directory, Function<io.github.jbastgen.stemma.git.api.GitRepository, T> operation) Runsoperationon the repository indirectoryon a virtual thread, after earlier operations on the same repository have finished. The repository is opened for the operation and closed afterwards. The future fails with theGitExceptionthrown by the operation. -
commitDetails
public CompletableFuture<io.github.jbastgen.stemma.git.api.CommitDetails> commitDetails(Path directory, String commitId) Reads the details of a commit: message body and changed files. -
diff
public CompletableFuture<io.github.jbastgen.stemma.git.api.FileDiff> diff(Path directory, io.github.jbastgen.stemma.git.api.DiffTarget target, String path) Reads the diff of one file. -
initAsync
Creates a repository and returns its snapshot. -
initAsync
public CompletableFuture<RepositorySnapshot> initAsync(Path directory, String initialBranch, boolean gitFlow) Creates a repository and returns its snapshot.- Parameters:
gitFlow- also set Git Flow up:initialBranchis the production branch, it gets an empty first commit,developis created from it and checked out
-
cloneAsync
Clones a repository and returns its snapshot. -
close
public void close()- Specified by:
closein interfaceAutoCloseable
-