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