diff --git a/check-before-push.bat b/check-before-push.bat index af317d0..c75f8ec 100755 --- a/check-before-push.bat +++ b/check-before-push.bat @@ -1,8 +1,49 @@ @echo off +setlocal + set CARGO_TERM_COLOR=always set RUSTFLAGS=-Dwarnings set RUSTDOCFLAGS=-Dwarnings +:: Filepath to the Cargo.toml file +set "CARGO_FILE=Cargo.toml" +set "BACKUP_FILE=Cargo_backup.txt" + +:: Function to add -dryRun to the version +:add_dryrun_to_version +if exist "%CARGO_FILE%" ( + findstr /r "^version\s*=\s*\"[0-9\.]*\"" "%CARGO_FILE%" >nul + if errorlevel 1 ( + echo No version found in the file. + goto :eof + ) + + copy /y "%CARGO_FILE%" "%BACKUP_FILE%" >nul + + for /f "tokens=3 delims== " %%A in ('findstr /r "^version\s*=\s*\"[0-9\.]*\"" "%CARGO_FILE%"') do ( + set "ORIGINAL_VERSION=%%~A" + set "MODIFIED_VERSION=%ORIGINAL_VERSION:~0,-1%-dryRun" + ) + + powershell -Command "(Get-Content -Raw '%CARGO_FILE%') -replace 'version = \"%ORIGINAL_VERSION%\"', 'version = \"%MODIFIED_VERSION%\"' | Set-Content '%CARGO_FILE%'" + + echo Version modified to: %MODIFIED_VERSION% +) else ( + echo Cargo.toml file not found! +) +goto :eof + +:: Function to revert the version to its original state by restoring from backup +:revert_version +if exist "%BACKUP_FILE%" ( + copy /y "%BACKUP_FILE%" "%CARGO_FILE%" >nul + del /f "%BACKUP_FILE%" + echo Cargo.toml reverted to the original version. +) else ( + echo Backup file not found! Cannot revert. +) +goto :eof + cargo fmt --all if %errorlevel% neq 0 exit /b %errorlevel% @@ -30,9 +71,15 @@ if %errorlevel% neq 0 exit /b %errorlevel% cargo doc --workspace --all-features --no-deps if %errorlevel% neq 0 exit /b %errorlevel% +call :add_dryrun_to_version +if %errorlevel% neq 0 exit /b %errorlevel% + cargo publish --dry-run --allow-dirty if %errorlevel% neq 0 exit /b %errorlevel% +call :revert_version +if %errorlevel% neq 0 exit /b %errorlevel% + cd java-bridge cargo fmt --all if %errorlevel% neq 0 exit /b %errorlevel% diff --git a/check-before-push.sh b/check-before-push.sh index 62df25f..b10232b 100755 --- a/check-before-push.sh +++ b/check-before-push.sh @@ -6,6 +6,42 @@ export CARGO_TERM_COLOR=always export RUSTFLAGS="-Dwarnings" export RUSTDOCFLAGS="-Dwarnings" +# Filepath to the Cargo.toml file +CARGO_FILE="Cargo.toml" +BACKUP_FILE="Cargo_backup.txt" + +# Function to add -dryRun to the version +add_dryrun_to_version() { + if [[ -f $CARGO_FILE ]]; then + # Backup the original Cargo.toml before modification + cp "$CARGO_FILE" "$BACKUP_FILE" + + # Extract the current version from the file + ORIGINAL_VERSION=$(grep -oP '^version\s*=\s*"\K[^\"]+' "$CARGO_FILE") + + if [[ -n $ORIGINAL_VERSION ]]; then + # Modify the version and write it back to the Cargo.toml file + sed -i "s/version = \"$ORIGINAL_VERSION\"/version = \"$ORIGINAL_VERSION-dryRun\"/" "$CARGO_FILE" + echo "Version modified to: $ORIGINAL_VERSION-dryRun" + else + echo "No version found in the file." + fi + else + echo "Cargo.toml file not found!" + fi +} + +# Function to revert the version to its original state by restoring from backup +revert_version() { + if [[ -f $BACKUP_FILE ]]; then + # Restore the original Cargo.toml from the backup + mv "$BACKUP_FILE" "$CARGO_FILE" + echo "Cargo.toml reverted to the original version." + else + echo "Backup file not found! Cannot revert." + fi +} + cargo fmt --all cargo build --all-targets --all-features --target x86_64-unknown-linux-gnu @@ -22,7 +58,11 @@ cargo clippy --all-targets --release --target x86_64-unknown-linux-gnu -- \ -A clippy::type_complexity cargo test --release --all --all-features --target x86_64-unknown-linux-gnu cargo doc --workspace --all-features --no-deps --target x86_64-unknown-linux-gnu + +add_dryrun_to_version cargo publish --dry-run --allow-dirty --target x86_64-unknown-linux-gnu +revert_version + cargo aur cargo generate-rpm diff --git a/src/mount/linux.rs b/src/mount/linux.rs index d6d3cc9..f65c779 100644 --- a/src/mount/linux.rs +++ b/src/mount/linux.rs @@ -1084,7 +1084,10 @@ impl Filesystem for EncryptedFsFuse3 { } } - type DirEntryStream<'a> = Iter> where Self: 'a; + type DirEntryStream<'a> + = Iter> + where + Self: 'a; #[instrument(skip(self), err(level = Level::DEBUG))] async fn readdir( @@ -1175,7 +1178,10 @@ impl Filesystem for EncryptedFsFuse3 { }) } - type DirEntryPlusStream<'a> = Iter> where Self: 'a; + type DirEntryPlusStream<'a> + = Iter> + where + Self: 'a; #[instrument(skip(self), err(level = Level::DEBUG))] async fn readdirplus( diff --git a/src/run.rs b/src/run.rs index 01b7ae6..ab84b7f 100644 --- a/src/run.rs +++ b/src/run.rs @@ -321,9 +321,9 @@ async fn run_mount(cipher: Cipher, matches: &ArgMatches) -> Result<()> { }); } - #[allow(clippy::items_after_statements)] struct PasswordProviderImpl {} #[allow(clippy::items_after_statements)] + #[allow(static_mut_refs)] impl PasswordProvider for PasswordProviderImpl { fn get_password(&self) -> Option { unsafe { @@ -406,6 +406,7 @@ async fn run_mount(cipher: Cipher, matches: &ArgMatches) -> Result<()> { Ok(()) } +#[allow(static_mut_refs)] fn remove_pass() { unsafe { if PASS.is_none() {