index : gitrs
A lightweight web interface for browsing Git repositories, implemented in Rust
about summary refs log tree commit diff

Diffstat

-rw-r--r-- Cargo.lock 2
-rw-r--r-- Cargo.toml 2
-rw-r--r-- README.md 12
-rw-r--r-- build.rs 6
-rw-r--r-- git-rs.service 16
-rw-r--r-- gitrs.service 16
-rw-r--r-- justfile 8
-rw-r--r-- src/cli.rs 6
-rw-r--r-- src/main.rs 8
-rw-r--r-- templates/base.html 2
-rw-r--r-- templates/macros.html 2
-rw-r--r-- src/routes/repository/diff.rs 2
 12 files changed, 41 insertions(+), 41 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock
index 16443c8..a3f3ef0 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -903,7 +903,7 @@
]

[[package]]
name = "git-rs"
name = "gitrs"
version = "0.1.0"
dependencies = [
 "actix-web",
diff --git a/Cargo.toml b/Cargo.toml
index ec13600..387730a 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,5 +1,5 @@
[package]
name = "git-rs"
name = "gitrs"
version = "0.1.0"
edition = "2024"

diff --git a/README.md b/README.md
index 634d3c1..5be18dc 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
# git-rs
# gitrs

A fast, minimal web interface for self-hosted Git repositories, inspired by `cgit` and written in Rust using Actix Web, `gix` (gitoxide), and Askama templates.

@@ -19,10 +19,10 @@

## Usage

By default, `git-rs` reads bare repositories from `/srv/git` and listens on `127.0.0.1:80`:
By default, `gitrs` reads bare repositories from `/srv/git` and listens on `127.0.0.1:80`:

```sh
git-rs --url 0.0.0.0 --port 80 --repos-dir /srv/git
gitrs --url 0.0.0.0 --port 80 --repos-dir /srv/git
```

### Options
@@ -49,7 +49,7 @@

```sh
# From crates.io
cargo install git-rs
cargo install gitrs

# Or from a local checkout
cargo install --path .
@@ -58,9 +58,9 @@
To install and start the `systemd` service:

```sh
sudo $(which git-rs) --install-service --url 0.0.0.0 --port 80 --repos-dir /srv/git
sudo $(which gitrs) --install-service --url 0.0.0.0 --port 80 --repos-dir /srv/git
sudo systemctl daemon-reload
sudo systemctl enable --now git-rs
sudo systemctl enable --now gitrs
```

## License
diff --git a/build.rs b/build.rs
index 70178a3..3bbaf5e 100644
--- a/build.rs
+++ b/build.rs
@@ -4,11 +4,11 @@
    println!("cargo:rerun-if-changed=src");
    println!("cargo:rerun-if-changed=templates");
    println!("cargo:rerun-if-changed=static");
    println!("cargo:rerun-if-changed=git-rs.service");
    println!("cargo:rerun-if-changed=gitrs.service");

    // When running `cargo install` (release profile) with permissions to write to
    // /etc/systemd/system, automatically install git-rs.service.
    // /etc/systemd/system, automatically install gitrs.service.
    if std::env::var("PROFILE").as_deref() == Ok("release") {
        let _ = std::fs::copy("git-rs.service", "/etc/systemd/system/git-rs.service");
        let _ = std::fs::copy("gitrs.service", "/etc/systemd/system/gitrs.service");
    }
}
diff --git a/git-rs.service b/git-rs.service
deleted file mode 100644
index 1814be5..0000000 100644
--- a/git-rs.service
+++ /dev/null
@@ -1,16 +1,0 @@
[Unit]
Description=git-rs — Lightweight Git web frontend
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
User=root
WorkingDirectory=/srv/git
ExecStart=/usr/bin/git-rs --url 0.0.0.0 --port 80 --repos-dir /srv/git
Restart=on-failure
RestartSec=5
AmbientCapabilities=CAP_NET_BIND_SERVICE

[Install]
WantedBy=multi-user.target
diff --git a/gitrs.service b/gitrs.service
new file mode 100644
index 0000000..2bcf86c 100644
--- /dev/null
+++ b/gitrs.service
@@ -1,0 +1,16 @@
[Unit]
Description=gitrs — Lightweight Git web frontend
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
User=root
WorkingDirectory=/srv/git
ExecStart=/usr/bin/gitrs --url 0.0.0.0 --port 80 --repos-dir /srv/git
Restart=on-failure
RestartSec=5
AmbientCapabilities=CAP_NET_BIND_SERVICE

[Install]
WantedBy=multi-user.target
diff --git a/justfile b/justfile
index b94382e..f894d57 100644
--- a/justfile
+++ b/justfile
@@ -17,10 +17,10 @@

# Build and deploy ARM64 binary + systemd service to Orange Pi
deploy host="pi": build-arm
    ssh {{host}} "systemctl stop git-rs || true"
    scp target/{{arm_target}}/release/git-rs {{host}}:/usr/bin/git-rs
    # scp git-rs.service {{host}}:/etc/systemd/system/git-rs.service
    ssh {{host}} "systemctl daemon-reload && systemctl start git-rs"
    ssh {{host}} "systemctl stop gitrs || true"
    scp target/{{arm_target}}/release/gitrs {{host}}:/usr/bin/gitrs
    # scp gitrs.service {{host}}:/etc/systemd/system/gitrs.service
    ssh {{host}} "systemctl daemon-reload && systemctl start gitrs"

# Run locally (e.g. `just run -p 8080 -r ./repos`)
run *args:
diff --git a/src/cli.rs b/src/cli.rs
index 172b22e..ecf3d69 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -2,10 +2,10 @@

#[derive(Parser)]
#[command(
    name = "rsgit",
    name = "gitrs",
    version,
    about = "A lightweight, blazingly fast Git web frontend written in Rust 🦀",
    long_about = "rsgit is a minimalist web interface for scouting and browsing local Git repositories, viewing diffs, and managing user patches natively."
    long_about = "gitrs is a minimalist web interface for scouting and browsing local Git repositories, viewing diffs, and managing user patches natively."
)]
pub struct Args {
    /// The URL where the frontend is hosted (e.g., 127.0.0.1 or 0.0.0.0 for the public)
@@ -20,7 +20,7 @@
    #[arg(short, long, value_name = "DIR", default_value = "/srv/git")]
    pub repos_dir: String,

    /// Install and enable the systemd service (/etc/systemd/system/git-rs.service)
    /// Install and enable the systemd service (/etc/systemd/system/gitrs.service)
    #[arg(long)]
    pub install_service: bool,
}
diff --git a/src/main.rs b/src/main.rs
index 9913e79..9c53edf 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -54,7 +54,7 @@
    let exe = std::env::current_exe()?;
    let service = format!(
        "[Unit]\n\
         Description=git-rs — Lightweight Git web frontend\n\
         Description=gitrs — Lightweight Git web frontend\n\
         After=network-online.target\n\
         Wants=network-online.target\n\
         \n\
@@ -75,8 +75,8 @@
        repos_dir = args.repos_dir,
    );

    std::fs::write("/etc/systemd/system/git-rs.service", service)?;
    println!("Installed /etc/systemd/system/git-rs.service");
    std::fs::write("/etc/systemd/system/gitrs.service", service)?;
    println!("Installed /etc/systemd/system/gitrs.service");
    Ok(())
}

@@ -123,7 +123,7 @@
    #[test]
    fn markdown_escapes_attribute_injections_in_media() {
        let md = "![demo & test](https://github.com/user-attachments/assets/1234?a=1&b=2)";
        let html = markdown::render(md, "git-rs", "main");
        let html = markdown::render(md, "gitrs", "main");
        assert!(html.contains(r#"alt="demo & test""#));
        assert!(
            html.contains(r#"src="https://github.com/user-attachments/assets/1234?a=1&b=2""#)
diff --git a/templates/base.html b/templates/base.html
index e0c93ca..e1877ca 100644
--- a/templates/base.html
+++ b/templates/base.html
@@ -5,7 +5,7 @@
  <head>
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <title>{% block title %}rsgit{% endblock %}</title>
      <title>{% block title %}gitrs{% endblock %}</title>
      <link rel="stylesheet" href="/static/style.css">
      <link rel="shortcut icon" href="/static/favicon.ico">
  </head>
diff --git a/templates/macros.html b/templates/macros.html
index 7047cff..c8c48af 100644
--- a/templates/macros.html
+++ b/templates/macros.html
@@ -23,7 +23,7 @@
      <td class="main">y2w8 Repos</td>
    </tr>
    <tr>
      <td class="sub">y2w8 git repositories, powered by rsgit</td>
      <td class="sub">y2w8 git repositories, powered by gitrs</td>
    </tr>
  {% endif %}
{% endmacro %}
diff --git a/src/routes/repository/diff.rs b/src/routes/repository/diff.rs
index b8da47f..a12107f 100644
--- a/src/routes/repository/diff.rs
+++ b/src/routes/repository/diff.rs
@@ -80,7 +80,7 @@
    data.extend_from_slice(b"\n");
    data.extend_from_slice(diff.output.as_bytes());

    writeln!(data, "--\ngit-rs {}", crate_version!())?;
    writeln!(data, "--\ngitrs {}", crate_version!())?;

    Ok(HttpResponse::Ok().content_type("text").body(data))
}