Skip to main content

SourceControl

Trait SourceControl 

Source
pub trait SourceControl: Send + Sync {
Show 15 methods // Required methods fn name(&self) -> &str; fn get_commits_since<'life0, 'life1, 'async_trait>( &'life0 self, tag: Option<&'life1 str>, ) -> Pin<Box<dyn Future<Output = Result<Vec<Commit>, ScmError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn get_last_tag<'life0, 'life1, 'async_trait>( &'life0 self, pattern: Option<&'life1 str>, ) -> Pin<Box<dyn Future<Output = Result<Option<String>, ScmError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn create_tag<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, name: &'life1 str, message: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<String, ScmError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait; fn delete_tag<'life0, 'life1, 'async_trait>( &'life0 self, name: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<(), ScmError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn get_current_commit<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<String, ScmError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn get_current_branch<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<String, ScmError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn get_working_tree_status<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<WorkingTreeStatus, ScmError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn commit<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, message: &'life1 str, files: &'life2 [String], ) -> Pin<Box<dyn Future<Output = Result<String, ScmError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait; fn stage_files<'life0, 'life1, 'async_trait>( &'life0 self, files: &'life1 [String], ) -> Pin<Box<dyn Future<Output = Result<(), ScmError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn push<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, remote: Option<&'life1 str>, branch: Option<&'life2 str>, ) -> Pin<Box<dyn Future<Output = Result<(), ScmError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait; fn repository_root(&self) -> Option<&Path>; fn is_on_branch<'life0, 'life1, 'async_trait>( &'life0 self, branch: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<bool, ScmError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn get_tags_for_commit<'life0, 'life1, 'async_trait>( &'life0 self, commit_hash: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<String>, ScmError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn get_remote_url<'life0, 'life1, 'async_trait>( &'life0 self, remote: Option<&'life1 str>, ) -> Pin<Box<dyn Future<Output = Result<Option<String>, ScmError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait;
}
Expand description

Trait for source control operations

Provides an abstraction over Git (and potentially other VCS) operations needed for release automation.

§Examples

The trait is used by implementors that provide Git (or other VCS) operations:

use governor_core::traits::source_control::SourceControl;

// A concrete implementation would provide:
let commits = scm.get_commits_since(Some("v1.0.0")).await?;
for commit in commits {
    println!("{}: {}", commit.hash, commit.message);
}

Required Methods§

Source

fn name(&self) -> &str

Get the name of this SCM (e.g., “git”)

Source

fn get_commits_since<'life0, 'life1, 'async_trait>( &'life0 self, tag: Option<&'life1 str>, ) -> Pin<Box<dyn Future<Output = Result<Vec<Commit>, ScmError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get commits since a specific tag/ref

§Arguments
  • tag - Optional tag/ref to get commits since. If None, returns all commits.
§Returns

Vector of commits in reverse chronological order (newest first).

§Errors

Returns ScmError::TagNotFound if the specified tag doesn’t exist.

Source

fn get_last_tag<'life0, 'life1, 'async_trait>( &'life0 self, pattern: Option<&'life1 str>, ) -> Pin<Box<dyn Future<Output = Result<Option<String>, ScmError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get the last tag matching a pattern

§Arguments
  • pattern - Optional pattern to filter tags (e.g., “v” for version tags).
§Returns

The most recent tag name, or None if no tags found.

Source

fn create_tag<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, name: &'life1 str, message: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<String, ScmError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Create a new tag

§Arguments
  • name - Tag name (e.g., “v1.0.0”)
  • message - Tag message
§Returns

The created tag name.

§Errors

Returns ScmError::GitError if tag creation fails.

Source

fn delete_tag<'life0, 'life1, 'async_trait>( &'life0 self, name: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<(), ScmError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Delete a tag

§Errors

Returns ScmError::TagNotFound if the tag doesn’t exist.

Source

fn get_current_commit<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<String, ScmError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get current commit hash

§Returns

The full SHA-1 hash of HEAD.

Source

fn get_current_branch<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<String, ScmError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get current branch name

§Returns

The current branch name (e.g., “main”).

Source

fn get_working_tree_status<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<WorkingTreeStatus, ScmError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Check if working tree is clean

§Returns

Status of the working tree including modified, added, deleted, and untracked files.

Source

fn commit<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, message: &'life1 str, files: &'life2 [String], ) -> Pin<Box<dyn Future<Output = Result<String, ScmError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Create a commit with staged changes

§Arguments
  • message - Commit message
  • files - List of file paths to include in the commit
§Returns

The created commit hash.

Source

fn stage_files<'life0, 'life1, 'async_trait>( &'life0 self, files: &'life1 [String], ) -> Pin<Box<dyn Future<Output = Result<(), ScmError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Stage files for commit

§Arguments
  • files - List of file paths to stage
Source

fn push<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, remote: Option<&'life1 str>, branch: Option<&'life2 str>, ) -> Pin<Box<dyn Future<Output = Result<(), ScmError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Push to remote

§Arguments
  • remote - Remote name (e.g., “origin”). If None, uses default.
  • branch - Branch name to push. If None, pushes current branch.
Source

fn repository_root(&self) -> Option<&Path>

Get repository root path

Source

fn is_on_branch<'life0, 'life1, 'async_trait>( &'life0 self, branch: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<bool, ScmError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Check if we’re on a specific branch

Source

fn get_tags_for_commit<'life0, 'life1, 'async_trait>( &'life0 self, commit_hash: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<String>, ScmError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get tags for a specific commit

§Returns

List of tag names pointing to this commit.

Source

fn get_remote_url<'life0, 'life1, 'async_trait>( &'life0 self, remote: Option<&'life1 str>, ) -> Pin<Box<dyn Future<Output = Result<Option<String>, ScmError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get remote URL

§Arguments
  • remote - Remote name (e.g., “origin”). If None, uses default.
§Returns

The fetch/push URL of the remote, or None if not configured.

Implementors§