Unverified Commit f474294b authored by david-perez's avatar david-perez Committed by GitHub
Browse files

Run lints against changed VCS files once (#2093)

We're currently running the lints against changed files twice, causing
some output lines to be duplicated.

Switch to `git ls-files`, which can list files in the index and the
working (staged and unstaged), as well as unignored untracked files.
parent b17a8675
Loading
Loading
Loading
Loading
+9 −12
Original line number Diff line number Diff line
@@ -65,20 +65,17 @@ enum Args {
}

fn load_vcs_files() -> Result<Vec<PathBuf>> {
    let tracked_files = Command::new("git")
        .arg("ls-tree")
        .arg("-r")
        .arg("HEAD")
        .arg("--name-only")
    // This includes files in the index and the working tree (staged or unstaged), as well as
    // unignored untracked files.
    let vcs_files = Command::new("git")
        .arg("ls-files")
        .arg("--cached")
        .arg("--others")
        .arg("--exclude-standard")
        .current_dir(load_repo_root()?)
        .output()
        .context("couldn't load VCS tracked files")?;
    let mut output = String::from_utf8(tracked_files.stdout)?;
    let changed_files = Command::new("git")
        .arg("diff")
        .arg("--name-only")
        .output()?;
    output.push_str(std::str::from_utf8(changed_files.stdout.as_slice())?);
        .context("couldn't load VCS files")?;
    let output = String::from_utf8(vcs_files.stdout)?;
    let files = output
        .lines()
        .map(|line| PathBuf::from(line.trim().to_string()));