| Modifier and Type | Field and Description |
|---|---|
| private final GitPreferences | |
| private static final Logger | |
| pack-priv final Path | |
| pack-priv final File |
| Access | Constructor and Description |
|---|---|
| public | GitHandler(Path
The root of the initialized git repository repositoryPath, GitPreferences gitPreferences)Initialize the handler for the given repository |
| Modifier and Type | Method and Description |
|---|---|
| public void | checkoutBranch(String
Name of the branch to check out branchToCheckout)Checkout the branch with the specified name, if it does not exist create it |
| private void | |
| public boolean | Returns: true if a commit was created, false if the file was unchangedCommits |
| public boolean | Returns: Returns true if a new commit was created. This is the case if the repository was not clean on method invocationWhether to amend to the last commit (true), or not (false) amend)Creates a commit on the currently checked out branch |
| private static Optional | |
| public void | |
| public void | |
| public static Optional | Returns: an optional containing the path to the Git repository root if foundthe file or directory path that is assumed to be located inside a Git repository anyPathInsideRepo)Try to locate the Git repository root by walking up the directory tree starting from the given path. |
| public static Optional | |
| public Optional | |
| public String | |
| private static String | |
| pack-priv Optional | getRefForBranch(String branchName)
Returns the reference of the specified branch If it does not exist returns an empty optional |
| public File | |
| public boolean | |
| public synchronized void | initAndCommit(@NonNull Path fileToCommit)
Creates the repository and commits |
| public void | |
| pack-priv boolean | isGitRepository()
Returns true if the given path points to a directory that is a git repository (contains a .git folder) |
| public void | mergeBranches(String
the name of the branch that is merged into targetBranch, String the name of the branch that gets merged sourceBranch, MergeStrategy mergeStrategy)Merges the source branch into the target branch |
| public Git | |
| public void | |
| public void | pushCommitsToRemoteRepository()
Pushes all commits made to the branch that is tracked by the currently checked out branch. |
| public void | |
| private String | relativizeToRepository(Path file)
The Git index always uses forward slashes, independent of the platform. |
| private static boolean | |
| public static @NonNull Path | resolveToRealPath(@NonNull Path path)
Resolves symlinks so repository detection and repository-relative paths refer to the real file. |
| pack-priv void | |
| private static void |
| gitPreferences | back to summary |
|---|---|
| private final GitPreferences gitPreferences | |
| LOGGER | back to summary |
|---|---|
| private static final Logger LOGGER | |
| repositoryPath | back to summary |
|---|---|
| pack-priv final Path repositoryPath | |
| repositoryPathAsFile | back to summary |
|---|---|
| pack-priv final File repositoryPathAsFile | |
| GitHandler | back to summary |
|---|---|
| public GitHandler(Path repositoryPath, GitPreferences gitPreferences) Initialize the handler for the given repository
| |
| checkoutBranch | back to summary |
|---|---|
| public void checkoutBranch(String branchToCheckout) throws IOException, GitAPIException Checkout the branch with the specified name, if it does not exist create it
| |
| copyGitIgnoreIfAbsent | back to summary |
|---|---|
| private void copyGitIgnoreIfAbsent() throws IOException | |
| createCommitForFileOnCurrentBranch | back to summary |
|---|---|
| public boolean createCommitForFileOnCurrentBranch(Path fileToCommit, String commitMessage) throws IOException, GitAPIException Commits Unlike
| |
| createCommitOnCurrentBranch | back to summary |
|---|---|
| public boolean createCommitOnCurrentBranch(String commitMessage, boolean amend) throws IOException, GitAPIException Creates a commit on the currently checked out branch
| |
| currentRemoteUrl | back to summary |
|---|---|
| private static Optional | |
| fastForwardTo | back to summary |
|---|---|
| public void fastForwardTo(RevCommit remote) throws IOException, GitAPIException Fast-forward only to | |
| fetchOnCurrentBranch | back to summary |
|---|---|
| public void fetchOnCurrentBranch() throws JabRefException | |
| findRepositoryRoot | back to summary |
|---|---|
| public static Optional Try to locate the Git repository root by walking up the directory tree starting from the given path. If a directory containing a .git folder is found, return that path. | |
| fromAnyPath | back to summary |
|---|---|
| public static Optional | |
| getCredentialsProvider | back to summary |
|---|---|
| public Optional | |
| getCurrentlyCheckedOutBranch | back to summary |
|---|---|
| public String getCurrentlyCheckedOutBranch() throws IOException | |
| getLocalizedPushRejectionMessage | back to summary |
|---|---|
| private static String getLocalizedPushRejectionMessage(RemoteRefUpdate update, String remoteMessage) | |
| getRefForBranch | back to summary |
|---|---|
| pack-priv Optional Returns the reference of the specified branch If it does not exist returns an empty optional | |
| getRepositoryPathAsFile | back to summary |
|---|---|
| public File getRepositoryPathAsFile() | |
| hasRemote | back to summary |
|---|---|
| public boolean hasRemote(String remoteName) | |
| initAndCommit | back to summary |
|---|---|
| public synchronized void initAndCommit(@NonNull Path fileToCommit) throws IOException, GitAPIException, JabRefException Creates the repository and commits Fails with a
| |
| initIfNeeded | back to summary |
|---|---|
| public void initIfNeeded() | |
| isGitRepository | back to summary |
|---|---|
| pack-priv boolean isGitRepository() Returns true if the given path points to a directory that is a git repository (contains a .git folder) | |
| mergeBranches | back to summary |
|---|---|
| public void mergeBranches(String targetBranch, String sourceBranch, MergeStrategy mergeStrategy) throws IOException, GitAPIException Merges the source branch into the target branch | |
| open | back to summary |
|---|---|
| public Git open() throws IOException | |
| pullOnCurrentBranch | back to summary |
|---|---|
| public void pullOnCurrentBranch() throws IOException Pulls from the current branch’s upstream. If no remote is configured, silently performs local merge. This ensures SLR repositories without remotes still initialize correctly. | |
| pushCommitsToRemoteRepository | back to summary |
|---|---|
| public void pushCommitsToRemoteRepository() throws IOException, GitAPIException, JabRefException Pushes all commits made to the branch that is tracked by the currently checked out branch. | |
| pushCurrentBranchCreatingUpstream | back to summary |
|---|---|
| public void pushCurrentBranchCreatingUpstream() throws IOException, GitAPIException, JabRefException | |
| relativizeToRepository | back to summary |
|---|---|
| private String relativizeToRepository(Path file) The Git index always uses forward slashes, independent of the platform. | |
| requiresCredentialsForUrl | back to summary |
|---|---|
| private static boolean requiresCredentialsForUrl(String url) | |
| resolveToRealPath | back to summary |
|---|---|
| public static @NonNull Path resolveToRealPath(@NonNull Path path) Resolves symlinks so repository detection and repository-relative paths refer to the real file. Falls back to the lexical absolute path when resolution fails (e.g. the file vanished meanwhile). | |
| setupGitIgnore | back to summary |
|---|---|
| pack-priv void setupGitIgnore() | |
| verifyPushResults | back to summary |
|---|---|
| private static void verifyPushResults(Iterable<PushResult> pushResults) throws JabRefException | |