Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/review-api-docs-on-merge-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
bal run -- incremental \
../../current-repo \
../.claude/commands/review-docs.md \
--commit-sha ${{ github.sha }}
${{ github.sha }}
else
# Full review
bal run -- full \
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/review-api-docs-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
bal run -- incremental \
../../target-repo \
../.claude/commands/review-docs.md \
--commit-sha "$TARGET_SHA"
"$TARGET_SHA"

echo "Review complete with state tracking"

Expand Down
38 changes: 14 additions & 24 deletions api_doc_reviewer/main.bal
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
// It supports both full and incremental review modes.
//
// Usage:
// bal run -- full <repo-path> <prompt-file> [--dry-run]
// bal run -- incremental <repo-path> <prompt-file> --commit-sha <sha> [--dry-run]
// bal run -- full <repo-path> <prompt-file> [dry-run]
// bal run -- incremental <repo-path> <prompt-file> <commit-sha> [dry-run]

import ballerina/file;
import ballerina/http;
Expand Down Expand Up @@ -306,14 +306,14 @@ function runIncrementalReview(string repoPath, string promptFile, string commitS
function printUsage() {
io:println("Usage:");
io:println(" Full review:");
io:println(" bal run -- full <repo-path> <prompt-file> [--dry-run]");
io:println(" bal run -- full <repo-path> <prompt-file> [dry-run]");
io:println();
io:println(" Incremental review:");
io:println(" bal run -- incremental <repo-path> <prompt-file> --commit-sha <sha> [--dry-run]");
io:println(" bal run -- incremental <repo-path> <prompt-file> <commit-sha> [dry-run]");
io:println();
io:println("Options:");
io:println(" --dry-run Preview what would be reviewed without making changes");
io:println(" --commit-sha Git commit SHA for incremental review tracking (required for incremental mode)");
io:println(" dry-run Preview what would be reviewed without making changes");
io:println(" <commit-sha> Git commit SHA for incremental review tracking (required for incremental mode)");
}

// Main function
Expand Down Expand Up @@ -346,31 +346,21 @@ public function main(string... args) returns error? {
return error("Prompt file not found");
}

// Parse additional options
boolean dryRun = false;
string commitSha = "";

int i = 3;
while i < args.length() {
string arg = args[i];
if arg == "--dry-run" {
dryRun = true;
} else if arg == "--commit-sha" && i + 1 < args.length() {
commitSha = args[i + 1];
i += 1;
}
i += 1;
}

// Route to appropriate mode
if mode == "full" {
// Parse optional dry-run flag for full mode
boolean dryRun = args.length() > 3 && args[3] == "dry-run";
check runFullReview(repoPath, promptFile, dryRun, apiKey);
} else if mode == "incremental" {
if commitSha == "" {
io:println("Error: --commit-sha is required for incremental mode");
// For incremental mode, commit-sha is required as 4th argument
if args.length() < 4 {
io:println("Error: commit-sha is required for incremental mode");
printUsage();
return error("Missing commit-sha");
}
string commitSha = args[3];
// Parse optional dry-run flag for incremental mode
boolean dryRun = args.length() > 4 && args[4] == "dry-run";
check runIncrementalReview(repoPath, promptFile, commitSha, dryRun, apiKey);
} else {
io:println("Error: Invalid mode '" + mode + "'. Must be 'full' or 'incremental'");
Expand Down