[PR #1160] [MERGED] feat(backup): Extend Backup to other Git providers #1165

Closed
opened 2026-05-06 12:35:28 +02:00 by BreizhHardware · 0 comments

📋 Pull Request Information

Original PR: https://github.com/maziggy/bambuddy/pull/1160
Author: @BurntOutHylian
Created: 4/28/2026
Status: Merged
Merged: 5/3/2026
Merged by: @maziggy

Base: devHead: feature/multi-provider-backup


📝 Commits (10+)

  • 029c5fb feat(#576): add provider and api_base_url to GitHub_backup_config with migration defaults
  • 6f0ea79 feat(#576): add mapped columns to GitHubBackupConfig
  • 285b2d5 feat(#576): added new backend git provider abstraction. should allow for future addition/removal of providers. Also modified github_backup service to use said abstraction. Route handler updated to accomodate new database columns for provider and api_base_url
  • 3a5fbb8 feat(#576): remove api_base_url and simplify provider config to use repository_url
  • f77a3d2 feat(#576): add separate providers for Gitea and Forgejo, remove separate GitHub Enterprise
  • f7ca431 feat(#586): skip commits on all providers when content is unchanged
  • 8b6f648 feat(#586): add insecure HTTP option for self-hosted Git backups
  • 424a195 feat(#576): Addressing Blockers, nits, and test gaps for PR#1160
  • f09409d feat(#576): R2 Blockers for PR#1160
  • c3ca4bb Merge branch 'dev' into feature/multi-provider-backup

📊 Changes

26 files changed (+2192 additions, -461 deletions)

View changed files

📝 backend/app/api/routes/github_backup.py (+31 -8)
📝 backend/app/core/database.py (+6 -0)
📝 backend/app/models/github_backup.py (+2 -0)
📝 backend/app/schemas/github_backup.py (+53 -26)
backend/app/services/git_providers/__init__.py (+4 -0)
backend/app/services/git_providers/base.py (+56 -0)
backend/app/services/git_providers/factory.py (+22 -0)
backend/app/services/git_providers/forgejo.py (+11 -0)
backend/app/services/git_providers/gitea.py (+44 -0)
backend/app/services/git_providers/github.py (+335 -0)
backend/app/services/git_providers/gitlab.py (+257 -0)
📝 backend/app/services/github_backup.py (+31 -349)
📝 backend/tests/integration/test_github_backup_api.py (+35 -0)
backend/tests/unit/test_git_providers.py (+460 -0)
backend/tests/unit/test_github_backup_schemas.py (+85 -0)
frontend/src/__tests__/components/GitHubBackupSettings.provider.test.tsx (+452 -0)
📝 frontend/src/api/client.ts (+10 -3)
📝 frontend/src/components/GitHubBackupSettings.tsx (+192 -57)
📝 frontend/src/i18n/locales/de.ts (+14 -3)
📝 frontend/src/i18n/locales/en.ts (+14 -3)

...and 6 more files

📄 Description

Description

Extends the Git backup feature to support GitHub, Gitea, Forgejo, and GitLab as backup targets.
Previously the feature was hard-wired to github.com (URL validator rejected all non-github.com URLs
and all API calls used api.github.com). Users running self-hosted Gitea, Forgejo, or GitLab
instances could not use the feature.

Key changes

  • Provider dropdown in the backup settings UI (GitHub / GitLab / Gitea / Forgejo)
  • An "Allow Insecure HTTP" option for users who have locally hostet Git repo
  • Provider abstraction layer in the backend — each provider is its own class behind a factory
  • URL validator updated to account for non-GitHUB URLs, self-hosted URL formatting, and insecure URLs (if allow insecure is checked)
  • Database migration adds a provider column (default github) — safe to replay on existing installs
  • Database migration adds a allow_insecure_http column (default false) — safe to replay on existing installs
  • GitLab uses the GitLab REST API v4 (different from GitHub's Git Data API)
  • All 8 locale files updated with provider labels and URL placeholders

Fixes #576

Documentation

Companion docs PRs:

Type of Change

  • New feature (non-breaking change that adds functionality)

Changes Made

  • backend/app/core/database.py — migration adds provider VARCHAR(30) DEFAULT 'github' and allow_insecure_http BOOL DEFAULT false
  • backend/app/models/github_backup.py — provider mapped column
  • backend/app/schemas/github_backup.py — ProviderType StrEnum, relaxed URL regex
  • backend/app/services/git_providers/ — new package: base ABC, GitHub, Gitea, Forgejo, GitLab backends, factory
  • backend/app/services/github_backup.py — delegates push/test to provider backend
  • backend/app/api/routes/github_backup.py — reads/writes provider field
  • frontend/src/api/client.ts — GitProviderType union type, updated interfaces
  • frontend/src/components/GitHubBackupSettings.tsx — provider dropdown, provider-aware placeholders
  • frontend/src/i18n/locales/*.ts — new keys in all 8 locale files
  • backend/tests/unit/test_git_providers.py — provider factory and URL parsing tests
  • backend/tests/unit/test_github_backup_schemas.py — schema validation tests
  • frontend/src/tests/components/GitHubBackupSettings.provider.test.tsx — UI tests

Screenshots

Before

Before

After

After

After - Selection List

After_DropDown

After - Edge Case: Alert when using HTTP instead of HTTPS

After_EdgeCase

Testing

  • I have tested this on my local machine
  • I have tested this as a user with an existing GitHub backup (to ensure no breaking change)
  • I have tested this with GitHub
  • I have tested this with GitLab
  • I have tested this with a local Gitea instance
  • I have tested this with a local Forgejo instance
  • I have tested with my printer model: BambuLab P2S

Backend unit tests:

  • pytest backend/tests/unit/test_git_providers.py — factory, URL parsing, API base derivation
  • pytest backend/tests/unit/test_github_backup_schemas.py — schema validation, provider enum

Frontend tests:

  • npm run test:run — provider dropdown renders, loads from config, Git options present
  • UI interactive testing

Checklist

  • My code follows the project's coding style
  • I have commented my code where necessary
  • ./test_frontend.sh passed
  • venv/bin/ruff check backend passed
  • venv/bin/ruff format --check passed for modified backend files
  • ../venv/bin/python3 -m pytest tests/ -v -n 30 passed with 3370 passed I have tested my changes thoroughly

Additional Notes

The implementation drops api_base_url relative to the original issue discussion: Gitea and Forgejo are their own distinct providers in case Gitea and Forgejo diverge in their APIs over time.

With the abstraction layer, adding/removing hosts should allow us to minimize the impact of future add/remove changes


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/maziggy/bambuddy/pull/1160 **Author:** [@BurntOutHylian](https://github.com/BurntOutHylian) **Created:** 4/28/2026 **Status:** ✅ Merged **Merged:** 5/3/2026 **Merged by:** [@maziggy](https://github.com/maziggy) **Base:** `dev` ← **Head:** `feature/multi-provider-backup` --- ### 📝 Commits (10+) - [`029c5fb`](https://github.com/maziggy/bambuddy/commit/029c5fbc3c57868883897fe68bb943ff51459118) feat(#576): add provider and api_base_url to GitHub_backup_config with migration defaults - [`6f0ea79`](https://github.com/maziggy/bambuddy/commit/6f0ea79b3e74e33d3b9733971af5d651757eae40) feat(#576): add mapped columns to GitHubBackupConfig - [`285b2d5`](https://github.com/maziggy/bambuddy/commit/285b2d54acb848084fdf40053cbc0c9a51bbe458) feat(#576): added new backend git provider abstraction. should allow for future addition/removal of providers. Also modified github_backup service to use said abstraction. Route handler updated to accomodate new database columns for provider and api_base_url - [`3a5fbb8`](https://github.com/maziggy/bambuddy/commit/3a5fbb8eca5ff4421fb036aade18614d658883f3) feat(#576): remove api_base_url and simplify provider config to use repository_url - [`f77a3d2`](https://github.com/maziggy/bambuddy/commit/f77a3d208dce3e66d04d61dcdac45043da11c076) feat(#576): add separate providers for Gitea and Forgejo, remove separate GitHub Enterprise - [`f7ca431`](https://github.com/maziggy/bambuddy/commit/f7ca43174565afee5dcca8c4ba5747c8ff3e78d9) feat(#586): skip commits on all providers when content is unchanged - [`8b6f648`](https://github.com/maziggy/bambuddy/commit/8b6f6484c7c3f3da12e343308bc367eee482d2f0) feat(#586): add insecure HTTP option for self-hosted Git backups - [`424a195`](https://github.com/maziggy/bambuddy/commit/424a1955c6b32810acefd6150ea91996f0dde8d5) feat(#576): Addressing Blockers, nits, and test gaps for PR#1160 - [`f09409d`](https://github.com/maziggy/bambuddy/commit/f09409d779f99a876dacf7ba28088e14b2b2aa86) feat(#576): R2 Blockers for PR#1160 - [`c3ca4bb`](https://github.com/maziggy/bambuddy/commit/c3ca4bbf2c56ddeea33f1a54dc4536e37c638275) Merge branch 'dev' into feature/multi-provider-backup ### 📊 Changes **26 files changed** (+2192 additions, -461 deletions) <details> <summary>View changed files</summary> 📝 `backend/app/api/routes/github_backup.py` (+31 -8) 📝 `backend/app/core/database.py` (+6 -0) 📝 `backend/app/models/github_backup.py` (+2 -0) 📝 `backend/app/schemas/github_backup.py` (+53 -26) ➕ `backend/app/services/git_providers/__init__.py` (+4 -0) ➕ `backend/app/services/git_providers/base.py` (+56 -0) ➕ `backend/app/services/git_providers/factory.py` (+22 -0) ➕ `backend/app/services/git_providers/forgejo.py` (+11 -0) ➕ `backend/app/services/git_providers/gitea.py` (+44 -0) ➕ `backend/app/services/git_providers/github.py` (+335 -0) ➕ `backend/app/services/git_providers/gitlab.py` (+257 -0) 📝 `backend/app/services/github_backup.py` (+31 -349) 📝 `backend/tests/integration/test_github_backup_api.py` (+35 -0) ➕ `backend/tests/unit/test_git_providers.py` (+460 -0) ➕ `backend/tests/unit/test_github_backup_schemas.py` (+85 -0) ➕ `frontend/src/__tests__/components/GitHubBackupSettings.provider.test.tsx` (+452 -0) 📝 `frontend/src/api/client.ts` (+10 -3) 📝 `frontend/src/components/GitHubBackupSettings.tsx` (+192 -57) 📝 `frontend/src/i18n/locales/de.ts` (+14 -3) 📝 `frontend/src/i18n/locales/en.ts` (+14 -3) _...and 6 more files_ </details> ### 📄 Description ## Description Extends the Git backup feature to support GitHub, Gitea, Forgejo, and GitLab as backup targets. Previously the feature was hard-wired to github.com (URL validator rejected all non-github.com URLs and all API calls used api.github.com). Users running self-hosted Gitea, Forgejo, or GitLab instances could not use the feature. ## Key changes - Provider dropdown in the backup settings UI (GitHub / GitLab / Gitea / Forgejo) - An "Allow Insecure HTTP" option for users who have locally hostet Git repo - Provider abstraction layer in the backend — each provider is its own class behind a factory - URL validator updated to account for non-GitHUB URLs, self-hosted URL formatting, and insecure URLs (if allow insecure is checked) - Database migration adds a provider column (default github) — safe to replay on existing installs - Database migration adds a allow_insecure_http column (default false) — safe to replay on existing installs - GitLab uses the GitLab REST API v4 (different from GitHub's Git Data API) - All 8 locale files updated with provider labels and URL placeholders ## Related Issue Fixes #576 ## Documentation Companion docs PRs: - Wiki: maziggy/bambuddy-wiki#21 - Docs PR(s) linked above ## Type of Change - New feature (non-breaking change that adds functionality) ## Changes Made - backend/app/core/database.py — migration adds provider VARCHAR(30) DEFAULT 'github' and allow_insecure_http BOOL DEFAULT false - backend/app/models/github_backup.py — provider mapped column - backend/app/schemas/github_backup.py — ProviderType StrEnum, relaxed URL regex - backend/app/services/git_providers/ — new package: base ABC, GitHub, Gitea, Forgejo, GitLab backends, factory - backend/app/services/github_backup.py — delegates push/test to provider backend - backend/app/api/routes/github_backup.py — reads/writes provider field - frontend/src/api/client.ts — GitProviderType union type, updated interfaces - frontend/src/components/GitHubBackupSettings.tsx — provider dropdown, provider-aware placeholders - frontend/src/i18n/locales/*.ts — new keys in all 8 locale files - backend/tests/unit/test_git_providers.py — provider factory and URL parsing tests - backend/tests/unit/test_github_backup_schemas.py — schema validation tests - frontend/src/__tests__/components/GitHubBackupSettings.provider.test.tsx — UI tests ## Screenshots ### Before <img width="1243" height="695" alt="Before" src="https://github.com/user-attachments/assets/2dc08388-fa0b-48c8-8de7-6c9a9b99c6cc" /> ### After <img width="1252" height="685" alt="After" src="https://github.com/user-attachments/assets/b9421ae2-b76b-48ed-8dc3-baa91464a850" /> ### After - Selection List <img width="1239" height="689" alt="After_DropDown" src="https://github.com/user-attachments/assets/dfbd6beb-3c80-42a7-b86d-eabb3d6a6002" /> ### After - Edge Case: Alert when using HTTP instead of HTTPS <img width="822" height="100" alt="After_EdgeCase" src="https://github.com/user-attachments/assets/f71a4b6f-944a-4034-bee9-15b82aef352f" /> ## Testing - I have tested this on my local machine - I have tested this as a user with an existing GitHub backup (to ensure no breaking change) - I have tested this with GitHub - I have tested this with GitLab - I have tested this with a local Gitea instance - I have tested this with a local Forgejo instance - I have tested with my printer model: BambuLab P2S Backend unit tests: - pytest backend/tests/unit/test_git_providers.py — factory, URL parsing, API base derivation - pytest backend/tests/unit/test_github_backup_schemas.py — schema validation, provider enum Frontend tests: - npm run test:run — provider dropdown renders, loads from config, Git options present - UI interactive testing ## Checklist - [x] My code follows the project's coding style - [x] I have commented my code where necessary - [x] ./test_frontend.sh passed - [x] venv/bin/ruff check backend passed - [x] venv/bin/ruff format --check passed for modified backend files - [x] ../venv/bin/python3 -m pytest tests/ -v -n 30 passed with 3370 passed I have tested my changes thoroughly ## Additional Notes The implementation drops api_base_url relative to the original issue discussion: Gitea and Forgejo are their own distinct providers in case Gitea and Forgejo diverge in their APIs over time. With the abstraction layer, adding/removing hosts should allow us to minimize the impact of future add/remove changes --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
BreizhHardware 2026-05-06 12:35:28 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/bambuddy#1165
No description provided.