Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
radumarias committed Sep 23, 2024
1 parent a8790cb commit c459bb9
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 3 deletions.
47 changes: 47 additions & 0 deletions check-before-push.bat
Original file line number Diff line number Diff line change
@@ -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%

Expand Down Expand Up @@ -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%
Expand Down
40 changes: 40 additions & 0 deletions check-before-push.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
10 changes: 8 additions & 2 deletions src/mount/linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1084,7 +1084,10 @@ impl Filesystem for EncryptedFsFuse3 {
}
}

type DirEntryStream<'a> = Iter<Skip<DirectoryEntryIterator>> where Self: 'a;
type DirEntryStream<'a>
= Iter<Skip<DirectoryEntryIterator>>
where
Self: 'a;

#[instrument(skip(self), err(level = Level::DEBUG))]
async fn readdir(
Expand Down Expand Up @@ -1175,7 +1178,10 @@ impl Filesystem for EncryptedFsFuse3 {
})
}

type DirEntryPlusStream<'a> = Iter<Skip<DirectoryEntryPlusIterator>> where Self: 'a;
type DirEntryPlusStream<'a>
= Iter<Skip<DirectoryEntryPlusIterator>>
where
Self: 'a;

#[instrument(skip(self), err(level = Level::DEBUG))]
async fn readdirplus(
Expand Down
3 changes: 2 additions & 1 deletion src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<SecretString> {
unsafe {
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit c459bb9

Please sign in to comment.