Add vibe code logs and fix repo searching (org vs user)
All checks were successful
Cargo Build & Test / Rust project - latest (1.90) (push) Successful in 3m3s
All checks were successful
Cargo Build & Test / Rust project - latest (1.90) (push) Successful in 3m3s
``` │ Agent powering down. Goodbye! │ │ Interaction Summary │ Session ID: d1261c5c-d812-4036-b57e-d188bdef12c4 │ Tool Calls: 30 ( ✓ 29 x 1 ) │ Success Rate: 96.7% │ User Agreement: 100.0% (30 reviewed) │ Code Changes: +124 -21 │ │ Performance │ Wall Time: 25m 19s │ Agent Active: 14m 11s │ » API Time: 5m 37s (39.6%) │ » Tool Time: 8m 33s (60.4%) │ │ │ Model Usage Reqs Input Tokens Cache Reads Output Tokens │ ──────────────────────────────────────────────────────────────────────────── │ gemini-2.5-flash-lite 4 8,739 0 371 │ gemini-3-pro-preview 24 218,346 1,111,266 4,682 │ gemini-2.5-flash 6 13,785 0 784 │ gemini-3-flash-preview 8 110,392 328,221 1,703 │ │ Savings Highlight: 1,439,487 (80.4%) of input tokens were served from the cache, reducing costs. ```
This commit is contained in:
40
src/main.rs
40
src/main.rs
@@ -5,7 +5,6 @@ use std::fs;
|
||||
use std::io::{self, Write};
|
||||
use std::path::{Path, PathBuf};
|
||||
use tracing::{Level, error, info, instrument, warn};
|
||||
use tracing_subscriber;
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
#[command(name = "gitea-mirror")]
|
||||
@@ -262,7 +261,7 @@ fn load_config(path: &Path) -> Result<Config, Box<dyn std::error::Error>> {
|
||||
}
|
||||
|
||||
fn extract_repo_name(url: &str) -> Option<&str> {
|
||||
url.split('/').last().map(|s| s.trim_end_matches(".git"))
|
||||
url.split('/').next_back().map(|s| s.trim_end_matches(".git"))
|
||||
}
|
||||
|
||||
// --- API Calls ---
|
||||
@@ -290,20 +289,36 @@ async fn fetch_all_target_repos(
|
||||
gitea_url: &str,
|
||||
api_key: &str,
|
||||
owner: &str,
|
||||
) -> Result<Vec<String>, Box<dyn std::error::Error>> {
|
||||
let org_url = format!("{}/api/v1/orgs/{}/repos", gitea_url, owner);
|
||||
match fetch_repos_from_endpoint(client, &org_url, api_key).await {
|
||||
Ok(repos) => Ok(repos),
|
||||
Err(e) => {
|
||||
if e.downcast_ref::<reqwest::Error>()
|
||||
.is_some_and(|r| r.status() == Some(reqwest::StatusCode::NOT_FOUND))
|
||||
{
|
||||
info!("Owner '{}' not found as org, trying as user...", owner);
|
||||
let user_url = format!("{}/api/v1/users/{}/repos", gitea_url, owner);
|
||||
return fetch_repos_from_endpoint(client, &user_url, api_key).await;
|
||||
}
|
||||
Err(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async fn fetch_repos_from_endpoint(
|
||||
client: &reqwest::Client,
|
||||
url: &str,
|
||||
api_key: &str,
|
||||
) -> Result<Vec<String>, Box<dyn std::error::Error>> {
|
||||
let mut names = Vec::new();
|
||||
let mut page = 1;
|
||||
let base_url = format!("{}/api/v1/repos/search", gitea_url);
|
||||
|
||||
loop {
|
||||
let params = [
|
||||
("owner", owner),
|
||||
("limit", "50"),
|
||||
("page", &page.to_string()),
|
||||
];
|
||||
let params = [("limit", "50"), ("page", &page.to_string())];
|
||||
|
||||
let res = client
|
||||
.get(&base_url)
|
||||
.get(url)
|
||||
.bearer_auth(api_key)
|
||||
.query(¶ms)
|
||||
.send()
|
||||
@@ -311,10 +326,7 @@ async fn fetch_all_target_repos(
|
||||
.error_for_status()?;
|
||||
|
||||
let json: serde_json::Value = res.json().await?;
|
||||
let data = json
|
||||
.get("data")
|
||||
.and_then(|d| d.as_array())
|
||||
.ok_or("Invalid API response")?;
|
||||
let data = json.as_array().ok_or("Invalid API response")?;
|
||||
|
||||
if data.is_empty() {
|
||||
break;
|
||||
@@ -347,7 +359,7 @@ async fn fetch_external_org_repos(
|
||||
// Heuristic to find API endpoint from web URL
|
||||
format!(
|
||||
"{}s/{}/repos",
|
||||
org_url.replace(user_or_org, &format!("api/v1/user")),
|
||||
org_url.replace(user_or_org, "api/v1/user"),
|
||||
user_or_org
|
||||
)
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user