Skip to content

Refactor duplicated GitHub-to-Gitea helpers#1

Open
athphane wants to merge 1 commit intomasterfrom
codex/refactor-repository-to-reduce-duplicate-code
Open

Refactor duplicated GitHub-to-Gitea helpers#1
athphane wants to merge 1 commit intomasterfrom
codex/refactor-repository-to-reduce-duplicate-code

Conversation

@athphane
Copy link
Copy Markdown
Owner

Summary

  • unify GithubToGitea and GithubToGiteaCF into single configurable class
  • add from_config helper to simplify script setup
  • update scripts to use new helper and remove duplicated code

Testing

  • python -m py_compile scripts/core/github_to_gitea.py scripts/clone_github_stars.py scripts/interactive.py scripts/scrape_organization.py scripts/scrape_organization_cf.py

https://chatgpt.com/codex/tasks/task_e_68ad4f276284833195e33686637e9b42

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR consolidates two nearly identical classes (GithubToGitea and GithubToGiteaCF) into a single configurable class to reduce code duplication and improve maintainability. The refactored class now optionally supports Cloudflare Access when credentials are provided.

  • Unified GithubToGitea and GithubToGiteaCF into single class with optional Cloudflare support
  • Added from_config class method to simplify configuration parsing across scripts
  • Updated all scripts to use the new helper method, removing duplicated instantiation code

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
scripts/core/github_to_gitea.py Enhanced with optional Cloudflare support, comprehensive documentation, and from_config helper method
scripts/core/github_to_gitea_cf.py Removed entire file as functionality merged into main class
scripts/scrape_organization_cf.py Updated to use unified class with Cloudflare enabled via from_config
scripts/scrape_organization.py Simplified instantiation using from_config method
scripts/interactive.py Simplified instantiation using from_config method
scripts/clone_github_stars.py Simplified instantiation using from_config method

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.


try: # pragma: no cover - optional dependency
from core.cf_ready.cf_gitea import CFGitea
except Exception: # ImportError or any other error
Copy link

Copilot AI Aug 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Catching Exception is too broad. Consider catching specific exceptions like ImportError or ModuleNotFoundError that would occur when the optional dependency is missing.

Suggested change
except Exception: # ImportError or any other error
except (ImportError, ModuleNotFoundError): # Only catch missing module errors

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants