From f8c8769af3dc7af9132984e9c6c2ed53a0babce1 Mon Sep 17 00:00:00 2001 From: openhands Date: Wed, 25 Mar 2026 15:20:53 +0000 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20fix:=20disinto=20init=20does=20not?= =?UTF-8?q?=20push=20repo=20to=20local=20Forgejo=20=E2=80=94=20repo=20stay?= =?UTF-8?q?s=20empty=20(#682)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.6 (1M context) --- bin/disinto | 49 +++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 41 insertions(+), 8 deletions(-) diff --git a/bin/disinto b/bin/disinto index 83454c2..0769d75 100755 --- a/bin/disinto +++ b/bin/disinto @@ -654,19 +654,52 @@ setup_forge() { # Push local clone to the Forgejo remote. push_to_forge() { local repo_root="$1" forge_url="$2" repo_slug="$3" - local remote_url="${forge_url}/${repo_slug}.git" + # Build authenticated remote URL: http://dev-bot:@host:port/org/repo.git + if [ -z "${FORGE_TOKEN:-}" ]; then + echo "Error: FORGE_TOKEN not set — cannot push to Forgejo" >&2 + return 1 + fi + local auth_url + auth_url=$(printf '%s' "$forge_url" | sed "s|://|://dev-bot:${FORGE_TOKEN}@|") + local remote_url="${auth_url}/${repo_slug}.git" + # Display URL without token + local display_url="${forge_url}/${repo_slug}.git" + + # Always set the remote URL to ensure credentials are current if git -C "$repo_root" remote get-url forgejo >/dev/null 2>&1; then - echo "Remote: forgejo (already configured)" + git -C "$repo_root" remote set-url forgejo "$remote_url" else - git -C "$repo_root" remote add forgejo "$remote_url" 2>/dev/null || \ - git -C "$repo_root" remote set-url forgejo "$remote_url" - echo "Remote: forgejo -> ${remote_url}" + git -C "$repo_root" remote add forgejo "$remote_url" + fi + echo "Remote: forgejo -> ${display_url}" + + # Push all branches and tags + echo "Pushing: branches to forgejo" + if ! git -C "$repo_root" push forgejo --all 2>&1; then + echo "Error: failed to push branches to Forgejo" >&2 + return 1 + fi + echo "Pushing: tags to forgejo" + if ! git -C "$repo_root" push forgejo --tags 2>&1; then + echo "Error: failed to push tags to Forgejo" >&2 + return 1 fi - # Push all branches - git -C "$repo_root" push forgejo --all 2>/dev/null || true - git -C "$repo_root" push forgejo --tags 2>/dev/null || true + # Verify the repo is no longer empty + local repo_info + repo_info=$(curl -sf --max-time 10 \ + -H "Authorization: token ${FORGE_TOKEN}" \ + "${forge_url}/api/v1/repos/${repo_slug}" 2>/dev/null) || repo_info="" + if [ -n "$repo_info" ]; then + local is_empty + is_empty=$(printf '%s' "$repo_info" | jq -r '.empty // "unknown"') + if [ "$is_empty" = "true" ]; then + echo "Warning: Forgejo repo still reports empty after push" >&2 + return 1 + fi + echo "Verify: repo is not empty (push confirmed)" + fi } # Preflight check — verify all factory requirements before proceeding. From 26df57da1882896afca87a85003b7c074d114a64 Mon Sep 17 00:00:00 2001 From: openhands Date: Wed, 25 Mar 2026 15:23:02 +0000 Subject: [PATCH 2/2] fix: skip push when local repo has no commits (empty clone) The smoke test clones from an empty Forgejo repo, so there are no refs to push. Skip the push and verification gracefully when HEAD does not resolve. Co-Authored-By: Claude Opus 4.6 (1M context) --- bin/disinto | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bin/disinto b/bin/disinto index 0769d75..e6e1f97 100755 --- a/bin/disinto +++ b/bin/disinto @@ -674,6 +674,12 @@ push_to_forge() { fi echo "Remote: forgejo -> ${display_url}" + # Skip push if local repo has no commits (e.g. cloned from empty Forgejo repo) + if ! git -C "$repo_root" rev-parse HEAD >/dev/null 2>&1; then + echo "Push: skipped (local repo has no commits)" + return 0 + fi + # Push all branches and tags echo "Pushing: branches to forgejo" if ! git -C "$repo_root" push forgejo --all 2>&1; then