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

+14 -1
View File
@@ -19,6 +19,7 @@ import { StarButton } from '@/components/StarButton';
import { useBuildProject } from '@/hooks/useBuildProject';
import { useIsProjectPreviewable } from '@/hooks/useIsProjectPreviewable';
import { useConsoleError } from '@/hooks/useConsoleError';
import { ContributeButton, PRStatusBadge } from '@/components/contribute';
export function ProjectView() {
const { projectId } = useParams<{ projectId: string }>();
@@ -157,6 +158,12 @@ export function ProjectView() {
<div className="flex items-center gap-2">
{project ? (
<>
<PRStatusBadge projectDir={`/projects/${project.id}`} />
<ContributeButton
projectDir={`/projects/${project.id}`}
variant="ghost"
size="sm"
/>
<StarButton
projectId={project.id}
projectName={project.name}
@@ -362,10 +369,16 @@ export function ProjectView() {
</div>
</div>
{/* Right side - Star and Actions Menu */}
{/* Right side - PR Status, Contribute, Star and Actions Menu */}
<div className="flex items-center gap-2">
{project ? (
<>
<PRStatusBadge projectDir={`/projects/${project.id}`} />
<ContributeButton
projectDir={`/projects/${project.id}`}
variant="ghost"
size="sm"
/>
<StarButton
projectId={project.id}
projectName={project.name}