Skip to content

Commit c342259

Browse files
authored
Merge pull request #5 from jnises/clap
1.4.9
2 parents 17f33d9 + 26e4f8f commit c342259

File tree

5 files changed

+72
-104
lines changed

5 files changed

+72
-104
lines changed

.github/workflows/release.yml

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ on:
77

88
jobs:
99
win_build:
10-
runs-on: windows-2019
10+
runs-on: windows-2022
1111
steps:
12-
- uses: actions/checkout@v2
13-
- uses: actions/cache@v2
12+
- uses: actions/checkout@v3
13+
- uses: actions/cache@v3
1414
with:
1515
path: |
1616
~/.cargo/bin/
@@ -27,16 +27,16 @@ jobs:
2727
run: |
2828
cargo build --release
2929
mv target/release/git-suggest-reviewers.exe git-suggest-reviewers_win_x64.exe
30-
- uses: actions/upload-artifact@v2
30+
- uses: actions/upload-artifact@v3
3131
with:
3232
name: git-suggest-reviewers_win_x64.exe
3333
path: git-suggest-reviewers_win_x64.exe
3434

3535
mac_build:
36-
runs-on: macos-11
36+
runs-on: macos-12
3737
steps:
38-
- uses: actions/checkout@v2
39-
- uses: actions/cache@v2
38+
- uses: actions/checkout@v3
39+
- uses: actions/cache@v3
4040
with:
4141
path: |
4242
~/.cargo/bin/
@@ -56,17 +56,18 @@ jobs:
5656
ARTIFACT="target/x86_64-apple-darwin/release/git-suggest-reviewers"
5757
strip -S "$ARTIFACT"
5858
ditto -c -k --sequesterRsrc "$ARTIFACT" git-suggest-reviewers_mac_x64.zip
59-
- uses: actions/upload-artifact@v2
59+
- uses: actions/upload-artifact@v3
6060
with:
6161
name: git-suggest-reviewers_mac_x64.zip
6262
path: git-suggest-reviewers_mac_x64.zip
6363
- name: Build aarch64
64+
# getting sdk using xcrun to cross compile. is this still needed these days?
6465
run: |
65-
SDKROOT=$(xcrun -sdk macosx11.1 --show-sdk-path) MACOSX_DEPLOYMENT_TARGET=$(xcrun -sdk macosx11.1 --show-sdk-platform-version) cargo build --release --target aarch64-apple-darwin
66+
SDKROOT=$(xcrun -sdk macosx12.3 --show-sdk-path) MACOSX_DEPLOYMENT_TARGET=$(xcrun -sdk macosx11.1 --show-sdk-platform-version) cargo build --release --target aarch64-apple-darwin
6667
ARTIFACT="target/aarch64-apple-darwin/release/git-suggest-reviewers"
6768
strip -S "$ARTIFACT"
6869
ditto -c -k --sequesterRsrc "$ARTIFACT" git-suggest-reviewers_mac_aarch64.zip
69-
- uses: actions/upload-artifact@v2
70+
- uses: actions/upload-artifact@v3
7071
with:
7172
name: git-suggest-reviewers_mac_aarch64.zip
7273
path: git-suggest-reviewers_mac_aarch64.zip
@@ -75,13 +76,13 @@ jobs:
7576
needs: [win_build, mac_build]
7677
runs-on: ubuntu-latest
7778
steps:
78-
- uses: actions/download-artifact@v2
79+
- uses: actions/download-artifact@v3
7980
with:
8081
name: git-suggest-reviewers_mac_x64.zip
81-
- uses: actions/download-artifact@v2
82+
- uses: actions/download-artifact@v3
8283
with:
8384
name: git-suggest-reviewers_mac_aarch64.zip
84-
- uses: actions/download-artifact@v2
85+
- uses: actions/download-artifact@v3
8586
with:
8687
name: git-suggest-reviewers_win_x64.exe
8788
# zip the win build here.

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ jobs:
1515
runs-on: ubuntu-latest
1616

1717
steps:
18-
- uses: actions/checkout@v2
19-
- uses: actions/cache@v2
18+
- uses: actions/checkout@v3
19+
- uses: actions/cache@v3
2020
with:
2121
path: |
2222
~/.cargo/bin/

Cargo.lock

Lines changed: 40 additions & 75 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "git-suggest-reviewers"
3-
version = "1.4.8"
3+
version = "1.4.9"
44
authors = ["Joel Nises <[email protected]>"]
55
edition = "2021"
66

@@ -9,7 +9,7 @@ lto = true
99

1010
[dependencies]
1111
anyhow = "1.0"
12-
structopt = "0.3"
12+
clap = { version = "4.0", features = ["derive"] }
1313
log = "0.4"
1414
stderrlog = "0.5"
1515
indicatif = "0.17"

src/main.rs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
// #![warn(missing_debug_implementations, rust_2018_idoms, clippy:all)]
22
use anyhow::{Context, Result};
3+
use clap::Parser;
34
use git2::{BlameOptions, Diff, DiffFindOptions, DiffOptions, FileMode, Oid, Patch, Repository};
45
use indicatif::{ProgressBar, ProgressStyle};
56
use log::{debug, info, warn};
67
use rayon::prelude::*;
78
use std::{cell::RefCell, cmp, collections::HashMap};
8-
use structopt::StructOpt;
99
use thread_local::ThreadLocal;
1010

11-
#[derive(Debug, StructOpt)]
12-
#[structopt(
13-
about = "List authors of lines changed by PR, including a few lines around the changed ones."
11+
#[derive(Debug, Parser)]
12+
#[command(
13+
about = "List authors of lines changed by PR, including a few lines around the changed ones.",
14+
author,
15+
version
1416
)]
1517
struct Opt {
1618
/// Where to merge to
@@ -20,23 +22,23 @@ struct Opt {
2022
compare: String,
2123

2224
/// Verbose mode (-v, -vv, -vvv, etc), disables progress bar
23-
#[structopt(short, long, parse(from_occurrences))]
24-
verbose: usize,
25+
#[arg(short, long, action = clap::ArgAction::Count)]
26+
verbose: u8,
2527

2628
/// Don't display a progress bar
27-
#[structopt(long)]
29+
#[arg(long)]
2830
no_progress: bool,
2931

3032
/// How many lines around each modification to count
31-
#[structopt(long, default_value = "1")]
33+
#[arg(long, default_value = "1")]
3234
context: u32,
3335

3436
/// Try not to look further back than this commit when blaming files
35-
#[structopt(long)]
37+
#[arg(long)]
3638
stop_at: Option<String>,
3739

3840
// Maximum number of threads. 0 is auto.
39-
#[structopt(long, short = "j", default_value = "0")]
41+
#[arg(long, short = 'j', default_value = "0")]
4042
max_concurrency: usize,
4143
}
4244

@@ -59,8 +61,8 @@ fn get_diff(repo: &Repository, base: Oid, compare: Oid, context: u32) -> Result<
5961
}
6062

6163
fn main() -> Result<()> {
62-
let opt = Opt::from_args();
63-
stderrlog::new().verbosity(opt.verbose).init()?;
64+
let opt = Opt::parse();
65+
stderrlog::new().verbosity(opt.verbose as usize).init()?;
6466
rayon::ThreadPoolBuilder::new()
6567
.num_threads(opt.max_concurrency)
6668
.build_global()?;

0 commit comments

Comments
 (0)