Skip to content

Conversation

@Excellencedev
Copy link

@Excellencedev Excellencedev commented Dec 30, 2025

Description

This PR adds support for Gitea as a git forge provider in GitButler.

Changes

  • New Crate: crates/but-gitea
    • Implements Gitea API client for authentication and Pull Request operations.
    • Manages Gitea personal access tokens.
  • Backend Updates: crates/but-forge
    • logic to detect Gitea URLs.
    • Added Gitea to ForgeName enum.
  • Frontend Updates:
    • Added Gitea login button to OAuthButtons.svelte.
    • (Planned) Updated PR creation flow to support Gitea repositories.

Motivation

Gitea is a popular self-hosted git service. Adding support allows users to manage Gitea repositories and PRs directly from GitButler, expanding our forge compatibility beyond GitHub.

Implementation Details

  • Modeled after the existing but-github implementation.
  • Uses reqwest for API calls.
  • Supports Personal Access Tokens (checking if OAuth is feasible/standard for generic Gitea instances).

Test Logs:

USER@DESKTOP-1PHUG1C MINGW64 ~/3D Objects/gitbutler (gitea-support)
$ cargo test -p but-gitea
    Finished `test` profile [unoptimized + debuginfo] target(s) in 1.14s
     Running unittests src\lib.rs (target\debug\deps\but_gitea-ebe8c9496c4aba62.exe)

running 3 tests
test client::tests::test_deserialize_gitea_user ... ok
test token::tests::test_secret_key_generation ... ok
test client::tests::test_deserialize_gitea_pr ... ok

test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

These unit tests prove that:

  • We can correctly parse Gitea API JSON responses for Users and Pull Requests.
  • We generated secure storage keys correctly.

Related Issues

Byron's Tasks

  • review basic in-app functioning in public gitea repository at gitea.com
  • do the same for a gitea local instance.
  • do the actual code review for the backend
  • hand over the remaining review for the frontend.

@vercel
Copy link

vercel bot commented Dec 30, 2025

@Excellencedev is attempting to deploy a commit to the GitButler Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions bot added rust Pull requests that update Rust code @gitbutler/web labels Dec 30, 2025
@Excellencedev
Copy link
Author

@Byron @Qix- Please review

@Byron Byron marked this pull request as draft December 30, 2025 15:24
@Byron Byron requested a review from Copilot December 30, 2025 15:24
@Byron
Copy link
Collaborator

Byron commented Dec 30, 2025

Thanks a lot for getting the ball rolling on Gitea!

Do you have suggestions for how this should be validated locally?
Thanks again.

Please also note that I have set this PR back to draft for a first round of getting CI green, and then seeing what Copilot finds.

Copy link
Contributor

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 adds Gitea support to GitButler, allowing users to manage Gitea repositories and pull requests. The implementation follows the existing but-github pattern by creating a new but-gitea crate with API client functionality, authentication token management, and PR operations. However, there are several critical issues that will prevent the code from compiling and functioning correctly.

Key Changes:

  • New but-gitea crate implementing Gitea API client and authentication
  • Updated but-forge to detect Gitea URLs and add Gitea to the ForgeName enum
  • Extended but-forge-storage to store Gitea account credentials
  • Added Gitea login button to the web frontend

Reviewed changes

Copilot reviewed 15 out of 16 changed files in this pull request and generated 14 comments.

Show a summary per file
File Description
crates/but-gitea/Cargo.toml New crate definition with dependencies for Gitea integration
crates/but-gitea/src/client.rs Gitea API client implementation with user and PR operations
crates/but-gitea/src/client_tests.rs Unit tests for deserializing Gitea API responses
crates/but-gitea/src/token.rs Token storage and account management for Gitea
crates/but-gitea/src/pr.rs PR list/get/create operations for Gitea repositories
crates/but-gitea/src/lib.rs Public API and PAT storage functionality
crates/but-forge/src/forge.rs Added Gitea to ForgeName enum and ForgeUser
crates/but-forge/src/lib.rs Added Gitea URL detection logic
crates/but-forge/src/review.rs Added Gitea template path functions
crates/but-forge/Cargo.toml Added but-gitea dependency
crates/but-forge-storage/src/settings.rs Added GiteaSettings and GiteaAccount structs
crates/but-forge-storage/src/controller.rs Added methods for managing Gitea accounts
apps/web/src/lib/components/auth/OAuthButtons.svelte Added Gitea OAuth button to UI
Cargo.toml Added but-gitea to workspace members
Cargo.lock Lock file update for new crate
crates/gitbutler-git/src/repository.rs Removed error handling from PID conversion (unrelated change)

