🏡 index : ~doyle/rgit.git

author Jordan Doyle <jordan@doyle.la> 2025-01-08 9:51:37.0 +07:00:00
committer Jordan Doyle <jordan@doyle.la> 2025-01-08 9:51:37.0 +07:00:00
commit
6a76f817ba52d7db0d420c31925048f4f7f237a9 [patch]
tree
fec74c8b5b6ae3a3d1d707950668d9b354ce1ad5
parent
dd440d9b8c4e50832996645afb78d8d3a63acbda
download
6a76f817ba52d7db0d420c31925048f4f7f237a9.tar.gz

Remove dependency on rust-ini



Diff

 Cargo.lock              | 72 ------------------------------------------------------------------------
 Cargo.toml              |  1 -
 src/database/indexer.rs | 32 ++++++++++++++------------------
 3 files changed, 11 insertions(+), 94 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock
index 239bd46..5640c36 100644
--- a/Cargo.lock
+++ a/Cargo.lock
@@ -495,26 +495,6 @@
]

[[package]]
name = "const-random"
version = "0.1.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "87e00182fe74b066627d63b85fd550ac2998d4b0bd86bfed477a0ae4c7c71359"
dependencies = [
 "const-random-macro",
]

[[package]]
name = "const-random-macro"
version = "0.1.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f9d839f2a20b0aee515dc581a6172f2321f96cab76c1a38a4c584a194955390e"
dependencies = [
 "getrandom",
 "once_cell",
 "tiny-keccak",
]

[[package]]
name = "const_format"
version = "0.2.33"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -575,12 +555,6 @@
version = "0.8.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80"

[[package]]
name = "crunchy"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7"

[[package]]
name = "crypto-common"
@@ -676,15 +650,6 @@
 "proc-macro2",
 "quote",
 "syn",
]

[[package]]
name = "dlv-list"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "442039f5147480ba31067cb00ada1adae6892028e40e45fc5de7b7df6dcc1b5f"
dependencies = [
 "const-random",
]

[[package]]
@@ -2270,16 +2235,6 @@
checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775"

[[package]]
name = "ordered-multimap"
version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49203cdcae0030493bad186b28da2fa25645fa276a51b6fec8010d281e02ef79"
dependencies = [
 "dlv-list",
 "hashbrown",
]

[[package]]
name = "parking"
version = "2.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2591,7 +2546,6 @@
 "rkyv",
 "rocksdb",
 "rsass",
 "rust-ini",
 "serde",
 "simdutf8",
 "tar",
@@ -2666,17 +2620,6 @@
 "num-rational",
 "num-traits",
 "tracing",
]

[[package]]
name = "rust-ini"
version = "0.21.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4e310ef0e1b6eeb79169a1171daf9abcb87a2e17c03bee2c4bb100b55c75409f"
dependencies = [
 "cfg-if",
 "ordered-multimap",
 "trim-in-place",
]

[[package]]
@@ -3062,15 +3005,6 @@
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1710e589de0a76aaf295cd47a6699f6405737dbfd3cf2b75c92d000b548d0e6"

[[package]]
name = "tiny-keccak"
version = "2.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237"
dependencies = [
 "crunchy",
]

[[package]]
name = "tinystr"
@@ -3294,12 +3228,6 @@
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8ddffe35a0e5eeeadf13ff7350af564c6e73993a24db62caee1822b185c2600"

[[package]]
name = "trim-in-place"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "343e926fc669bc8cde4fa3129ab681c63671bae288b1f1081ceee6d9d37904fc"

[[package]]
name = "triomphe"
diff --git a/Cargo.toml b/Cargo.toml
index 6f93ff9..9744731 100644
--- a/Cargo.toml
+++ a/Cargo.toml
@@ -59,7 +59,6 @@
  "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 }
diff --git a/src/database/indexer.rs b/src/database/indexer.rs
index 6b75cc3..5ca633e 100644
--- a/src/database/indexer.rs
+++ a/src/database/indexer.rs
@@ -8,7 +8,6 @@

use anyhow::Context;
use gix::{bstr::ByteSlice, refs::Category, Reference};
use ini::Ini;
use itertools::Itertools;
use rocksdb::WriteBatch;
use time::{OffsetDateTime, UtcOffset};
@@ -70,11 +69,16 @@
            .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);
@@ -104,16 +108,11 @@
        };

        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)
@@ -430,13 +429,4 @@
            }
        }
    }
}

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"))
}