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:
shakespeare.diy committed 2025-10-14 21:29:15 -05:00
1 parent 4226159f5d
commit add685257b
18 files changed
+2670 -5

No files matched your search

+45
View File
@@ -0,0 +1,45 @@
export * from './types';
export { GitHubProvider } from './GitHubProvider';
export { GitLabProvider } from './GitLabProvider';
export { GiteaProvider } from './GiteaProvider';
import { GitHubProvider } from './GitHubProvider';
import { GitLabProvider } from './GitLabProvider';
import { GiteaProvider } from './GiteaProvider';
import { detectGitHost } from './types';
import type { GitHostProvider, GitHostConfig } from './types';
/**
* Create a Git host provider instance based on the repository URL
*/
export function createGitHostProvider(
url: string,
config: GitHostConfig,
corsProxy?: string
): GitHostProvider | null {
const hostType = detectGitHost(url);
switch (hostType) {
case 'github':
return new GitHubProvider(config, corsProxy);
case 'gitlab':
return new GitLabProvider(config, corsProxy);
case 'codeberg':
return new GiteaProvider(config, 'https://codeberg.org/api/v1', 'Codeberg', corsProxy);
case 'gitea':
// Extract API URL from repository URL
try {
const parsed = new URL(url.replace(/^git@/, 'https://').replace(/\.git$/, ''));
const apiUrl = `${parsed.protocol}//${parsed.hostname}/api/v1`;
return new GiteaProvider(config, apiUrl, 'Gitea', corsProxy);
} catch {
return null;
}
default:
return null;
}
}