Skip to content

forgejo: add dump archive integration#27

Open
IvanchitorJR wants to merge 4 commits into
PlakarKorp:mainfrom
IvanchitorJR:bounty/forgejo-integration
Open

forgejo: add dump archive integration#27
IvanchitorJR wants to merge 4 commits into
PlakarKorp:mainfrom
IvanchitorJR:bounty/forgejo-integration

Conversation

@IvanchitorJR

Copy link
Copy Markdown

Refs PlakarKorp/hub#4.

Summary

Adds a community Forgejo integration that uses Forgejo's built-in dump tooling:

  • forgejo:// importer invokes forgejo dump --file ... --type ... --quiet and stores the resulting archive in the snapshot.
  • Snapshot includes /forgejo-dump.<type> plus /manifest.json metadata.
  • forgejo:// exporter materializes snapshot records into a local output directory so the dump archive is ready for Forgejo's documented restore workflow.
  • Adds manifest metadata, JSON schemas, README usage docs, and build targets.

Validation

  • gofmt on new Go files
  • go test ./...
  • go build -v -o forgejoImporter ./plugin/importer
  • go build -v -o forgejoExporter ./plugin/exporter
  • git diff --check -- forgejo

Note: I validated compilation and package-level behavior locally. I did not run an end-to-end live Forgejo container restore in this environment.

Signed-off-by: Iván Rodríguez <ivandejesus1806@gmail.com>
@IvanchitorJR IvanchitorJR force-pushed the bounty/forgejo-integration branch from 7f71865 to 8f5ec6d Compare June 3, 2026 02:23
Signed-off-by: Iván Rodríguez <ivandejesus1806@gmail.com>
@IvanchitorJR

Copy link
Copy Markdown
Author

Validation update: I added focused importer/exporter unit tests and tightened exporter path handling so restore rejects .. traversal attempts instead of normalizing them silently.

Re-ran locally after the update:

  • gofmt on new Go files
  • go test ./...
  • go build -v -o forgejoImporter ./plugin/importer
  • go build -v -o forgejoExporter ./plugin/exporter
  • git diff --check -- forgejo

Signed-off-by: Iván Rodríguez <ivandejesus1806@gmail.com>
@IvanchitorJR

Copy link
Copy Markdown
Author

Small follow-up: I added an importer flow test that uses a fake forgejo command to verify the integration actually invokes forgejo dump, consumes the generated archive, emits /manifest.json, and emits /forgejo-dump.zip with ACK handling.

Re-ran locally after the change: go test ./..., importer build, exporter build, and git diff --check -- forgejo.

@Alex-Parejo Alex-Parejo left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

One small hardening point: dump_type is passed to orgejo dump --type without validation, while �rchiveExtension() falls back to .zip for unknown values. So a typo like dump_type=tarz would run orgejo dump --type tarz but name/metadata the snapshot as orgejo-dump.zip. I would either validate dump_type against the supported set in NewImporter/schema or make �rchiveExtension return an error for unknown values, so failed config is explicit instead of producing mismatched archive metadata.

@Alex-Parejo

Copy link
Copy Markdown

Clarifying my previous review comment, which got mangled by shell escaping:

dump_type is passed to forgejo dump --type without validation, while archiveExtension() falls back to .zip for unknown values. So a typo like dump_type=tarz would run forgejo dump --type tarz but name/metadata the snapshot as forgejo-dump.zip.

Suggestion: validate dump_type against the supported set in NewImporter/schema, or make archiveExtension return an error for unknown values.

Signed-off-by: Iván Rodríguez <ivandejesus1806@gmail.com>
@IvanchitorJR

Copy link
Copy Markdown
Author

Thanks for catching that. I pushed b32c010 to validate and normalize dump_type before it reaches forgejo dump.

Changes:

  • accept only Forgejo's documented dump formats: zip, tar, tar.sz, tar.gz, tar.xz, tar.bz2, tar.br, tar.lz4, tar.zst
  • reject unknown values at importer construction instead of silently naming them .zip
  • add schema enums and README-supported values
  • add tests for unknown dump types and normalization

Re-ran locally: gofmt, go test ./..., importer/exporter builds, and git diff --check -- forgejo.

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.

2 participants