Skip to content

Gitea, Gitlab, GitHub webhooks clone to the wrong project path #1547

@aarononeal

Description

@aarononeal

Summary

  • What broke: Clone from Gitea places project in the wrong folder
  • When it started (if known): Feature introduction
  • Severity: major

Steps to Reproduce

  1. Add a webhook to Archon in Gitea (or Gitlab).
  2. Open an issue and make a comment with @archon which initiates repo clone.

Expected vs Actual

  • Expected: Repo clones to ~/.archon/workspaces/owner/repo/source/
  • Actual: Repo clones to ~/.archon/workspaces/owner/repo/ which breaks project structure worktrees/ etc.

The Bug

The Gitea adapter bypasses the proper clone flow entirely. Let's trace the two paths:

Correct path (via CLI /clone command)
In clone.ts, line 186-187:

const targetPath = getProjectSourcePath(ownerName, repoName);

getProjectSourcePath() returns ~/.archon/workspaces/owner/repo/source/. It also calls ensureProjectStructure() (line 242) which creates source/, worktrees/, artifacts/, logs/ as separate directories.

Buggy path (Gitea adapter)
In adapter.ts (gitea), line 611:

const canonicalPath = join(getArchonWorkspacesPath(), owner, repo);

This resolves to ~/.archon/workspaces/owner/repo/ — no /source suffix.

Then in ensureRepoReady() (line 527), it clones directly to repoPath (which is canonicalPath):

const cloneResult = await cloneRepository(repoUrl, toRepoPath(repoPath), {...});

So the repo gets cloned directly into owner/repo/ instead of owner/repo/source/. And since ensureProjectStructure() is never called, the worktrees/ directory ends up as a sibling subdirectory of the cloned repo content — inside the repo itself.

GitHub adapter has the same issue at line 585:

const canonicalPath = join(getArchonWorkspacesPath(), owner, repo);

GitLab adapter too line 549:

const canonicalPath = join(getArchonWorkspacesPath(), ...projectPath.split('/'));

The Fix

The adapters need to use getProjectSourcePath(owner, repo) instead of manually constructing the path, and call ensureProjectStructure(owner, repo) before cloning — matching what the CLI /clone command does. The canonicalPath should point to the source/ directory, since that's where the actual repo lives and where worktrees will be scoped.

Environment

  • Platform: Web, Docker
  • Database: PostgreSQL
  • Running in worktree? Yes
  • OS: Docker/Alpine

Logs

N/A

Impact

  • Affected workflows/commands: Workflow authoring and activities dependent on project structure.
  • Reproduction rate: Always
  • Workaround available? If so, describe: Manual clone and register project first.
  • Data loss risk? Maybe (Archon seems confused where workflows live).

Scope

  • Package(s) likely involved: adapters
  • Module (if known): adapters:gitea, adapters:gitlab

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High priority - Address soon, next in queuearea: adaptersPlatform adaptersbugSomething is brokeneffort/lowSingle file or function, one responsibility, isolated change

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions