Insert new commits into the queue
This commit is contained in:
parent
553a56bb12
commit
4f11b9c912
10 changed files with 128 additions and 14 deletions
20
src/util.rs
20
src/util.rs
|
|
@ -1,10 +1,22 @@
|
|||
use std::time::Duration;
|
||||
|
||||
use gix::date::Time;
|
||||
use gix::{actor::IdentityRef, date::Time};
|
||||
use rand::{rngs::OsRng, seq::IteratorRandom};
|
||||
use time::{macros::format_description, OffsetDateTime, UtcOffset};
|
||||
|
||||
use crate::somehow;
|
||||
|
||||
const RUN_ID_PREFIX: &str = "r-";
|
||||
const RUN_ID_CHARS: &str = "0123456789abcdefghijklmnopqrstuvwxyz";
|
||||
const RUN_ID_LEN: usize = 30; // log(16^40, base=len(RUN_ID_CHARS)) ~ 31
|
||||
|
||||
pub fn new_run_id() -> String {
|
||||
RUN_ID_PREFIX
|
||||
.chars()
|
||||
.chain((0..RUN_ID_LEN).map(|_| RUN_ID_CHARS.chars().choose(&mut OsRng).unwrap()))
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub fn time_to_offset_datetime(time: Time) -> somehow::Result<OffsetDateTime> {
|
||||
Ok(OffsetDateTime::from_unix_timestamp(time.seconds)?
|
||||
.to_offset(UtcOffset::from_whole_seconds(time.offset)?))
|
||||
|
|
@ -26,6 +38,12 @@ pub fn format_time(time: OffsetDateTime) -> somehow::Result<String> {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn format_actor(author: IdentityRef<'_>) -> somehow::Result<String> {
|
||||
let mut buffer = vec![];
|
||||
author.trim().write_to(&mut buffer)?;
|
||||
Ok(String::from_utf8_lossy(&buffer).to_string())
|
||||
}
|
||||
|
||||
pub fn format_commit_summary(message: &str) -> String {
|
||||
// Take everything up to the first double newline
|
||||
let title = message
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue