refactor(#1868): drop tokenised_repo_url — call forge_git_url directly
This commit is contained in:
parent
031edbd41f
commit
6f3e400903
1 changed files with 7 additions and 13 deletions
|
|
@ -77,13 +77,6 @@ fn repo_agent_name(repo: &str) -> &str {
|
|||
repo.rsplit('/').next().unwrap_or(repo)
|
||||
}
|
||||
|
||||
/// Token-in-URL clone/push URL for a forge repo (`owner/name`). Mirrors
|
||||
/// `push_config`'s pattern; the token is passed straight to git and never
|
||||
/// stored as a named remote.
|
||||
fn tokenised_repo_url(repo: &str, token: &str) -> String {
|
||||
forge_git_url(token, repo)
|
||||
}
|
||||
|
||||
/// Resolve a PR's head sha via `git ls-remote <repo> refs/pull/<pr>/head`
|
||||
/// (Forgejo exposes PR heads there). Pure read, no mutation — the handler's
|
||||
/// primary drift gate (compare against the approved sha), and `mark_pr_merged`
|
||||
|
|
@ -94,7 +87,7 @@ fn tokenised_repo_url(repo: &str, token: &str) -> String {
|
|||
pub async fn pr_head_sha(repo: &str, pr: u64) -> Result<String, ForgeMergeError> {
|
||||
let token = core_token()
|
||||
.ok_or_else(|| ForgeMergeError::Other(anyhow::anyhow!("forge core token absent")))?;
|
||||
let url = tokenised_repo_url(repo, &token);
|
||||
let url = forge_git_url(&token, repo);
|
||||
let refspec = format!("refs/pull/{pr}/head");
|
||||
let out = crate::lifecycle::git_command()
|
||||
.args(["ls-remote", &url, &refspec])
|
||||
|
|
@ -139,7 +132,7 @@ pub fn config_repo(agent: &str) -> String {
|
|||
pub async fn fetch_pr_head_into_applied(repo: &str, pr: u64) -> Result<(), ForgeMergeError> {
|
||||
let token = core_token()
|
||||
.ok_or_else(|| ForgeMergeError::Other(anyhow::anyhow!("forge core token absent")))?;
|
||||
let url = tokenised_repo_url(repo, &token);
|
||||
let url = forge_git_url(&token, repo);
|
||||
let applied = Coordinator::agent_applied_dir(repo_agent_name(repo));
|
||||
let refspec = format!("refs/pull/{pr}/head");
|
||||
let out = crate::lifecycle::git_command()
|
||||
|
|
@ -171,7 +164,7 @@ pub async fn fetch_pr_head_into_applied(repo: &str, pr: u64) -> Result<(), Forge
|
|||
pub async fn ff_push_to_main(repo: &str, sha: &str) -> Result<(), ForgeMergeError> {
|
||||
let token = core_token()
|
||||
.ok_or_else(|| ForgeMergeError::Other(anyhow::anyhow!("forge core token absent")))?;
|
||||
let url = tokenised_repo_url(repo, &token);
|
||||
let url = forge_git_url(&token, repo);
|
||||
let applied = Coordinator::agent_applied_dir(repo_agent_name(repo));
|
||||
|
||||
// Current `main` on the forge repo.
|
||||
|
|
@ -300,7 +293,8 @@ pub async fn mark_pr_merged(repo: &str, pr: u64, sha: &str) -> Result<(), ForgeM
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::{repo_agent_name, tokenised_repo_url};
|
||||
use super::repo_agent_name;
|
||||
use crate::forge::forge_git_url;
|
||||
|
||||
#[test]
|
||||
fn repo_agent_name_takes_trailing_segment() {
|
||||
|
|
@ -310,10 +304,10 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn tokenised_repo_url_shape() {
|
||||
fn forge_git_url_shape() {
|
||||
// Credentials are inserted between scheme and authority; fallback
|
||||
// base is `http://localhost:3000` when HIVE_FORGE_URL is unset.
|
||||
let url = tokenised_repo_url("agent-configs/iris", "tok");
|
||||
let url = forge_git_url("tok", "agent-configs/iris");
|
||||
assert!(url.contains("core:tok@"), "must embed credentials: {url}");
|
||||
assert!(
|
||||
url.ends_with("/agent-configs/iris.git"),
|
||||
|
|
|
|||
Loading…
Reference in a new issue