Skip to content

Commit fefa094

Browse files
committed
Improve CLI defaults and PR workflow safeguards
1 parent dea400c commit fefa094

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

.github/workflows/diffscope.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ concurrency:
1414
jobs:
1515
review:
1616
runs-on: ubuntu-latest
17-
if: github.event.pull_request.head.repo.full_name == github.repository
17+
if: github.event.pull_request.head.repo.full_name == github.repository && !github.event.pull_request.draft
1818
steps:
1919
- uses: actions/checkout@v4
2020
with:

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ git diff | diffscope smart-review --model claude-3-5-sonnet-20241022
123123
export OPENAI_API_KEY=your-key
124124
git diff | diffscope review --model gpt-4o
125125

126+
# Force OpenAI Responses API usage
127+
git diff | diffscope review --openai-responses true
128+
126129
# Anthropic Claude
127130
export ANTHROPIC_API_KEY=your-key
128131
git diff | diffscope review --model claude-3-5-sonnet-20241022
@@ -482,13 +485,16 @@ diffscope smart-review [--diff file.patch]
482485
# Git integration
483486
diffscope git uncommitted # Review uncommitted changes
484487
diffscope git staged # Review staged changes
485-
diffscope git branch [base] # Compare against branch (default: main)
488+
diffscope git branch [base] # Compare against branch (default: repo default)
486489
diffscope git suggest # Generate commit messages
487490
diffscope git pr-title # Generate PR titles
488491

489492
# Pull request operations
490493
diffscope pr [--number N] [--post-comments] [--summary]
491494

495+
# Repository check (uncommitted changes at path)
496+
diffscope check [path]
497+
492498
# File comparison
493499
diffscope compare --old-file old.py --new-file new.py
494500

src/main.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ struct Cli {
3131
#[arg(long, global = true)]
3232
max_tokens: Option<usize>,
3333

34+
#[arg(long, global = true, value_parser = clap::value_parser!(bool))]
35+
openai_responses: Option<bool>,
36+
3437
#[arg(long, global = true, default_value = "json")]
3538
output_format: OutputFormat,
3639

@@ -115,8 +118,8 @@ enum GitCommands {
115118
Uncommitted,
116119
Staged,
117120
Branch {
118-
#[arg(default_value = "main")]
119-
base: String,
121+
#[arg(help = "Base branch/ref (defaults to repo default)")]
122+
base: Option<String>,
120123
},
121124
Suggest,
122125
PrTitle,
@@ -152,6 +155,9 @@ async fn main() -> Result<()> {
152155
if let Some(tokens) = cli.max_tokens {
153156
config.max_tokens = tokens;
154157
}
158+
if let Some(flag) = cli.openai_responses {
159+
config.openai_use_responses = Some(flag);
160+
}
155161
config.normalize();
156162

157163
match cli.command {
@@ -397,8 +403,12 @@ async fn git_command(
397403
git.get_staged_diff()?
398404
}
399405
GitCommands::Branch { base } => {
400-
info!("Analyzing changes from branch: {}", base);
401-
git.get_branch_diff(&base)?
406+
let base_branch = base.unwrap_or_else(|| {
407+
git.get_default_branch()
408+
.unwrap_or_else(|_| "main".to_string())
409+
});
410+
info!("Analyzing changes from branch: {}", base_branch);
411+
git.get_branch_diff(&base_branch)?
402412
}
403413
GitCommands::Suggest => {
404414
return suggest_commit_message(config).await;

0 commit comments

Comments
 (0)