Add branch specifier to git config
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
51f6a3c0de
commit
25f5817873
|
@ -1,6 +1,7 @@
|
|||
[project]
|
||||
kind = "git"
|
||||
repository = "https://gitlab.com/famedly/conduit"
|
||||
branch = "rocksdb"
|
||||
recent = 3
|
||||
language = "rust"
|
||||
config = "Cargo.toml"
|
||||
|
|
|
@ -37,6 +37,7 @@ pub(crate) enum ProjectConfig {
|
|||
#[serde(rename = "git")]
|
||||
Git {
|
||||
repository: String,
|
||||
branch: String,
|
||||
recent: i64,
|
||||
|
||||
#[serde(flatten)]
|
||||
|
|
17
src/git.rs
17
src/git.rs
|
@ -24,6 +24,7 @@ impl<'a> Drop for RemoveOnDrop<'a> {
|
|||
|
||||
#[derive(Debug)]
|
||||
enum GitError {
|
||||
Branch,
|
||||
Clone,
|
||||
Date,
|
||||
}
|
||||
|
@ -31,6 +32,7 @@ enum GitError {
|
|||
impl std::fmt::Display for GitError {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::Branch => write!(f, "Failed to checkout branch"),
|
||||
Self::Clone => write!(f, "Failed to clone repository"),
|
||||
Self::Date => write!(f, "Failed to fetch date from repository"),
|
||||
}
|
||||
|
@ -42,6 +44,7 @@ impl std::error::Error for GitError {}
|
|||
#[tracing::instrument]
|
||||
pub(crate) async fn check_git_project(
|
||||
repository: String,
|
||||
branch: String,
|
||||
recent: i64,
|
||||
language: LanguageConfig,
|
||||
) -> color_eyre::eyre::Result<BuildDirective> {
|
||||
|
@ -57,9 +60,19 @@ pub(crate) async fn check_git_project(
|
|||
return Err(GitError::Clone.into());
|
||||
}
|
||||
|
||||
let git_dir = format!("--git-dir={}/.git", CHECK_REPO);
|
||||
let output = tokio::process::Command::new("git")
|
||||
.args([&git_dir, "show", "-s", "--format=%ci", "HEAD"])
|
||||
.args(["checkout", &branch])
|
||||
.current_dir(CHECK_REPO)
|
||||
.output()
|
||||
.await?;
|
||||
|
||||
if !output.status.success() {
|
||||
return Err(GitError::Branch.into());
|
||||
}
|
||||
|
||||
let output = tokio::process::Command::new("git")
|
||||
.args(["show", "-s", "--format=%ci", "HEAD"])
|
||||
.current_dir(CHECK_REPO)
|
||||
.output()
|
||||
.await?;
|
||||
|
||||
|
|
|
@ -31,8 +31,9 @@ async fn check_project(
|
|||
ProjectConfig::Git {
|
||||
repository,
|
||||
recent,
|
||||
branch,
|
||||
language,
|
||||
} => check_git_project(repository, recent, language).await,
|
||||
} => check_git_project(repository, branch, recent, language).await,
|
||||
ProjectConfig::Alpine {
|
||||
package,
|
||||
branch,
|
||||
|
|
Loading…
Reference in a new issue