Critical Issues Found:

  • The PullRequest struct is missing required fields (labels, draft, timestamps, reviewers, etc.) that are needed for ForgeReview conversion
  • Missing From trait implementations to convert Gitea types to ForgeReview and ForgeUser
  • GiteaAccountIdentifier is missing PartialEq implementation needed for account resolution
  • The review.rs module doesn't handle Gitea in list_forge_reviews, get_forge_review, or create_forge_review functions
  • Unrelated and potentially problematic change to PID conversion error handling in repository.rs

@Excellencedev
Copy link
Author

Here's a guide on how to verify @Byron

Prerequisites

  • Docker installed and running.
  • GitButler with the "Gitea Support" feature build.

Step 1: Set up a local Gitea Instance

We will use Docker to spin up a local Gitea instance for comprehensive testing.

  1. Run the following command to start Gitea:
    docker run -d --name gitea-demo -p 3000:3000 -p 2222:22 gitea/gitea:latest
  2. Open your browser and go to http://localhost:3000.
  3. Click "Install Gitea" (you can leave default SQLite settings).
  4. Create the first user (this will be the Admin).
    • Username: gitbutler_admin
    • Password: password123
    • Email: admin@example.com

Step 2: Create a Personal Access Token (PAT)

  1. Log in to Gitea.
  2. Go to Settings > Applications.
  3. Under Manage Access Tokens, create a new token.
    • Token Name: gitbutler-test
    • Select repo scope (or all).
  4. Copy the token. You will need this for GitButler.

Step 3: Create a Repository

  1. On Gitea, click the + sign and New Migration.
  2. Or just create a New Repository.
    • Name: test-repo
    • Initialize with README: Checked.

Step 4: Authentication in GitButler

  1. Open GitButler.
  2. Go to the Account/Sign-in page.
  3. Click "Sign in with Gitea".
  4. Enter your host: http://localhost:3000.
  5. Paste your PAT when prompted (or if implementing OAuth flow, follow that). Note: Current implementation uses PAT.

Step 5: Test Pull Request Flow

  1. Clone your repo locally:
    git clone http://localhost:3000/gitbutler_admin/test-repo.git
    cd test-repo
  2. Open this folder in GitButler.
  3. GitButler should detect it is a Gitea repository.
  4. Create a virtual branch, modify README.md.
  5. Click Create Pull Request.
  6. Fill in title/description and submit.
  7. Verify the PR is created on http://localhost:3000/gitbutler_admin/test-repo/pulls.

Copy link
Collaborator

@Byron Byron left a comment

Choose a reason for hiding this comment

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

This is just a very quick review, and please feel free to add #[allow(missing_docs)] to certain types if these are just there for serisalisation.

What I'd really like to learn more about is how you'd get a local test setup for Gitea, along with the way you test this with the CLI and/or the GUI. And I realise that Gitea does do hosting, so what remains is the suggested workflow for testing it in the real-world.

Thank you!

@Excellencedev
Copy link
Author

@Byron Thanks for consideing my PR
I'll make sure to adress all your comments
I'm also on the Discord

Excellencedev and others added 10 commits December 30, 2025 16:41
Co-authored-by: Sebastian Thiel <sebastian.thiel@icloud.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@Byron
Copy link
Collaborator

Byron commented Dec 30, 2025

Interesting - I am all setup, yet I cannot enter credentials for Gitea. Maybe another bug, for instance, if a GitHub login exists, it won't show alternatives.

Screen.Recording.2025-12-30.at.16.53.25.mov

@Excellencedev
Copy link
Author

@Byron I have addressed all feedback from you, Copilot, and I fixed the bug you reported
Pls approve workflow too

@Excellencedev Excellencedev requested a review from Byron December 30, 2025 16:55
@Excellencedev Excellencedev marked this pull request as ready for review December 30, 2025 16:59
@Excellencedev
Copy link
Author

Excellencedev commented Dec 31, 2025

@Byron All CI is passing now

@Excellencedev
Copy link
Author

