-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Stash working tree before running hooks (#96)
* Add test * Fix test * add signal test * Fix test * Fix tests * Fix tests
- Loading branch information
Showing
9 changed files
with
423 additions
and
54 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
use std::sync::Mutex; | ||
|
||
static CLEANUP_HOOKS: Mutex<Vec<Box<dyn Fn() + Send>>> = Mutex::new(Vec::new()); | ||
|
||
/// Run all cleanup functions. | ||
pub fn cleanup() { | ||
let mut cleanup = CLEANUP_HOOKS.lock().unwrap(); | ||
for f in cleanup.drain(..) { | ||
f(); | ||
} | ||
} | ||
|
||
/// Add a cleanup function to be run when the program is interrupted. | ||
pub fn add_cleanup<F: Fn() + Send + 'static>(f: F) { | ||
let mut cleanup = CLEANUP_HOOKS.lock().unwrap(); | ||
cleanup.push(Box::new(f)); | ||
} |
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
Oops, something went wrong.