|
|
@ -11,6 +11,7 @@ pub(crate) enum GitCommand<'a> {
|
|
|
|
DefaultRemote,
|
|
|
|
DefaultRemote,
|
|
|
|
TrackedRemote(&'a str),
|
|
|
|
TrackedRemote(&'a str),
|
|
|
|
UpstreamBranch(&'a str),
|
|
|
|
UpstreamBranch(&'a str),
|
|
|
|
|
|
|
|
DefaultBranch(&'a str),
|
|
|
|
IsValidRemote(&'a str),
|
|
|
|
IsValidRemote(&'a str),
|
|
|
|
CurrentTag,
|
|
|
|
CurrentTag,
|
|
|
|
CurrentCommit,
|
|
|
|
CurrentCommit,
|
|
|
@ -44,6 +45,7 @@ pub trait GitTrait {
|
|
|
|
fn get_default_remote(&self) -> Result<GitOutput, AppError>;
|
|
|
|
fn get_default_remote(&self) -> Result<GitOutput, AppError>;
|
|
|
|
fn get_tracked_remote(&self, tracked: &str) -> Result<GitOutput, AppError>;
|
|
|
|
fn get_tracked_remote(&self, tracked: &str) -> Result<GitOutput, AppError>;
|
|
|
|
fn get_upstream_branch(&self, branch: &str) -> Result<GitOutput, AppError>;
|
|
|
|
fn get_upstream_branch(&self, branch: &str) -> Result<GitOutput, AppError>;
|
|
|
|
|
|
|
|
fn get_default_branch(&self, remote: &str) -> Result<GitOutput, AppError>;
|
|
|
|
fn is_valid_remote(&self, remote: &str) -> Result<GitOutput, AppError>;
|
|
|
|
fn is_valid_remote(&self, remote: &str) -> Result<GitOutput, AppError>;
|
|
|
|
fn get_current_tag(&self) -> Result<GitOutput, AppError>;
|
|
|
|
fn get_current_tag(&self) -> Result<GitOutput, AppError>;
|
|
|
|
fn get_current_commit(&self) -> Result<GitOutput, AppError>;
|
|
|
|
fn get_current_commit(&self) -> Result<GitOutput, AppError>;
|
|
|
@ -70,6 +72,10 @@ impl GitTrait for Git {
|
|
|
|
execute(command(GitCommand::UpstreamBranch(branch))?)
|
|
|
|
execute(command(GitCommand::UpstreamBranch(branch))?)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn get_default_branch(&self, remote: &str) -> Result<GitOutput, AppError> {
|
|
|
|
|
|
|
|
execute(command(GitCommand::DefaultBranch(remote))?)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn is_valid_remote(&self, remote: &str) -> Result<GitOutput, AppError> {
|
|
|
|
fn is_valid_remote(&self, remote: &str) -> Result<GitOutput, AppError> {
|
|
|
|
execute(command(GitCommand::IsValidRemote(remote))?)
|
|
|
|
execute(command(GitCommand::IsValidRemote(remote))?)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -107,6 +113,11 @@ fn command(git_command: GitCommand) -> Result<Output, std::io::Error> {
|
|
|
|
.arg("config")
|
|
|
|
.arg("config")
|
|
|
|
.arg(format!("branch.{}.merge", branch))
|
|
|
|
.arg(format!("branch.{}.merge", branch))
|
|
|
|
.output(),
|
|
|
|
.output(),
|
|
|
|
|
|
|
|
GitCommand::DefaultBranch(remote) => Command::new("git")
|
|
|
|
|
|
|
|
.arg("rev-parse")
|
|
|
|
|
|
|
|
.arg("--abbrev-ref")
|
|
|
|
|
|
|
|
.arg(format!("{}/HEAD", remote))
|
|
|
|
|
|
|
|
.output(),
|
|
|
|
GitCommand::IsValidRemote(remote) => Command::new("git")
|
|
|
|
GitCommand::IsValidRemote(remote) => Command::new("git")
|
|
|
|
.arg("ls-remote")
|
|
|
|
.arg("ls-remote")
|
|
|
|
.arg("--get-url")
|
|
|
|
.arg("--get-url")
|
|
|
|