Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
d8fd1ac57d
|
|||
|
eeeb42b48b
|
1189
Cargo.lock
generated
1189
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -4,9 +4,9 @@ version = "0.1.0"
|
|||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = { version = "4.0", features = ["derive", "env"] }
|
clap = { version = "4.5", features = ["derive", "env"] }
|
||||||
tokio = { version = "1", features = ["full"] }
|
tokio = { version = "1", features = ["full"] }
|
||||||
reqwest = { version = "0.12", features = ["json"] }
|
reqwest = { version = "0.13", features = ["json", "query"] }
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
toml = "0.9"
|
toml = "0.9"
|
||||||
|
|||||||
40
src/main.rs
40
src/main.rs
@@ -5,7 +5,6 @@ use std::fs;
|
|||||||
use std::io::{self, Write};
|
use std::io::{self, Write};
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use tracing::{Level, error, info, instrument, warn};
|
use tracing::{Level, error, info, instrument, warn};
|
||||||
use tracing_subscriber;
|
|
||||||
|
|
||||||
#[derive(Parser, Debug)]
|
#[derive(Parser, Debug)]
|
||||||
#[command(name = "gitea-mirror")]
|
#[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> {
|
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 ---
|
// --- API Calls ---
|
||||||
@@ -290,20 +289,36 @@ async fn fetch_all_target_repos(
|
|||||||
gitea_url: &str,
|
gitea_url: &str,
|
||||||
api_key: &str,
|
api_key: &str,
|
||||||
owner: &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>> {
|
) -> Result<Vec<String>, Box<dyn std::error::Error>> {
|
||||||
let mut names = Vec::new();
|
let mut names = Vec::new();
|
||||||
let mut page = 1;
|
let mut page = 1;
|
||||||
let base_url = format!("{}/api/v1/repos/search", gitea_url);
|
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
let params = [
|
let params = [("limit", "50"), ("page", &page.to_string())];
|
||||||
("owner", owner),
|
|
||||||
("limit", "50"),
|
|
||||||
("page", &page.to_string()),
|
|
||||||
];
|
|
||||||
|
|
||||||
let res = client
|
let res = client
|
||||||
.get(&base_url)
|
.get(url)
|
||||||
.bearer_auth(api_key)
|
.bearer_auth(api_key)
|
||||||
.query(¶ms)
|
.query(¶ms)
|
||||||
.send()
|
.send()
|
||||||
@@ -311,10 +326,7 @@ async fn fetch_all_target_repos(
|
|||||||
.error_for_status()?;
|
.error_for_status()?;
|
||||||
|
|
||||||
let json: serde_json::Value = res.json().await?;
|
let json: serde_json::Value = res.json().await?;
|
||||||
let data = json
|
let data = json.as_array().ok_or("Invalid API response")?;
|
||||||
.get("data")
|
|
||||||
.and_then(|d| d.as_array())
|
|
||||||
.ok_or("Invalid API response")?;
|
|
||||||
|
|
||||||
if data.is_empty() {
|
if data.is_empty() {
|
||||||
break;
|
break;
|
||||||
@@ -347,7 +359,7 @@ async fn fetch_external_org_repos(
|
|||||||
// Heuristic to find API endpoint from web URL
|
// Heuristic to find API endpoint from web URL
|
||||||
format!(
|
format!(
|
||||||
"{}s/{}/repos",
|
"{}s/{}/repos",
|
||||||
org_url.replace(user_or_org, &format!("api/v1/user")),
|
org_url.replace(user_or_org, "api/v1/user"),
|
||||||
user_or_org
|
user_or_org
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|||||||
22
vibe_coding_log/README.md
Normal file
22
vibe_coding_log/README.md
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
# Vibe Coding Log
|
||||||
|
|
||||||
|
This directory contains logs of coding sessions with LLM assistants. The purpose is to track the evolution of LLM coding capabilities over time and provide an audit trail of changes made to the codebase.
|
||||||
|
|
||||||
|
## Log Structure
|
||||||
|
|
||||||
|
Each log entry is saved as a Markdown file named with the pattern:
|
||||||
|
`session_<YYYY_MM_DD>_<topic>.md`
|
||||||
|
|
||||||
|
## Instructions for Creating New Entries
|
||||||
|
|
||||||
|
1. **Create a new file**: Use the naming convention above.
|
||||||
|
2. **Record the Session**: Copy the conversation transcript or write a detailed summary of the interaction.
|
||||||
|
3. **Metadata**: Include the following at the top of the file:
|
||||||
|
* **Date**: The date of the session.
|
||||||
|
* **Model**: The name/version of the LLM used (e.g., Gemini 2.5 Flash, GPT-4, etc.).
|
||||||
|
* **Goal**: The primary objective of the session.
|
||||||
|
* **Outcome**: A brief summary of the result.
|
||||||
|
|
||||||
|
## Current Assistant
|
||||||
|
|
||||||
|
The initial logs in this folder were generated by **Gemini** (specifically acting as the Gemini CLI agent).
|
||||||
69
vibe_coding_log/session_2026_01_07_gitea_fix.md
Normal file
69
vibe_coding_log/session_2026_01_07_gitea_fix.md
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
# Session Log: Gitea Mirror Fixes
|
||||||
|
|
||||||
|
**Date**: Wednesday, January 7, 2026
|
||||||
|
**Model**: Gemini (CLI Agent)
|
||||||
|
**Goal**: Fix compiler errors after dependency bump and correct Gitea API usage.
|
||||||
|
**Outcome**: Successfully resolved `reqwest` 0.13 breaking changes and fixed logic for fetching repositories.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Transcript Summary
|
||||||
|
|
||||||
|
### 1. Dependency Update Fix
|
||||||
|
|
||||||
|
**User**: Reported a compiler error after bumping dependencies.
|
||||||
|
**Context**: The project uses `reqwest`. A recent update to `reqwest` 0.13 made the `.query()` method feature-gated.
|
||||||
|
**Error**:
|
||||||
|
```
|
||||||
|
error[E0599]: no method named `query` found for struct `RequestBuilder` in the current scope
|
||||||
|
```
|
||||||
|
|
||||||
|
**Agent Action**:
|
||||||
|
1. Analyzed `Cargo.toml` and build output.
|
||||||
|
2. Identified that `reqwest` 0.13 requires the `query` feature to use the query string builder.
|
||||||
|
3. Updated `Cargo.toml`:
|
||||||
|
```toml
|
||||||
|
reqwest = { version = "0.13", features = ["json", "query"] }
|
||||||
|
```
|
||||||
|
4. Verified with `cargo build`.
|
||||||
|
5. Committed changes: "Fix compilation error by enabling reqwest/query feature".
|
||||||
|
|
||||||
|
### 2. Logic Fix and Refactoring
|
||||||
|
|
||||||
|
**User**: Provided a `git diff` from another machine fixing an issue where Gitea's search API ignored the "owner" field, causing incorrect repo mirroring. Also requested incorporation of the fix.
|
||||||
|
|
||||||
|
**Agent Action**:
|
||||||
|
1. Applied the logic change to `src/main.rs`:
|
||||||
|
* Switched from `/api/v1/repos/search` to `/api/v1/orgs/{owner}/repos`.
|
||||||
|
* Updated response parsing to handle the JSON array directly.
|
||||||
|
2. Addressed `cargo clippy` warnings identified during the process:
|
||||||
|
* Removed unused `tracing_subscriber` import.
|
||||||
|
* Optimized iterator usage: `url.split('/').last()` -> `url.split('/').next_back()`.
|
||||||
|
* Removed redundant `format!` usage.
|
||||||
|
3. Verified with `cargo build` and `cargo clippy`.
|
||||||
|
4. Committed changes: "Fix target repo fetching by using orgs endpoint and address clippy warnings".
|
||||||
|
|
||||||
|
### 3. Verification and Robustness
|
||||||
|
|
||||||
|
**User**: Asked to verify if the logic fix (using `/orgs/{owner}/repos`) was correct via rigorous checking.
|
||||||
|
|
||||||
|
**Analysis**:
|
||||||
|
* Research confirmed that `/repos/search` does not support filtering by `owner` name (only `uid`), validating the need for a change.
|
||||||
|
* However, `/orgs/{owner}/repos` **only** works if the target is an organization. If the target is a User, it would fail.
|
||||||
|
* The correct endpoint for users is `/users/{owner}/repos`.
|
||||||
|
|
||||||
|
**Agent Action**:
|
||||||
|
1. Refactored `fetch_all_target_repos` to use a fallback strategy:
|
||||||
|
* First, try fetching from `/api/v1/orgs/{owner}/repos`.
|
||||||
|
* If the API returns `404 Not Found`, automatically retry with `/api/v1/users/{owner}/repos`.
|
||||||
|
2. Extracted the fetching logic into a helper function `fetch_repos_from_endpoint` to avoid duplication.
|
||||||
|
3. Addressed new `clippy` suggestions regarding `map_or` and `is_some_and`.
|
||||||
|
4. Committed changes: "Implement fallback to user repos endpoint if org not found".
|
||||||
|
|
||||||
|
## Final State
|
||||||
|
|
||||||
|
The codebase now:
|
||||||
|
1. Compiles with the latest dependencies (`reqwest` 0.13).
|
||||||
|
2. Correctly filters repositories by the target owner.
|
||||||
|
3. Robustly handles both Organization and User targets by attempting both endpoints.
|
||||||
|
4. Is free of linting warnings.
|
||||||
Reference in New Issue
Block a user