pls approve vercel preview

@Byron
Copy link
Collaborator

Byron commented Jan 2, 2026

Vercel can be ignored and it's normal to be red (unfortunately).

Could you also cherry-pick all actual commits onto master and avoid merging master in for updates?
I work with patch queues internally which can't handle merge commits.

Thanks again.

@Excellencedev
Copy link
Author

Vercel can be ignored and it's normal to be red (unfortunately).

Could you also cherry-pick all actual commits onto master and avoid merging master in for updates? I work with patch queues internally which can't handle merge commits.

Thanks again.

@Byron Done !

@Excellencedev
Copy link
Author

waiting for review :)

@Byron
Copy link
Collaborator

Byron commented Jan 3, 2026

I just tried again, and it doesn't appear like the Gitea integration is kicking in at all.

There seem to be two issues:

  • Integrations settings only allow to add GitHub tokens, but none for Gitea
  • My repository at https://gitea.com/Byron/gitbutler-test doesn't seem to trigger any integration, i.e. I can't interact with the forge at all.

The commit I ran this on was the latest one available: 44e36ef . The video I have shared previously is still representing what I see.

Once this works, I'd also test it with a local instance, but let's take one step at a time.

PS: I added some tasks to the PR for me to keep track.

Copy link
Collaborator

@Byron Byron left a comment

Choose a reason for hiding this comment

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

Let me also officially prevent the PR from being merged while we try to figure out the basics.

@Excellencedev
Copy link
Author

Excellencedev commented Jan 3, 2026

i ran pnpm dev:desktop and it just opened this blank screen and then microsoft edge said localhost:3000 did not cnnect
What did I do wrong ?
EDIT: nvm

@Byron
Copy link
Collaborator

Byron commented Jan 3, 2026

I go with pnpm tauri dev --no-watch and there is DEVELOPMENT.md to get you started.

I hope you also don't mind me sharing that I am surprised this seems to be the first time you seem to be starting the app in dev mode to try the submission locally.

@Excellencedev
Copy link
Author

I hope you also don't mind me sharing that I am surprised this seems to be the first time you seem to be starting the app in dev mode to try the submission locally.

Yeah I actually tied before and I got that error so I just decided submitted this PR
Initially, I wanted it to be a draft PR but I needed an initial review
Drafting this until I have tested this and it works

@Excellencedev Excellencedev marked this pull request as draft January 3, 2026 16:51
@Excellencedev
Copy link
Author

@Byron I keep getting this error. Ans yes i killed all tasks on that port, restarted my computer, nothing worked
This is why I'm getting the blank screen
I just ran pnpm tauri dev --no-watch

@gitbutler/desktop:dev:
@gitbutler/desktop:dev: > @gitbutler/desktop@0.0.0 dev C:\Users\USER\3D Objects\gitbutler\apps\desktop
@gitbutler/desktop:dev: > vite --clearScreen false
@gitbutler/desktop:dev:
        Warn Waiting for your frontend dev server to start on http://localhost:1420/...
@gitbutler/desktop:dev: error when starting dev server:
@gitbutler/desktop:dev: Error: Port 1430 is already in use
@gitbutler/desktop:dev:     at Server.onError (file:///C:/Users/USER/3D%20Objects/gitbutler/node_modules/.pnpm/vite@6.3.5_@types+node@22.1_cdc70ec4a8da45ab48fc93d8b4204639/node_modules/vite/dist/node/chunks/dep-DBxKXgDP.js:25023:18)
@gitbutler/desktop:dev:     at Server.emit (node:events:518:28)
@gitbutler/desktop:dev:     at emitErrorNT (node:net:1975:8)
@gitbutler/desktop:dev:     at process.processTicksAndRejections (node:internal/process/task_queues:90:21)
@gitbutler/desktop:dev:  ELIFECYCLE  Command failed with exit code 1.
        Warn Waiting for your frontend dev server to start on http://localhost:1420/...

@Byron
Copy link
Collaborator

Byron commented Jan 5, 2026

This is an unfortunate issue on Windows, and from what I heard people had to go as far as to reboot to fix it. Maybe pkill node works, or working from a Git bash? If it works once after a reboot, removing --no-watch might be better as well, it then just has to work once and can keep running.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

@gitbutler/desktop @gitbutler/web rust Pull requests that update Rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gitea support

2 participants