refactor: only get timestamp if necessary
This commit is contained in:
parent
fae0549aa9
commit
fae04bd975
18
src/main.rs
18
src/main.rs
|
@ -209,7 +209,7 @@ fn unlock_key_file(path: &str, check_secrets: bool, return_password: bool) -> Re
|
|||
Err(keyring::Error::NoEntry) => {}
|
||||
Err(e) => {
|
||||
eprintln!("warn: could not get saved password for key {}: {:#}", key_id, e);
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -462,16 +462,6 @@ fn main() -> Result<()> {
|
|||
break;
|
||||
}
|
||||
|
||||
let timestamp = if gpg.is_some() || seq_key.is_some() {
|
||||
timestamp.load(Ordering::SeqCst)
|
||||
} else {
|
||||
match method {
|
||||
Method::Decrement => timestamp.fetch_sub(1, Ordering::SeqCst) - 1,
|
||||
Method::Increment => timestamp.fetch_add(1, Ordering::SeqCst) + 1,
|
||||
_ => timestamp.load(Ordering::SeqCst),
|
||||
}
|
||||
};
|
||||
|
||||
let append = if gpg.is_some() || seq_key.is_some() {
|
||||
None
|
||||
} else {
|
||||
|
@ -490,6 +480,12 @@ fn main() -> Result<()> {
|
|||
};
|
||||
|
||||
if matches!(method, Method::Increment | Method::Decrement) {
|
||||
let timestamp = match method {
|
||||
Method::Decrement => timestamp.fetch_sub(1, Ordering::SeqCst) - 1,
|
||||
Method::Increment => timestamp.fetch_add(1, Ordering::SeqCst) + 1,
|
||||
_ => timestamp.load(Ordering::SeqCst),
|
||||
};
|
||||
|
||||
author_parts[author_len - 2] = buffer.format(timestamp).to_owned();
|
||||
committer_parts[committer_len - 2] = buffer.format(timestamp).to_owned();
|
||||
|
||||
|
|
Loading…
Reference in New Issue