Interface ScmApiClient
- All Known Implementing Classes:
BitbucketApiClient,BitbucketServerApiClient,GitHubApiClient,GitLabApiClient
public interface ScmApiClient
-
Method Summary
Modifier and TypeMethodDescriptionvoidAtomically commits multiple file changes to the given branch.voidcreateBranch(String branchName, String fromBranch) Creates a new branch from the given base branch.createPullRequest(String title, String body, String headBranch, String baseBranch, boolean draft) Creates a pull request and returns the created PR.voiddeleteBranch(String branchName) Deletes a branch (for cleanup/rollback).Returns the default branch name (e.g., "main", "master").getFileContent(String filePath, String branch) Returns the current file content as a UTF-8 string, or null if the file does not exist.voidValidates that the token has write access to the repository.
-
Method Details
-
getDefaultBranch
Returns the default branch name (e.g., "main", "master").- Returns:
- the default branch name
- Throws:
IOException- if the API call fails
-
createBranch
Creates a new branch from the given base branch.- Parameters:
branchName- the name of the new branchfromBranch- the branch to create from- Throws:
IOException- if the API call fails
-
getFileContent
Returns the current file content as a UTF-8 string, or null if the file does not exist.- Parameters:
filePath- the file path relative to repository rootbranch- the branch to read from- Returns:
- file content as a string, or null if not found
- Throws:
IOException- if the API call fails for a reason other than 404
-
commitFiles
void commitFiles(String branchName, String commitMessage, Map<String, String> fileContents) throws IOExceptionAtomically commits multiple file changes to the given branch.- Parameters:
branchName- the branch to commit tocommitMessage- the commit messagefileContents- map of filePath to new complete file content (not diffs)- Throws:
IOException- if the API call fails
-
createPullRequest
PullRequest createPullRequest(String title, String body, String headBranch, String baseBranch, boolean draft) throws IOException Creates a pull request and returns the created PR.- Parameters:
title- the pull request titlebody- the pull request description bodyheadBranch- the source branchbaseBranch- the target branchdraft- whether to create as a draft PR- Returns:
- the created PullRequest
- Throws:
IOException- if the API call fails
-
deleteBranch
Deletes a branch (for cleanup/rollback).- Parameters:
branchName- the branch to delete- Throws:
IOException- if the API call fails
-
validateWriteAccess
Validates that the token has write access to the repository.- Throws:
IOException- with a clear message if the token does not have push/write access
-