Compare commits

..

No commits in common. "main" and "v0.5.0" have entirely different histories.
main ... v0.5.0

14 changed files with 373 additions and 453 deletions

View File

@ -6,14 +6,13 @@ jobs:
build_deb:
name: Build .deb package
runs-on: ubuntu-latest
env:
RUSTFLAGS: "-C strip=debuginfo"
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- run: cargo install cargo-deb
- run: cargo build --release
- run: ./prepare-release.sh
- run: cargo deb
- uses: actions/upload-artifact@v4
- uses: actions/upload-artifact@v3
with:
path: target/debian/*.deb

View File

@ -1,6 +1,4 @@
on:
- push
- workflow_dispatch
on: push
name: CI
@ -9,7 +7,7 @@ jobs:
name: lint and test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt
@ -23,8 +21,6 @@ jobs:
needs: lint_and_test
if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/build-') }}
name: Build package
env:
RUSTFLAGS: "-C strip=debuginfo"
strategy:
matrix:
os:
@ -33,21 +29,15 @@ jobs:
# - windows-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
- uses: Swatinem/rust-cache@v2
- run: cargo build --release
- name: prepare release artifact
shell: bash
run: |
mkdir -p target/{bin,man}
cp target/release/*.1 target/man
cp target/release/git-{mob,solo,{add,edit,delete}-coauthor} target/bin
- uses: actions/upload-artifact@v4
- run: ./prepare-release.sh
- uses: actions/upload-artifact@v3
with:
name: git-mob-${{ matrix.os }}
path: |
target/bin
target/man
ci-release/git-mob

668
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
[package]
name = "git-mob"
version = "0.6.0"
version = "0.5.0"
authors = [ "Martin Frost <martin@frost.ws>" ]
edition = "2018"
description = "A CLI tool for social coding."
@ -10,17 +10,17 @@ repository = "https://github.com/Frost/git-mob"
readme = "README.md"
[dependencies]
git2 = { version = "0.19", default-features = false }
dirs = "4.0"
git2 = { version = "0.17", default-features = false }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
clap = { version = "~4.5", features = ["derive"] }
clap = { version = "~4.2", features = ["derive"] }
clap_mangen = "~0.2"
env_home = "0.1.0"
[build-dependencies]
clap_mangen = "~0.2"
clap = { version = "~4.5", features = ["derive"]}
clap_complete = "~4.5"
clap = { version = "~4.2", features = ["derive"]}
clap_complete = "~4.2"
[package.metadata.deb]
name = "git-mob"
@ -30,15 +30,15 @@ priority = "optional"
extended-description = """\
A set of git subcommands for including co-authors to your git commits."""
assets = [
["target/release/git-mob", "usr/bin/", "755"],
["target/release/git-solo", "usr/bin/", "755"],
["target/release/git-add-coauthor", "usr/bin/", "755"],
["target/release/git-edit-coauthor", "usr/bin/", "755"],
["target/release/git-delete-coauthor", "usr/bin/", "755"],
["target/release/git-mob.1", "usr/share/man/man1/", "644"],
["target/release/git-solo.1", "usr/share/man/man1/", "644"],
["target/release/git-add-coauthor.1", "usr/share/man/man1/", "644"],
["target/release/git-edit-coauthor.1", "usr/share/man/man1/", "644"],
["target/release/git-delete-coauthor.1", "usr/share/man/man1/", "644"],
["ci-release/bin/git-mob", "usr/bin/", "755"],
["ci-release/bin/git-solo", "usr/bin/", "755"],
["ci-release/bin/git-add-coauthor", "usr/bin/", "755"],
["ci-release/bin/git-edit-coauthor", "usr/bin/", "755"],
["ci-release/bin/git-delete-coauthor", "usr/bin/", "755"],
["ci-release/man/git-mob.1.gz", "usr/share/man/man1/", "644"],
["ci-release/man/git-solo.1.gz", "usr/share/man/man1/", "644"],
["ci-release/man/git-add-coauthor.1.gz", "usr/share/man/man1/", "644"],
["ci-release/man/git-edit-coauthor.1.gz", "usr/share/man/man1/", "644"],
["ci-release/man/git-delete-coauthor.1.gz", "usr/share/man/man1/", "644"],
["README.md", "usr/share/doc/git-mob/README", "644"],
]

View File

@ -6,26 +6,44 @@ use std::path::Path;
#[path = "src/cli.rs"]
mod cli;
macro_rules! generate_manpage {
($struct:ident) => {
let target_dir = env::var("CARGO_TARGET_DIR").unwrap_or("target".to_string());
let output_dir = Path::new(&target_dir).join(env::var("PROFILE").unwrap());
let cmd = cli::$struct::command();
let cmd_name = format!("{}.1", cmd.get_name());
let man = Man::new(cmd);
let mut buffer: Vec<u8> = Default::default();
man.render(&mut buffer)?;
std::fs::write(output_dir.join(cmd_name), buffer)?;
};
}
fn main() -> std::io::Result<()> {
generate_manpage!(GitMob);
generate_manpage!(GitSolo);
generate_manpage!(GitAddCoauthor);
generate_manpage!(GitEditCoauthor);
generate_manpage!(GitDeleteCoauthor);
let target_dir = env::var("CARGO_TARGET_DIR").unwrap_or("target".to_string());
let output_dir = Path::new(&target_dir).join(env::var("PROFILE").unwrap());
// git-mob docs
let cmd = cli::GitMob::command();
let man = Man::new(cmd);
let mut buffer: Vec<u8> = Default::default();
man.render(&mut buffer)?;
std::fs::write(output_dir.join("git-mob.1"), buffer)?;
// git-solo docs
let cmd = cli::GitSolo::command();
let man = Man::new(cmd);
let mut buffer: Vec<u8> = Default::default();
man.render(&mut buffer)?;
std::fs::write(output_dir.join("git-solo.1"), buffer)?;
// git-add-coauthor docs
let cmd = cli::GitAddCoauthor::command();
let man = Man::new(cmd);
let mut buffer: Vec<u8> = Default::default();
man.render(&mut buffer)?;
std::fs::write(output_dir.join("git-add-coauthor.1"), buffer)?;
// git-edit-coauthor docs
let cmd = cli::GitEditCoauthor::command();
let man = Man::new(cmd);
let mut buffer: Vec<u8> = Default::default();
man.render(&mut buffer)?;
std::fs::write(output_dir.join("git-edit-coauthor.1"), buffer)?;
// git-delete-coauthor docs
let cmd = cli::GitDeleteCoauthor::command();
let man = Man::new(cmd);
let mut buffer: Vec<u8> = Default::default();
man.render(&mut buffer)?;
std::fs::write(output_dir.join("git-delete-coauthor.1"), buffer)?;
Ok(())
}

3
docs/git-add-coauthor.md Normal file
View File

@ -0,0 +1,3 @@
# git-add-coauthor
<!-- `$ cargo run --bin git-add-coauthor -- --help` -->

View File

@ -0,0 +1,3 @@
# git-delete-coauthor
<!-- `$ cargo run --bin git-delete-coauthor -- --help` -->

View File

@ -0,0 +1,3 @@
# git-edit-coauthor
<!-- `$ cargo run --bin git-edit-coauthor -- --help` -->

3
docs/git-mob.md Normal file
View File

@ -0,0 +1,3 @@
# git-mob
<!-- `$ cargo run --bin git-mob -- --help` -->

3
docs/git-solo.md Normal file
View File

@ -0,0 +1,3 @@
# git-solo
<!-- `$ cargo run --bin git-solo -- --help` -->

12
prepare-release.sh Executable file
View File

@ -0,0 +1,12 @@
#!/usr/bin/env bash
set -e
OUT_DIR=ci-release/git-mob
mkdir -p $OUT_DIR/{bin,man}
for binary in git-{mob,solo,{add,edit,delete}-coauthor}; do
gzip --to-stdout target/release/$binary.1 > $OUT_DIR/man/$binary.gz
cp target/release/$binary $OUT_DIR/bin/$binary
cp README.md $OUT_DIR/README.md
done

View File

@ -25,7 +25,7 @@ fn main() {
fn list_coauthors() {
for (abbrev, author) in &get_available_coauthors() {
println!("{abbrev}\t{author}");
println!("{}\t{}", abbrev, author);
}
}
@ -34,7 +34,7 @@ fn override_main_author(initials: &str) {
match all_authors.get(initials) {
Some(new_main_author) => set_main_author(new_main_author),
None => {
eprintln!("Error: author with initials {initials} not found");
eprintln!("Error: author with initials {} not found", initials);
process::exit(1);
}
}
@ -51,11 +51,11 @@ fn write_coauthors_to_gitmessage_file(coauthor_initials: &[String]) {
Ok(_) => {
println!("{}", get_main_author());
for author in &coauthors {
println!("{author}");
println!("{}", author);
}
}
Err(e) => {
eprintln!("Error writing to .gitmessage template: {e}");
eprintln!("Error writing to .gitmessage template: {}", e);
process::exit(1);
}
});
@ -69,7 +69,7 @@ fn select_coauthors(coauthor_initials: &[String]) -> Vec<Author> {
match all_coauthors.get(initial) {
Some(coauthor) => coauthors.push(coauthor.clone()),
None => {
eprintln!("Error: author with initials {initial} not found");
eprintln!("Error: author with initials {} not found", initial);
process::exit(1);
}
}

View File

@ -7,7 +7,7 @@ use std::fs::File;
fn main() {
let _opt = cli::GitSolo::parse();
let main_author = get_main_author();
println!("{main_author}");
println!("{}", main_author);
with_gitmessage_template_path_or_exit(|path| {
let _template = File::create(path);

View File

@ -1,4 +1,4 @@
use env_home::env_home_dir as home_dir;
use dirs::home_dir;
use git2::{Config, Repository};
use serde::{Deserialize, Serialize};
use std::collections::BTreeMap;