Skip to content

Commit ba3934b

Browse files
author
nicos_backbase
committed
refactor: consolidate github api
1 parent d18ce02 commit ba3934b

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

src/commands/pr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ impl Command for PrCommand {
7070
async move {
7171
(
7272
repo.name.clone(),
73-
github::create_pull_request(&repo, &pr_options).await,
73+
github::create_pr_from_workspace(&repo, &pr_options).await,
7474
)
7575
}
7676
})
@@ -88,7 +88,7 @@ impl Command for PrCommand {
8888
}
8989
} else {
9090
for repo in repositories {
91-
match github::create_pull_request(&repo, &pr_options).await {
91+
match github::create_pr_from_workspace(&repo, &pr_options).await {
9292
Ok(_) => successful += 1,
9393
Err(e) => {
9494
eprintln!(

src/github/api.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,13 @@ use anyhow::Result;
99
use colored::*;
1010
use uuid::Uuid;
1111

12-
/// Create a pull request for a repository
13-
pub async fn create_pull_request(repo: &Repository, options: &PrOptions) -> Result<()> {
12+
/// High-level function to create a PR from local changes
13+
///
14+
/// This function encapsulates the entire pull request creation flow:
15+
/// 1. Check for changes in the workspace
16+
/// 2. Create branch, add, commit, and push changes
17+
/// 3. Create GitHub PR via API
18+
pub async fn create_pr_from_workspace(repo: &Repository, options: &PrOptions) -> Result<()> {
1419
let repo_path = repo.get_target_dir();
1520

1621
// Check if repository has changes

src/github/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ pub mod client;
66
pub mod types;
77

88
// Re-export commonly used items for convenience
9-
pub use api::create_pull_request;
9+
pub use api::create_pr_from_workspace;
1010
pub use auth::GitHubAuth;
1111
pub use client::GitHubClient;
1212
pub use types::{PrOptions, PullRequestParams};

tests/github_api_tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! GitHub API tests focusing on PR creation functionality
22
33
use repos::config::Repository;
4-
use repos::github::api::create_pull_request;
4+
use repos::github::api::create_pr_from_workspace;
55
use repos::github::types::PrOptions;
66
use std::fs;
77
use std::path::PathBuf;
@@ -54,7 +54,7 @@ async fn test_create_pull_request_no_changes() {
5454
);
5555

5656
// Should succeed with no changes (just prints a message and returns Ok)
57-
let result = create_pull_request(&repo, &options).await;
57+
let result = create_pr_from_workspace(&repo, &options).await;
5858
assert!(result.is_ok());
5959
}
6060

0 commit comments

Comments
 (0)