mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-06 08:37:22 +00:00
Add upstream PR contribution system
Implements a complete workflow for non-technical users to contribute to open source projects: **New Features:** - ContributeButton component shows "Propose Changes" when project has upstream remote - ContributeWizard guides users through 5-step contribution process - PRStatusBadge shows existing PR status for current branch - Automatic forking when user lacks push permissions - OAuth and PAT authentication for GitHub, GitLab, Gitea/Codeberg - Pre-submission validation (type check + build) - Automatic remote configuration (upstream/origin) - PR creation and updates via Git host APIs **Git Host Abstraction:** - GitHostProvider interface for platform-agnostic operations - GitHubProvider with GitHub REST API v3 - GitLabProvider with GitLab REST API v4 - GiteaProvider for Gitea/Forgejo/Codeberg instances - Auto-detection of Git host from repository URL **Components:** - components/contribute/ContributeButton.tsx - Entry point button - components/contribute/ContributeWizard.tsx - Multi-step wizard UI - components/contribute/AuthStep.tsx - Authentication flow - components/contribute/DiffView.tsx - Changed files review - components/contribute/PRStatusBadge.tsx - PR status display **Hooks:** - hooks/useContribute.ts - Main contribution workflow orchestration **Context Updates:** - Extended GitSettings to include hostTokens for API authentication - Updated GitHubOAuth to save tokens in both formats **Integration:** - Added to ProjectView header (mobile and desktop) - Integrated with existing Git workflow - Works with existing OAuth callback system **Documentation:** - CONTRIBUTING_GUIDE.md with user guide and developer docs The system handles the entire fork → branch → commit → push → PR flow transparently, making open source contribution accessible to users without Git knowledge.
This commit is contained in:
1 parent
4226159f5d
commit
add685257b
18 files changed
+2670
-5
No files matched your search
@@ -2,6 +2,7 @@ import { useState, useCallback } from 'react';
|
||||
import { useGitSettings } from './useGitSettings';
|
||||
import { useAppContext } from './useAppContext';
|
||||
import { proxyUrl } from '@/lib/proxyUrl';
|
||||
import type { GitHostToken } from '@/contexts/GitSettingsContext';
|
||||
|
||||
interface GitHubOAuthState {
|
||||
isLoading: boolean;
|
||||
@@ -19,7 +20,7 @@ export function useGitHubOAuth() {
|
||||
isLoading: false,
|
||||
error: null,
|
||||
});
|
||||
const { addCredential } = useGitSettings();
|
||||
const { addCredential, addHostToken } = useGitSettings();
|
||||
const { config } = useAppContext();
|
||||
const { corsProxy } = config;
|
||||
|
||||
@@ -161,12 +162,21 @@ export function useGitHubOAuth() {
|
||||
|
||||
const userData = await userResponse.json();
|
||||
|
||||
// Store the credentials
|
||||
// Store the credentials (legacy format for existing push/pull operations)
|
||||
addCredential('https://github.com', {
|
||||
username: userData.login || 'git',
|
||||
password: tokenData.access_token,
|
||||
});
|
||||
|
||||
// Also store as host token for PR/contribution operations
|
||||
const hostToken: GitHostToken = {
|
||||
token: tokenData.access_token,
|
||||
username: userData.login,
|
||||
scopes: tokenData.scope ? tokenData.scope.split(',').map(s => s.trim()) : [],
|
||||
createdAt: Date.now(),
|
||||
};
|
||||
addHostToken('github.com', hostToken);
|
||||
|
||||
setState(prev => ({ ...prev, isLoading: false }));
|
||||
return true;
|
||||
} catch (error) {
|
||||
|
||||
Reference in new issue
Block a user