Skip to content

Fix GitHub repository creation and clone logic in scan storage#853

Open
huseynovvusal wants to merge 1 commit intoaboutcode-org:mainfrom
huseynovvusal:fix/clearcode-scan-storage-bootstrap
Open

Fix GitHub repository creation and clone logic in scan storage#853
huseynovvusal wants to merge 1 commit intoaboutcode-org:mainfrom
huseynovvusal:fix/clearcode-scan-storage-bootstrap

Conversation

@huseynovvusal
Copy link
Copy Markdown

@huseynovvusal huseynovvusal commented Mar 21, 2026

Description

This PR fixes two critical failure cases in the get_or_init_repo() bootstrap flow during scan storage, which previously broke when handling existing remote repositories or correctly creating new ones.

The Issues

  1. Name Mismatch: get_github_repos() was yielding full repository names (e.g., org/repo-name), which caused the simple repo_name not in get_github_repos() membership check to silently fail and incorrectly attempt to recreate existing repositories.
  2. Missing Clone URLs:
    • When a new repository was created, create_github_repo() did not return the new clone URL, causing Repo.clone_from() to fail with a None URL.
    • If the repository already existed remotely, repo_url was never defined, resulting in an undefined variable crash during cloning.
  3. Organization Support: create_github_repo hardcoded the /user/repos API endpoint, causing organizational repositories to be incorrectly requested under the authenticated user instead of their respective namespace.

The Fixes

  • get_github_repos() now yields the exact repository "name" to ensure the existence check successfully evaluates.
  • get_or_init_repo() now proactively constructs a fallback clone URL (f"https://github.com/{namespace}/{repo_name}.git") to ensure the clone command never crashes.
  • create_github_repo() now successfully returns the GitHub API clone_url upon creation.
  • Added an optional organization argument to seamlessly support both user and organization /orgs/{org}/repos creation pathways based on the provided namespace.

Testing

  • Verified clearcode and model test suites pass locally against the PostgreSQL testing database.

Closes #847

…s and refine repository name retrieval in `get_github_repos`.

Signed-off-by: Vusal Huseynov <vslh333222111@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

clearcode/store_scans.py fails to bootstrap shard repositories reliably

1 participant