Skip to main content

forgejo-sync-manager-core v1.0.2

Universal core library for Forgejo repository synchronization.


GitHub top language GitHub license GitHub release GitHub stars GitHub forks

PyPI - Downloads PyPI PyPI - Format PyPI Downloads PyPI Downloads PyPI Downloads


⚠️ Disclaimer

By using this software, you agree to the full disclaimer terms.

Summary: Software provided "AS IS" without warranty. You assume all risks.

Full legal disclaimer: See DISCLAIMER.md


Overview

forgejo-sync-manager-core is a reusable Python library that provides the core functionality for synchronizing Forgejo repositories. It is designed to be used by both CLI and GUI applications, ensuring code reuse and consistency across different interfaces.

Features

  • Forgejo API client with token-based authentication
  • Repository discovery with pagination support
  • Git repository cloning and updating
  • Repository recloning functionality
  • Local repository existence checking
  • Path management for local storage
  • Cross-platform support (Linux, Windows, macOS)
  • Abstract base classes for easy extension

Implementations

This core library is used in the following projects:

Project Description Repository
forgejo-sync-manager-cli CLI tool for batch synchronization GitHub
forgejo-sync-manager-gui Desktop GUI tool for batch synchronization GitHub

Components

Core Classes

Class Description
ForgejoAuth Authentication container for server URL and token
ForgejoAPIClient API client for Forgejo REST API
ConfigManager Configuration file management (JSON)
BaseSyncManager Abstract base class for sync operations

Sync Managers

Class Purpose
GUISyncManager Lightweight manager for GUI applications (no console output)
CLISyncManager Full-featured manager with console progress output

Requirements

  • Python 3.8+
  • Git
  • Forgejo server with API access
  • requests library

Installation

git clone https://github.com/smartlegionlab/forgejo-sync-manager-core.git
cd forgejo-sync-manager-core
python -m venv venv
pip install -r requirements.txt

Usage

Basic Authentication

from forgejo_sync_manager_core.core.auth import ForgejoAuth

auth = ForgejoAuth(
    token="your_token",
    server_url="http://localhost:3000",
    username="your_username"
)

API Client

from forgejo_sync_manager_core.core.api_client import ForgejoAPIClient

client = ForgejoAPIClient(auth)
user_info = client.get_user_info()
repositories = client.get_user_repos()

Sync Manager for GUI Applications

from forgejo_sync_manager_core.core.sync_manager_gui import GUISyncManager

sync_manager = GUISyncManager(auth)
sync_manager.ensure_directories()

for repo in repositories:
    status = sync_manager.sync_repository(repo)
    # status: "CLONED", "UPDATED", "FAILED"

Sync Manager for CLI Applications

from forgejo_sync_manager_core.core.sync_manager_cli import CLISyncManager

sync_manager = CLISyncManager(auth)
results = sync_manager.sync_all_repositories(repositories)
# results: {"cloned": 0, "updated": 0, "failed": 0}

Check Repository Updates (CLI only)

from forgejo_sync_manager_core.core.sync_manager_cli import CLISyncManager

sync_manager = CLISyncManager(auth)
needs_update = sync_manager.check_updates(repositories)
print(f"Repositories needing update: {len(needs_update)}")

Local Repository Management

# Check if repository exists locally
exists = sync_manager.repo_exists_locally("repo-name")

# Get path to local repository
repo_path = sync_manager.get_repo_path("repo-name")

Configuration

Configuration is stored in ~/forgejo-sync-manager/config.json:

{
    "token": "your_access_token",
    "server_url": "http://localhost:3000",
    "username": "your_username"
}

Return Status Codes

Status Description
CLONED Repository was successfully cloned
UPDATED Existing repository was successfully updated
RECLONED Repository was deleted and re-cloned
FAILED Operation failed

How It Works

  1. Authentication: Token-based authentication via Forgejo API
  2. Repository Discovery: Fetches complete repository list with pagination (50 per page)
  3. Update Detection (CLI only): For each existing repository, executes git fetch and compares HEAD with FETCH_HEAD
  4. Sync Operations: Uses authenticated URLs with embedded token for Git operations
  5. Directory Structure: ~/forgejo-sync-manager/{username}/repositories/

License

BSD 3-Clause License

Copyright (©) 2026, Alexander Suvorov All rights reserved.

Metadata

Release files for forgejo-sync-manager-core 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for forgejo-sync-manager-core 1.0.2
File Size Uploaded
forgejo_sync_manager_core-1.0.2.tar.gz 9.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for forgejo-sync-manager-core 1.0.2
File Interpreter ABI Platform
forgejo_sync_manager_core-1.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 19.0 kB

Release files / forgejo_sync_manager_core-1.0.2.tar.gz

Download URL forgejo_sync_manager_core-1.0.2.tar.gz
Size 9.2 kB
Tags Source
SHA-256 checksum
How to use checksums
43db6cb2941548b11057aa7ce9f1294243408e050d2310666eb6147355e2e6e0
BLAKE2b-256 checksum
How to use checksums
7839347aa06b3e1d341cb1e0bc686c9cf252b29cfc3584c4b713f1f0aecc9c32
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.5

Release files / forgejo_sync_manager_core-1.0.2-py3-none-any.whl

Download URL forgejo_sync_manager_core-1.0.2-py3-none-any.whl
Size 9.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c8a879fbbd060e1560a7f88e6d681aa0272d14893cb7a102cd49162a9b12f8c2
BLAKE2b-256 checksum
How to use checksums
0c71329d1ec9042b4253b49147bce594cd13a986f485d427ee2b5784e5a2cf24
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.5

Release history Release notifications | RSS feed

This release

1.0.2 This release

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page