Revert "Check for pull changes using ORIG_HEAD"
ORIG_HEAD isn't very reliable
This commit is contained in:
@@ -23,22 +23,18 @@ pub struct Repositories<'a> {
|
|||||||
repositories: HashSet<String>,
|
repositories: HashSet<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Checks whether the latest pull command actually pulled something
|
fn get_head_revision(git: &Path, repo: &str) -> Option<String> {
|
||||||
fn did_pull_change(git: &Path, repo: &str) -> bool {
|
|
||||||
Command::new(git)
|
Command::new(git)
|
||||||
.args(&["rev-parse", "HEAD", "ORIG_HEAD"])
|
.args(&["rev-parse", "HEAD"])
|
||||||
.current_dir(repo)
|
.current_dir(repo)
|
||||||
.check_output()
|
.check_output()
|
||||||
.map(|output| {
|
.map(|output| output.trim().to_string())
|
||||||
let mut lines = output.trim().split('\n');
|
|
||||||
lines.next().unwrap() != lines.next().unwrap()
|
|
||||||
})
|
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
error!("Error getting revision for {}: {}", repo, e);
|
error!("Error getting revision for {}: {}", repo, e);
|
||||||
|
|
||||||
e
|
e
|
||||||
})
|
})
|
||||||
.unwrap_or(false)
|
.ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Git {
|
impl Git {
|
||||||
@@ -101,6 +97,7 @@ impl Git {
|
|||||||
.map(|repo| {
|
.map(|repo| {
|
||||||
let repo = repo.clone();
|
let repo = repo.clone();
|
||||||
let path = format!("{}", HumanizedPath::from(std::path::Path::new(&repo)));
|
let path = format!("{}", HumanizedPath::from(std::path::Path::new(&repo)));
|
||||||
|
let before_revision = get_head_revision(git, &repo);
|
||||||
let cloned_git = git.to_owned();
|
let cloned_git = git.to_owned();
|
||||||
|
|
||||||
println!("{} {}", style("Pulling").cyan().bold(), path);
|
println!("{} {}", style("Pulling").cyan().bold(), path);
|
||||||
@@ -112,11 +109,21 @@ impl Git {
|
|||||||
.then(move |result| match result {
|
.then(move |result| match result {
|
||||||
Ok(output) => {
|
Ok(output) => {
|
||||||
if output.status.success() {
|
if output.status.success() {
|
||||||
if did_pull_change(&cloned_git, &repo) {
|
let after_revision = get_head_revision(&cloned_git, &repo);
|
||||||
|
|
||||||
|
if before_revision != after_revision
|
||||||
|
&& after_revision.is_some()
|
||||||
|
&& before_revision.is_some()
|
||||||
|
{
|
||||||
println!("{} {}:", style("Changed").yellow().bold(), path);
|
println!("{} {}:", style("Changed").yellow().bold(), path);
|
||||||
Command::new(&cloned_git)
|
Command::new(&cloned_git)
|
||||||
.current_dir(&repo)
|
.current_dir(&repo)
|
||||||
.args(&["log", "--no-decorate", "--oneline", "ORIG_HEAD.."])
|
.args(&[
|
||||||
|
"log",
|
||||||
|
"--no-decorate",
|
||||||
|
"--oneline",
|
||||||
|
&format!("{}..{}", before_revision.unwrap(), after_revision.unwrap()),
|
||||||
|
])
|
||||||
.spawn()
|
.spawn()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.wait()
|
.wait()
|
||||||
|
|||||||
Reference in New Issue
Block a user