Get rid of repo module
This commit is contained in:
parent
2be929ec94
commit
0146bcb016
3 changed files with 11 additions and 17 deletions
|
|
@ -1,7 +1,6 @@
|
||||||
mod config;
|
mod config;
|
||||||
mod db;
|
mod db;
|
||||||
mod recurring;
|
mod recurring;
|
||||||
mod repo;
|
|
||||||
mod somehow;
|
mod somehow;
|
||||||
mod state;
|
mod state;
|
||||||
mod web;
|
mod web;
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,13 @@ use std::collections::HashSet;
|
||||||
|
|
||||||
use futures::TryStreamExt;
|
use futures::TryStreamExt;
|
||||||
use gix::{
|
use gix::{
|
||||||
date::time::format::ISO8601_STRICT, objs::Kind, refs::Reference, Commit, ObjectId, Repository,
|
actor::IdentityRef, date::time::format::ISO8601_STRICT, objs::Kind, refs::Reference, Commit,
|
||||||
|
ObjectId, Repository,
|
||||||
};
|
};
|
||||||
use sqlx::{Acquire, SqliteConnection, SqlitePool};
|
use sqlx::{Acquire, SqliteConnection, SqlitePool};
|
||||||
use tracing::{debug, info};
|
use tracing::{debug, info};
|
||||||
|
|
||||||
use crate::{repo, somehow};
|
use crate::somehow;
|
||||||
|
|
||||||
async fn get_all_commit_hashes_from_db(
|
async fn get_all_commit_hashes_from_db(
|
||||||
conn: &mut SqliteConnection,
|
conn: &mut SqliteConnection,
|
||||||
|
|
@ -60,6 +61,12 @@ fn get_new_commits_from_repo<'a, 'b: 'a>(
|
||||||
Ok(new)
|
Ok(new)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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())
|
||||||
|
}
|
||||||
|
|
||||||
async fn insert_new_commits(
|
async fn insert_new_commits(
|
||||||
conn: &mut SqliteConnection,
|
conn: &mut SqliteConnection,
|
||||||
new: &[Commit<'_>],
|
new: &[Commit<'_>],
|
||||||
|
|
@ -67,10 +74,10 @@ async fn insert_new_commits(
|
||||||
for commit in new {
|
for commit in new {
|
||||||
let hash = commit.id.to_string();
|
let hash = commit.id.to_string();
|
||||||
let author_info = commit.author()?;
|
let author_info = commit.author()?;
|
||||||
let author = repo::format_actor(author_info.actor())?;
|
let author = format_actor(author_info.actor())?;
|
||||||
let author_date = author_info.time.format(ISO8601_STRICT);
|
let author_date = author_info.time.format(ISO8601_STRICT);
|
||||||
let committer_info = commit.committer()?;
|
let committer_info = commit.committer()?;
|
||||||
let committer = repo::format_actor(committer_info.actor())?;
|
let committer = format_actor(committer_info.actor())?;
|
||||||
let committer_date = committer_info.time.format(ISO8601_STRICT);
|
let committer_date = committer_info.time.format(ISO8601_STRICT);
|
||||||
let message = commit.message_raw()?.to_string();
|
let message = commit.message_raw()?.to_string();
|
||||||
|
|
||||||
|
|
|
||||||
12
src/repo.rs
12
src/repo.rs
|
|
@ -1,12 +0,0 @@
|
||||||
//! Utility functions for accessing a [`Repository`].
|
|
||||||
|
|
||||||
use gix::actor::IdentityRef;
|
|
||||||
|
|
||||||
use crate::somehow;
|
|
||||||
|
|
||||||
// TODO Remove this function
|
|
||||||
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())
|
|
||||||
}
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue