Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unreproducible release for refinery-core 0.8.13 #323

Closed
paolobarbolini opened this issue Apr 2, 2024 · 2 comments
Closed

Unreproducible release for refinery-core 0.8.13 #323

paolobarbolini opened this issue Apr 2, 2024 · 2 comments

Comments

@paolobarbolini
Copy link

Hi! As part of M4SS-Code/cargo-goggles#11 we're scraping the top 20k crates from crates.io and verifying that the releases can be reproduced from the contents of the git repository. refinery and refinery-macros reproduce fine, we run into a little warning that we can ignore for now. However, refinery-core doesn't reproduce, which can be verified with the following script:

git clone https://github.com/rust-db/refinery.git
cd refinery/
git checkout 0.8.13
cargo package --no-verify --package refinery-core
cd ..
cp refinery/target/package/refinery-core-0.8.13.crate our-release.tar.gz
curl -o upstream.tar.gz --fail "https://static.crates.io/crates/refinery-core/refinery-core-0.8.13.crate"
mkdir our-release
mkdir upstream
tar -xvzf our-release.tar.gz -C our-release
tar -xvzf upstream.tar.gz -C upstream
diff -r our-release upstream

Which yields this diff:

diff -r our-release/refinery-core-0.8.13/.cargo_vcs_info.json upstream/refinery-core-0.8.13/.cargo_vcs_info.json
3c3
<     "sha1": "a20120a6007c5c199f5f84f46324f5a5056ff6c7"
---
>     "sha1": "fd935b3146a5e413822bbe28a8c56b0694a64f85"
diff -r our-release/refinery-core-0.8.13/src/lib.rs upstream/refinery-core-0.8.13/src/lib.rs
12,14c12
< pub use crate::util::{
<     find_migration_files, load_sql_migrations, parse_migration_name, MigrationType,
< };
---
> pub use crate::util::{find_migration_files, load_sql_migrations, MigrationType};
diff -r our-release/refinery-core-0.8.13/src/runner.rs upstream/refinery-core-0.8.13/src/runner.rs
0a1
> use regex::Regex;
8a10
> use std::sync::OnceLock;
9a12
> use crate::error::Kind;
11d13
< use crate::util::parse_migration_name;
14a17,22
> // regex used to match file names
> pub fn file_match_re() -> &'static Regex {
>     static RE: OnceLock<regex::Regex> = OnceLock::new();
>     RE.get_or_init(|| Regex::new(r"^([U|V])(\d+(?:\.\d+)?)__(\w+)").unwrap())
> }
> 
79c87,100
<         let (prefix, version, name) = parse_migration_name(input_name)?;
---
>         let captures = file_match_re()
>             .captures(input_name)
>             .filter(|caps| caps.len() == 4)
>             .ok_or_else(|| Error::new(Kind::InvalidName, None))?;
>         let version: i32 = captures[2]
>             .parse()
>             .map_err(|_| Error::new(Kind::InvalidVersion, None))?;
> 
>         let name: String = (&captures[3]).into();
>         let prefix = match &captures[1] {
>             "V" => Type::Versioned,
>             "U" => Type::Unversioned,
>             _ => unreachable!(),
>         };
107c128
<     pub fn applied(
---
>     pub(crate) fn applied(
126c147
<     pub fn set_applied(&mut self) {
---
>     pub(crate) fn set_applied(&mut self) {
diff -r our-release/refinery-core-0.8.13/src/util.rs upstream/refinery-core-0.8.13/src/util.rs
2d1
< use crate::runner::Type;
7d5
< use std::sync::OnceLock;
10,29d7
< const STEM_RE: &'static str = r"^([U|V])(\d+(?:\.\d+)?)__(\w+)";
< 
< /// Matches the stem of a migration file.
< fn file_stem_re() -> &'static Regex {
<     static RE: OnceLock<Regex> = OnceLock::new();
<     RE.get_or_init(|| Regex::new(STEM_RE).unwrap())
< }
< 
< /// Matches the stem + extension of a SQL migration file.
< fn file_re_sql() -> &'static Regex {
<     static RE: OnceLock<Regex> = OnceLock::new();
<     RE.get_or_init(|| Regex::new([STEM_RE, r"\.sql$"].concat().as_str()).unwrap())
< }
< 
< /// Matches the stem + extension of any migration file.
< fn file_re_all() -> &'static Regex {
<     static RE: OnceLock<Regex> = OnceLock::new();
<     RE.get_or_init(|| Regex::new([STEM_RE, r"\.(rs|sql)$"].concat().as_str()).unwrap())
< }
< 
38,42c16,22
<     fn file_match_re(&self) -> &'static Regex {
<         match self {
<             MigrationType::All => file_re_all(),
<             MigrationType::Sql => file_re_sql(),
<         }
---
>     fn file_match_re(&self) -> Regex {
>         let ext = match self {
>             MigrationType::All => "(rs|sql)",
>             MigrationType::Sql => "sql",
>         };
>         let re_str = format!(r"^(U|V)(\d+(?:\.\d+)?)__(\w+)\.{}$", ext);
>         Regex::new(re_str.as_str()).unwrap()
44,63d23
< }
< 
< /// Parse a migration filename stem into a prefix, version, and name.
< pub fn parse_migration_name(name: &str) -> Result<(Type, i32, String), Error> {
<     let captures = file_stem_re()
<         .captures(name)
<         .filter(|caps| caps.len() == 4)
<         .ok_or_else(|| Error::new(Kind::InvalidName, None))?;
<     let version: i32 = captures[2]
<         .parse()
<         .map_err(|_| Error::new(Kind::InvalidVersion, None))?;
< 
<     let name: String = (&captures[3]).into();
<     let prefix = match &captures[1] {
<         "V" => Type::Versioned,
<         "U" => Type::Unversioned,
<         _ => unreachable!(),
<     };
< 
<     Ok((prefix, version, name))
@jxs
Copy link
Member

jxs commented Apr 3, 2024

Hi Paolo, and thanks for this! I probably released without pulling master I already yanked 0.8.13 and released 0.8.14

@paolobarbolini
Copy link
Author

Looks good now. Thank you for the quick fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants