Skip to content

Commit

Permalink
Merge branch 'alexpovel:main' into rename-lang-to-compiled-query
Browse files Browse the repository at this point in the history
  • Loading branch information
bheylin authored Oct 20, 2024
2 parents ff232f5 + d05f278 commit 212ca28
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 21 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,11 @@ jobs:

runs-on: ubuntu-latest

# Only run this on push events: `pull_request` events will not have access to
# secrets if coming from forks, and we do not care about release chores there
# anyway.
if: github.event_name == 'push'

outputs:
created: ${{ steps.release.outputs.release_created }}
tag_name: ${{ steps.release.outputs.tag_name }}
Expand Down
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.13.2"
".": "0.13.3"
}
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## [0.13.3](https://github.com/alexpovel/srgn/compare/srgn-v0.13.2...srgn-v0.13.3) (2024-10-19)


### Bug Fixes

* **files:** Writing new files works across devices ([1b27825](https://github.com/alexpovel/srgn/commit/1b278251f3aaa273b221f9520512a55ab04bd6cc)), closes [#145](https://github.com/alexpovel/srgn/issues/145)

## [0.13.2](https://github.com/alexpovel/srgn/compare/srgn-v0.13.1...srgn-v0.13.2) (2024-09-27)


Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "srgn"
version = "0.13.2"
version = "0.13.3"
edition = "2021"
authors = ["Alex Povel <[email protected]>"]
description = "A grep-like tool which understands source code syntax and allows for manipulation in addition to search"
Expand Down
1 change: 0 additions & 1 deletion release-please-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"packages": {
".": {}
},
"bootstrap-sha": "22c06f621585a3f872e1677c3b5d1238efec05dc",
"release-type": "rust",
"bump-minor-pre-major": true,
"bump-patch-for-minor-pre-major": true,
Expand Down
22 changes: 5 additions & 17 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//! deals with CLI argument handling, I/O, threading, and more.

use std::error::Error;
use std::fs::File;
use std::fs::{self, File};
use std::io::{self, stdout, Read, Write};
use std::path::{Path, PathBuf};
use std::sync::{Arc, Mutex};
Expand Down Expand Up @@ -609,17 +609,11 @@ fn process_path(
}

if changed {
writeln!(stdout, "{}", path.display())?;

debug!("Got new file contents, writing to file: {:?}", path);
let mut file = tempfile::Builder::new()
.prefix(env!("CARGO_PKG_NAME"))
.tempfile()?;
trace!("Writing to temporary file: {:?}", file.path());
file.write_all(new_contents.as_bytes())?;

// Atomically replace so SIGINT etc. do not leave dangling crap.
file.persist(&path)?;
fs::write(&path, new_contents.as_bytes())?;

// Confirm after successful write.
writeln!(stdout, "{}", path.display())?;
} else {
debug!(
"Skipping writing file anew (nothing changed): {}",
Expand Down Expand Up @@ -845,12 +839,6 @@ impl From<ApplicationError> for PathProcessingError {
}
}

impl From<tempfile::PersistError> for PathProcessingError {
fn from(err: tempfile::PersistError) -> Self {
Self::IoError(err.error, Some(err.file.path().to_owned()))
}
}

impl Error for PathProcessingError {}

#[derive(Debug)]
Expand Down

0 comments on commit 212ca28

Please sign in to comment.