mygit

[UNMAINTAINED] A cgit/webgit alternative, written in Rust
Log | Files | Refs | README | LICENSE

commit 67b63145c37528102bc073da4bedb61fcff40241
parent edee9be2bcdd132e918e3f8176b6ce484726d943
Author: Johann150 <johann@qwertqwefsday.eu>
Date:   Tue, 16 Mar 2021 21:14:05 -0700

As said on the mailing list earlier, I think it would be nice to be
more or less compatible with gitweb since others also orient themselves
on this. One point about this would be to use the same configuration
option names. Of course not all of them are good, e.g. projectroot
does not follow the naming convention, so we might want to change that.
Docs for gitweb config are at <https://git-scm.com/docs/gitweb.conf>.

Diffstat:
Mmygit.toml | 7++++---
Msrc/main.rs | 10++++++----
2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/mygit.toml b/mygit.toml @@ -1,5 +1,6 @@ port = 8081 -# Directory to store git repos -repo_directory = "repos" +# Directory to find git repos +projectroot = "repos" emoji_favicon = "💻" -page_title = "My git repositories" +site_name = "My git repositories" +export_ok = "git-daemon-export-ok" diff --git a/src/main.rs b/src/main.rs @@ -13,8 +13,10 @@ use tide::Request; #[derive(Deserialize, Debug)] pub struct Config { port: u16, - repo_directory: String, + projectroot: String, emoji_favicon: String, + site_name: String, + export_ok: String, } const HELP: &str = "\ @@ -56,14 +58,14 @@ struct IndexTemplate { } async fn index(req: Request<()>) -> tide::Result { - let repos = fs::read_dir(&CONFIG.repo_directory) + let repos = fs::read_dir(&CONFIG.projectroot) .map(|entries| { entries .filter_map(|entry| Some(entry.ok()?.path())) .filter(|entry| { // check for the export file let mut path = entry.clone(); - path.push("git-daemon-export-ok"); + path.push(&CONFIG.export_ok); path.exists() }) .filter_map(|entry| Repository::open(entry).ok()) @@ -93,7 +95,7 @@ fn repo_from_request(repo_name: &str) -> Result<Repository> { let repo_name = percent_encoding::percent_decode_str(repo_name) .decode_utf8_lossy() .into_owned(); - let repo_path = Path::new(&CONFIG.repo_directory).join(repo_name); + let repo_path = Path::new(&CONFIG.projectroot).join(repo_name); // TODO CLEAN PATH! VERY IMPORTANT! DONT FORGET! let r = Repository::open(repo_path)?; Ok(r)