summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main.rs99
1 files changed, 76 insertions, 23 deletions
diff --git a/src/main.rs b/src/main.rs
index 7cdcbaa..a73421c 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -350,24 +350,26 @@ impl VersionPattern {
return CompareOutcome::Incompatible;
}
+ let mut state = CompareOutcome::Identical;
for (self_part, other_part) in self.parts.iter().zip(other.parts.iter()) {
- match (self_part, other_part) {
- (VersionPart::String(x1), VersionPart::String(x2)) => if x1 != x2 { return CompareOutcome::Incompatible },
- (VersionPart::String(_), _) => return CompareOutcome::Incompatible,
- (VersionPart::Number(x1), VersionPart::Number(x2)) => {
+ match (&state, self_part, other_part) {
+ (_, VersionPart::String(x1), VersionPart::String(x2)) => if x1 != x2 { return CompareOutcome::Incompatible },
+ (_, VersionPart::String(_), _) => return CompareOutcome::Incompatible,
+ (CompareOutcome::Identical, VersionPart::Number(x1), VersionPart::Number(x2)) => {
if x1 > x2 {
- return CompareOutcome::Lower
- } else if x1 > x2 {
- return CompareOutcome::Higher
+ state = CompareOutcome::Lower;
+ } else if x1 < x2 {
+ state = CompareOutcome::Higher;
}
},
- (VersionPart::Number(_), _) => return CompareOutcome::Incompatible,
- (VersionPart::Hash, VersionPart::Hash) => {},
- (VersionPart::Hash, _) => return CompareOutcome::Incompatible,
+ (_, VersionPart::Number(_), VersionPart::Number(_)) => {},
+ (_, VersionPart::Number(_), _) => return CompareOutcome::Incompatible,
+ (_, VersionPart::Hash, VersionPart::Hash) => {},
+ (_, VersionPart::Hash, _) => return CompareOutcome::Incompatible,
}
}
- return CompareOutcome::Identical;
+ return state;
}
}
@@ -741,21 +743,71 @@ fn main() {
}
for repo in &repos {
- let mut gitcmd = std::process::Command::new("git");
+ if repo.dest.exists() {
+ let mut gitcmd = std::process::Command::new("git");
- gitcmd
- .arg("clone")
- .arg(&repo.url)
- .arg(&repo.dest);
+ gitcmd
+ .arg("-C")
+ .arg(&repo.dest)
+ .arg("fetch")
+ .arg("origin");
- if let Some(key) = &repo.key {
- gitcmd.env("GIT_SSH_COMMAND", format!("ssh -F none -o IdentitiesOnly=yes -i \"{}\"", key.to_str().unwrap()));
- }
+ if let Some(key) = &repo.key {
+ gitcmd.env("GIT_SSH_COMMAND", format!("ssh -F none -o IdentitiesOnly=yes -i \"{}\"", key.to_str().unwrap()));
+ }
+ let exit = gitcmd.status()
+ .expect("Git command failed");
+ if !exit.success() {
+ panic!("Git exited with failure");
+ }
- let exit = gitcmd.status()
- .expect("Git command failed");
- if !exit.success() {
- panic!("Git exited with failure");
+ let mut gitcmd = std::process::Command::new("git");
+
+ gitcmd
+ .arg("-C")
+ .arg(&repo.dest)
+ .arg("reset")
+ .arg("--hard")
+ .arg("@{u}");
+
+ let exit = gitcmd.status()
+ .expect("Git command failed");
+ if !exit.success() {
+ panic!("Git exited with failure");
+ }
+
+ let mut gitcmd = std::process::Command::new("git");
+
+ gitcmd
+ .arg("-C")
+ .arg(&repo.dest)
+ .arg("clean")
+ .arg("--force")
+ .arg("-d")
+ .arg("-x");
+
+ let exit = gitcmd.status()
+ .expect("Git command failed");
+ if !exit.success() {
+ panic!("Git exited with failure");
+ }
+ } else {
+ let mut gitcmd = std::process::Command::new("git");
+
+ gitcmd
+ .arg("clone")
+ .arg(&repo.url)
+ .arg(&repo.dest);
+
+ if let Some(key) = &repo.key {
+ gitcmd.env("GIT_SSH_COMMAND", format!("ssh -F none -o IdentitiesOnly=yes -i \"{}\"", key.to_str().unwrap()));
+ }
+
+ let exit = gitcmd.status()
+ .expect("Git command failed");
+ if !exit.success() {
+ panic!("Git exited with failure");
+ }
}
infile_paths.push(repo.dest.clone());
@@ -802,6 +854,7 @@ fn main() {
let mut edits = vec![];
for ref image in images.image_tags {
+ println!("Checking image {}", &file_content[image.clone()]);
let image_ref = DockerRef::parse(&file_content, image);
if let Err(msg) = update_images(&file_content, &mut auth, image_ref, &mut edits) {
failed = Some(msg);