Class RemoteRepoBranchApi
Implements friendly GitHub repository branch related APIs.
Namespace: Neon.GitHub
Assembly: Neon.GitHub.dll
Syntax
public class RemoteRepoBranchApi
Methods
ExistsAsync(string)
Determines whether a branch exists in the origin repo.
Declaration
public Task<bool> ExistsAsync(string branchName)
Parameters
Type | Name | Description |
---|---|---|
string | branchName | Specifies the origin repository branch name. |
Returns
Type | Description |
---|---|
Task<bool> |
|
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | Thrown when the GitHubRepo has been disposed. |
FindAsync(string)
Searches for a specific GitHub origin repository branch.
Declaration
public Task<Branch> FindAsync(string branchName)
Parameters
Type | Name | Description |
---|---|---|
string | branchName | Specifies the origin repository branch name. |
Returns
Type | Description |
---|---|
Task<Branch> | The requested Octokit.Branch or |
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | Thrown when the GitHubRepo has been disposed. |
GetAllAsync()
Returns all branches from the GitHub origin repository.
Declaration
public Task<IReadOnlyList<Branch>> GetAllAsync()
Returns
Type | Description |
---|---|
Task<IReadOnlyList<Branch>> | The list of branches. |
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | Thrown when the GitHubRepo has been disposed. |
GetAsync(string)
Returns a specific GitHub origin repository branch.
Declaration
public Task<Branch> GetAsync(string branchName)
Parameters
Type | Name | Description |
---|---|---|
string | branchName | Specifies the origin repository branch name. |
Returns
Type | Description |
---|---|
Task<Branch> | The requested Octokit.Branch. |
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | Thrown when the GitHubRepo has been disposed. |
NotFoundException | Thrown when the branch does not exist. |
GetBranchFileAsTextAsync(string, string)
Retieves the contents file in a specific repo branch as text.
Declaration
public Task<string> GetBranchFileAsTextAsync(string branchName, string relativePath)
Parameters
Type | Name | Description |
---|---|---|
string | branchName | Specifies the origin repository branch name. |
string | relativePath | Specifies the path to the file relative to the remote repository root folder. This may include a leading slash (which is assumed when not present) and both forward and backslashes are allowed as path separators. |
Returns
Type | Description |
---|---|
Task<string> | The file text. |
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | Thrown when the GitHubRepo has been disposed. |
NotFoundException | Thrown if the branch or the file doesn't exist. |
GetBranchFileAsync(string, string, Stream)
Copies the contents of a file in a specific repo branch to a stream.
Declaration
public Task GetBranchFileAsync(string branchName, string relativePath, Stream output)
Parameters
Type | Name | Description |
---|---|---|
string | branchName | Specifies the origin repository branch name. |
string | relativePath | Specifies the path to the file relative to the remote repository root folder. This may include a leading slash (which is assumed when not present) and both forward and backslashes are allowed as path separators. |
Stream | output | Specifies the stream where the remote file contents will be copied. |
Returns
Type | Description |
---|---|
Task | The tracking Task. |
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | Thrown when the GitHubRepo has been disposed. |
NotFoundException | Thrown if the branch or file file doesn't exist. |
GetBranchProtectionAsync(string)
Returns the branch protections settings for a specific GitHub origin repository branch.
Declaration
public Task<BranchProtectionSettings> GetBranchProtectionAsync(string branchName)
Parameters
Type | Name | Description |
---|---|---|
string | branchName | Specifies the origin repository branch name. |
Returns
Type | Description |
---|---|
Task<BranchProtectionSettings> | The requested Octokit.BranchProtectionSettings. |
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | Thrown when the GitHubRepo has been disposed. |
NotFoundException | Thrown when the branch does not exist. |
NotFoundException | Thrown when the branch is not currently protected. |
GetRemoteFileUriAsync(string, string, bool)
Converts a relative local repository file path like "/my-folder/test.txt" or "my-folder/test.txt" to the remote GitHub URI for the file within the the currently checked out branch.
note
The local or remote file doesn't need to actually exist.
Declaration
public Task<string> GetRemoteFileUriAsync(string branchName, string relativePath, bool raw = false)
Parameters
Type | Name | Description |
---|---|---|
string | branchName | Specifies the origin repository branch name. |
string | relativePath | Specifies the path to the file relative to the local repository root folder. This may include a leading slash (which is assumed when not present) and both forward and backslashes are allowed as path separators. |
bool | raw | Optionally returns the link to the raw file bytes as opposed to the URL for the GitHub HTML page for the file. |
Returns
Type | Description |
---|---|
Task<string> | The GitHub URI for the file from the current branch. |
Remarks
note
This method does not ensure that the target file actually exists in the repo.
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | Thrown when the GitHubRepo has been disposed. |
NoLocalRepositoryException | Thrown when the GitHubRepo is not associated with a local git repository. |
RemoveAsync(string)
Removes an origin branch, if it exists.
Declaration
public Task<bool> RemoveAsync(string branchName)
Parameters
Type | Name | Description |
---|---|---|
string | branchName | Specifies the origin repository branch name. |
Returns
Type | Description |
---|---|
Task<bool> |
|
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | Thrown when the GitHubRepo has been disposed. |
RemoveBranchProtection(string)
Removes all protection for for a specific GitHub origin repository branch.
Declaration
public Task RemoveBranchProtection(string branchName)
Parameters
Type | Name | Description |
---|---|---|
string | branchName |
|
Returns
Type | Description |
---|---|
Task | The tracking Task. |
UpdateBranchProtectionAsync(string, BranchProtectionSettingsUpdate)
Updates the branch protections settings for a specific GitHub origin repository branch.
Declaration
public Task<BranchProtectionSettings> UpdateBranchProtectionAsync(string branchName, BranchProtectionSettingsUpdate update)
Parameters
Type | Name | Description |
---|---|---|
string | branchName | Specifies the origin repository branch name. |
BranchProtectionSettingsUpdate | update | Specifies the new protection settings update for the branch. |
Returns
Type | Description |
---|---|
Task<BranchProtectionSettings> | The updated Octokit.BranchProtectionSettings. |
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | Thrown when the GitHubRepo has been disposed. |
NotFoundException | Thrown when the branch does not exist. |