зеркало из https://github.com/github/codeql.git
Rust: use shared path utilities
This commit is contained in:
Родитель
aae33db137
Коммит
89a8cbc536
|
@ -1,4 +1,4 @@
|
|||
use crate::path;
|
||||
use codeql_extractor::file_paths;
|
||||
use log::{debug, warn};
|
||||
use std::fs;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
@ -15,12 +15,11 @@ impl Archiver {
|
|||
}
|
||||
|
||||
fn try_archive(&self, source: &Path) -> std::io::Result<()> {
|
||||
let mut dest = self.root.clone();
|
||||
dest.push(path::key(source));
|
||||
let parent = dest.parent().unwrap();
|
||||
let dest = file_paths::path_for(&self.root, source, "");
|
||||
if fs::metadata(&dest).is_ok() {
|
||||
return Ok(());
|
||||
}
|
||||
let parent = dest.parent().unwrap();
|
||||
fs::create_dir_all(parent)?;
|
||||
fs::copy(source, dest)?;
|
||||
debug!("archived {}", source.display());
|
||||
|
|
|
@ -11,7 +11,6 @@ use std::path::PathBuf;
|
|||
mod archive;
|
||||
mod config;
|
||||
pub mod generated;
|
||||
pub mod path;
|
||||
mod translate;
|
||||
pub mod trap;
|
||||
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
use std::fs::canonicalize;
|
||||
use std::path::{absolute, Path, PathBuf};
|
||||
|
||||
pub fn key(p: &Path) -> PathBuf {
|
||||
let normalized = canonicalize(p)
|
||||
.or_else(|_| absolute(p))
|
||||
.unwrap_or_else(|_| p.into());
|
||||
let root = normalized.ancestors().last().unwrap(); // ancestors always yields at least one
|
||||
normalized.strip_prefix(root).unwrap().into() // stripping an ancestor always works
|
||||
}
|
|
@ -1,9 +1,8 @@
|
|||
use crate::config;
|
||||
use crate::config::Compression;
|
||||
use crate::{config, path};
|
||||
use codeql_extractor::{extractor, trap};
|
||||
use codeql_extractor::{extractor, file_paths, trap};
|
||||
use log::debug;
|
||||
use ra_ap_ide_db::line_index::LineCol;
|
||||
use std::ffi::OsString;
|
||||
use std::fmt::Debug;
|
||||
use std::hash::Hash;
|
||||
use std::marker::PhantomData;
|
||||
|
@ -12,7 +11,6 @@ use std::path::{Path, PathBuf};
|
|||
pub use trap::Label as UntypedLabel;
|
||||
pub use trap::Writer;
|
||||
|
||||
//TODO: typed labels
|
||||
pub trait AsTrapKeyPart {
|
||||
fn as_key_part(&self) -> String;
|
||||
}
|
||||
|
@ -210,19 +208,8 @@ impl TrapFileProvider {
|
|||
}
|
||||
|
||||
pub fn create(&self, category: &str, key: &Path) -> TrapFile {
|
||||
let mut path = PathBuf::from(category);
|
||||
path.push(path::key(key));
|
||||
path.set_extension(
|
||||
path.extension()
|
||||
.map(|e| {
|
||||
let mut o: OsString = e.to_owned();
|
||||
o.push(".trap");
|
||||
o
|
||||
})
|
||||
.unwrap_or("trap".into()),
|
||||
);
|
||||
let path = file_paths::path_for(&self.trap_dir.join(category), key, ".trap");
|
||||
debug!("creating trap file {}", path.display());
|
||||
path = self.trap_dir.join(path);
|
||||
let mut writer = trap::Writer::new();
|
||||
extractor::populate_empty_location(&mut writer);
|
||||
TrapFile {
|
||||
|
|
|
@ -12,7 +12,7 @@ assert cargo, "no cargo binary found on `PATH`"
|
|||
|
||||
fmt = subprocess.run([cargo, "fmt", "--all", "--quiet"], cwd=this_dir)
|
||||
for manifest in this_dir.rglob("Cargo.toml"):
|
||||
if not manifest.is_relative_to(this_dir / "ql"):
|
||||
if not manifest.is_relative_to(this_dir / "ql") and not manifest.is_relative_to(this_dir / "integration-tests"):
|
||||
clippy = subprocess.run([cargo, "clippy", "--fix", "--allow-dirty", "--allow-staged", "--quiet"],
|
||||
cwd=manifest.parent)
|
||||
sys.exit(fmt.returncode or clippy.returncode)
|
||||
|
|
Загрузка…
Ссылка в новой задаче