mirror of
https://git.alemi.dev/tci.git
synced 2024-12-18 09:44:53 +01:00
Compare commits
2 commits
e0e3041db7
...
4b8c1a6476
Author | SHA1 | Date | |
---|---|---|---|
4b8c1a6476 | |||
92ea79333e |
2 changed files with 10 additions and 5 deletions
|
@ -4,6 +4,7 @@ pub struct TciRepo {
|
|||
pub path: std::path::PathBuf,
|
||||
pub cfg: git2::Config,
|
||||
pub refs: Vec<String>,
|
||||
pub ci_branch: Option<String>,
|
||||
}
|
||||
|
||||
impl TciRepo {
|
||||
|
@ -31,7 +32,9 @@ impl TciRepo {
|
|||
|
||||
let cfg = git2::Config::open(&path.join("config"))?;
|
||||
|
||||
Ok(TciRepo { name, path, cfg, refs })
|
||||
let ci_branch = cfg.get_string("tci.branch").ok();
|
||||
|
||||
Ok(TciRepo { name, path, cfg, refs, ci_branch })
|
||||
}
|
||||
|
||||
pub fn updated(&self, search: &str) -> bool {
|
||||
|
|
10
src/tci.rs
10
src/tci.rs
|
@ -24,13 +24,12 @@ impl Tci {
|
|||
return false; // we are in whitelist mode and this repo is not whitelisted
|
||||
}
|
||||
|
||||
if let Ok(repo_branch) = self.repo.cfg.get_str("tci.branch") {
|
||||
return self.repo.updated(repo_branch);
|
||||
if let Some(repo_branch) = &self.repo.ci_branch {
|
||||
return self.repo.updated(&repo_branch);
|
||||
}
|
||||
|
||||
match self.cfg.branch.as_deref() {
|
||||
None => self.repo.updated("tci"),
|
||||
Some("") => true,
|
||||
Some(b) => self.repo.updated(b),
|
||||
}
|
||||
}
|
||||
|
@ -66,10 +65,13 @@ impl Tci {
|
|||
&format!("tci-{}", self.repo.name.replace('/', "_"))
|
||||
)?;
|
||||
|
||||
let clone_branch = self.repo.ci_branch.as_deref()
|
||||
.unwrap_or_else(|| self.cfg.branch.as_deref().unwrap_or("tci"));
|
||||
|
||||
// TODO recursive clone? automatically clone all submodules after?
|
||||
git2::build::RepoBuilder::new()
|
||||
.bare(false)
|
||||
.branch("tci")
|
||||
.branch(clone_branch)
|
||||
.clone(
|
||||
self.repo.path.to_str()
|
||||
.ok_or(TciErr::FsError("repo path is not a valid string"))?,
|
||||
|
|
Loading…
Reference in a new issue