Skip to content

Commit

Permalink
Remove dependency on rust-ini
Browse files Browse the repository at this point in the history
  • Loading branch information
w4 committed Jan 8, 2025
1 parent dd440d9 commit 6a76f81
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 94 deletions.
72 changes: 0 additions & 72 deletions Cargo.lock

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

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ rkyv = { version = "0.8", features = [
"alloc",
], default-features = false }
rocksdb = { version = "0.22", default-features = false, features = ["snappy"] }
rust-ini = "0.21.1"
serde = { version = "1.0", features = ["derive", "rc"] }
simdutf8 = "0.1.5"
tar = { version = "0.4", default-features = false }
Expand Down
32 changes: 11 additions & 21 deletions src/database/indexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use std::{

use anyhow::Context;
use gix::{bstr::ByteSlice, refs::Category, Reference};
use ini::Ini;
use itertools::Itertools;
use rocksdb::WriteBatch;
use time::{OffsetDateTime, UtcOffset};
Expand Down Expand Up @@ -70,11 +69,16 @@ fn update_repository_metadata(scan_path: &Path, db: &rocksdb::DB) {
.ok()
.filter(|v| !v.is_empty());

let owner = git_repository
.config_snapshot()
.string("gitweb.owner")
.map(|v| v.to_string());

let res = Repository {
id,
name: name.to_string(),
description,
owner: find_gitweb_owner(repository_path.as_path()),
owner,
last_modified: {
let r =
find_last_committed_time(&git_repository).unwrap_or(OffsetDateTime::UNIX_EPOCH);
Expand Down Expand Up @@ -104,16 +108,11 @@ fn find_last_committed_time(repo: &gix::Repository) -> Result<OffsetDateTime, an
};

let committer = commit.committer()?;
let mut committed_time = OffsetDateTime::from_unix_timestamp(committer.time.seconds)
.unwrap_or(OffsetDateTime::UNIX_EPOCH);

if let Ok(offset) = UtcOffset::from_whole_seconds(committer.time.offset) {
committed_time = committed_time.to_offset(offset);
}

if committed_time > timestamp {
timestamp = committed_time;
}
let offset = UtcOffset::from_whole_seconds(committer.time.offset).unwrap_or(UtcOffset::UTC);
let committed_time = OffsetDateTime::from_unix_timestamp(committer.time.seconds)
.unwrap_or(OffsetDateTime::UNIX_EPOCH)
.to_offset(offset);
timestamp = timestamp.max(committed_time);
}

Ok(timestamp)
Expand Down Expand Up @@ -431,12 +430,3 @@ fn discover_repositories(current: &Path, discovered_repos: &mut Vec<(PathBuf, gi
}
}
}

fn find_gitweb_owner(repository_path: &Path) -> Option<String> {
// Load the Git config file and attempt to extract the owner from the "gitweb" section.
// If the owner is not found, an empty string is returned.
Ini::load_from_file(repository_path.join("config"))
.ok()?
.section_mut(Some("gitweb"))
.and_then(|section| section.remove("owner"))
}

0 comments on commit 6a76f81

Please sign in to comment.