-
-
Notifications
You must be signed in to change notification settings - Fork 339
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(tasks): add commit sha to snapshots to make sure submodules are…
… not outdated closes #2819
- Loading branch information
Showing
22 changed files
with
117 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
use std::{ | ||
borrow::Cow, | ||
env, | ||
fs::{self, File}, | ||
io::Write, | ||
path::{Path, PathBuf}, | ||
process::Command, | ||
}; | ||
|
||
pub struct Snapshot { | ||
git_repo_path: PathBuf, | ||
sha: Option<String>, | ||
} | ||
|
||
impl Snapshot { | ||
/// # Panics | ||
/// | ||
/// * Git operation fails | ||
pub fn new(git_repo_path: &Path, show_commit: bool) -> Self { | ||
let sha = show_commit.then(|| { | ||
let path = git_repo_path.to_str().unwrap(); | ||
let output = Command::new("git") | ||
.args(["-C", path, "rev-parse", "--short", "HEAD"]) | ||
.output() | ||
.unwrap() | ||
.stdout; | ||
String::from_utf8(output).unwrap().trim().to_string() | ||
}); | ||
Self { git_repo_path: git_repo_path.to_path_buf(), sha } | ||
} | ||
|
||
/// # Panics | ||
/// | ||
/// * File operation fails | ||
pub fn save(&self, path: &Path, content: &str) { | ||
let content = if let Some(new_sha) = &self.sha { | ||
if path.exists() { | ||
let file = fs::read_to_string(path).unwrap(); | ||
let line = | ||
file.lines().next().unwrap_or_else(|| panic!("{path:?} content is empty.")); | ||
if let Some(old_sha) = line.strip_prefix("commit: ") { | ||
let outdated = new_sha != old_sha && env::var("UPDATE_SNAPSHOT").is_err(); | ||
assert!( | ||
!outdated, | ||
"\nRepository {:?} is outdated for {path:?}.\nPlease run `just submodules` to update it.\n", | ||
self.git_repo_path | ||
); | ||
} | ||
} | ||
Cow::Owned(format!("commit: {new_sha}\n\n{content}")) | ||
} else { | ||
Cow::Borrowed(content) | ||
}; | ||
|
||
let mut file = File::create(path).unwrap(); | ||
file.write_all(content.as_bytes()).unwrap(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
commit: 4bd1b2c2f1 | ||
|
||
codegen_babel Summary: | ||
AST Parsed : 2099/2099 (100.00%) | ||
Positive Passed: 2099/2099 (100.00%) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
commit: 17ba9aea47 | ||
|
||
codegen_test262 Summary: | ||
AST Parsed : 45836/45836 (100.00%) | ||
Positive Passed: 45836/45836 (100.00%) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
commit: 4bd1b2c2f1 | ||
|
||
minifier_babel Summary: | ||
AST Parsed : 1638/1638 (100.00%) | ||
Positive Passed: 1638/1638 (100.00%) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
commit: 17ba9aea47 | ||
|
||
minifier_test262 Summary: | ||
AST Parsed : 45836/45836 (100.00%) | ||
Positive Passed: 45836/45836 (100.00%) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
commit: 4bd1b2c2f1 | ||
|
||
parser_babel Summary: | ||
AST Parsed : 2093/2099 (99.71%) | ||
Positive Passed: 2086/2099 (99.38%) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
commit: 4bd1b2c2f1 | ||
|
||
prettier_babel Summary: | ||
AST Parsed : 2099/2099 (100.00%) | ||
Positive Passed: 1893/2099 (90.19%) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
commit: 4bd1b2c2f1 | ||
|
||
transformer_babel Summary: | ||
AST Parsed : 2099/2099 (100.00%) | ||
Positive Passed: 2099/2099 (100.00%) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
commit: 17ba9aea47 | ||
|
||
transformer_test262 Summary: | ||
AST Parsed : 45836/45836 (100.00%) | ||
Positive Passed: 45836/45836 (100.00%) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
commit: 64d2eeea7b | ||
|
||
transformer_typescript Summary: | ||
AST Parsed : 5243/5243 (100.00%) | ||
Positive Passed: 5243/5243 (100.00%) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
commit: 4bd1b2c2f1 | ||
|
||
Passed: 308/362 | ||
|
||
# All Passed: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
commit: 4bd1b2c2f1 | ||
|
||
Passed: 1/3 | ||
|
||
# All Passed: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
commit: 4bd1b2c2f1 | ||
|
||
Passed: 2/2 | ||
|
||
# All Passed: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
commit: 4bd1b2c2f1 | ||
|
||
Passed: 0/0 | ||
|
||
# All Passed: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters