Contribution Workflow
This guide walks you through the complete process of contributing to XOOPS, from initial setup to merged pull request.
Prerequisites
Section titled “Prerequisites”Before you start contributing, ensure you have:
- Git installed and configured
- GitHub account (free)
- PHP 7.4+ for XOOPS development
- Composer for dependency management
- Basic knowledge of Git workflows
- Familiarity with Code of Conduct
Step 1: Fork the Repository
Section titled “Step 1: Fork the Repository”On GitHub Web Interface
Section titled “On GitHub Web Interface”- Navigate to the repository (e.g.,
XOOPS/XoopsCore27) - Click the Fork button in the top-right corner
- Select where to fork (your personal account)
- Wait for the fork to complete
Why Fork?
Section titled “Why Fork?”- You get your own copy to work on
- Maintainers don’t need to manage many branches
- You have full control of your fork
- Pull Requests reference your fork and the upstream repo
Step 2: Clone Your Fork Locally
Section titled “Step 2: Clone Your Fork Locally”# Clone your fork (replace YOUR_USERNAME)git clone https://github.com/YOUR_USERNAME/XoopsCore27.gitcd XoopsCore27
# Add upstream remote to track original repositorygit remote add upstream https://github.com/XOOPS/XoopsCore27/.git
# Verify remotes are set correctlygit remote -v# origin https://github.com/YOUR_USERNAME/XoopsCore27.git (fetch)# origin https://github.com/YOUR_USERNAME/XoopsCore27.git (push)# upstream https://github.com/XOOPS/XoopsCore27/.git (fetch)# upstream https://github.com/XOOPS/XoopsCore27/.git (nofetch)Step 3: Set Up Development Environment
Section titled “Step 3: Set Up Development Environment”Install Dependencies
Section titled “Install Dependencies”# Install Composer dependenciescomposer install
# Install development dependenciescomposer install --dev
# For module developmentcd modules/mymodulecomposer installConfigure Git
Section titled “Configure Git”# Set your Git identitygit config user.name "Your Name"git config user.email "your.email@example.com"
# Optional: Set global Git configgit config --global user.name "Your Name"git config --global user.email "your.email@example.com"Run Tests
Section titled “Run Tests”# Make sure tests pass in clean state./vendor/bin/phpunit
# Run specific test suite./vendor/bin/phpunit --testsuite unitStep 4: Create Feature Branch
Section titled “Step 4: Create Feature Branch”Branch Naming Convention
Section titled “Branch Naming Convention”Follow this pattern: <type>/<description>
Types:
feature/- New featurefix/- Bug fixdocs/- Documentation onlyrefactor/- Code refactoringtest/- Test additionschore/- Maintenance, tooling
Examples:
# Feature branchgit checkout -b feature/add-two-factor-auth
# Bug fix branchgit checkout -b fix/prevent-xss-in-forms
# Documentation branchgit checkout -b docs/update-api-guide
# Always branch from upstream/main (or develop)git checkout -b feature/my-feature upstream/mainKeep Branch Up to Date
Section titled “Keep Branch Up to Date”# Before you start work, sync with upstreamgit fetch upstreamgit merge upstream/main
# Later, if upstream has changedgit fetch upstreamgit rebase upstream/mainStep 5: Make Your Changes
Section titled “Step 5: Make Your Changes”Development Practices
Section titled “Development Practices”- Write code following PHP Standards
- Write tests for new functionality
- Update documentation if needed
- Run linters and code formatters
Code Quality Checks
Section titled “Code Quality Checks”# Run all tests./vendor/bin/phpunit
# Run with coverage./vendor/bin/phpunit --coverage-html coverage/
# Run PHP CS Fixer./vendor/bin/php-cs-fixer fix --dry-run
# Run PHPStan static analysis./vendor/bin/phpstan analyse class/ src/Commit Good Changes
Section titled “Commit Good Changes”# Check what you changedgit statusgit diff
# Stage specific filesgit add class/MyClass.phpgit add tests/MyClassTest.php
# Or stage all changesgit add .
# Commit with descriptive messagegit commit -m "feat(auth): add two-factor authentication support"Step 6: Keep Branch in Sync
Section titled “Step 6: Keep Branch in Sync”While working on your feature, the main branch might advance:
# Fetch latest changes from upstreamgit fetch upstream
# Option A: Rebase (preferred for clean history)git rebase upstream/main
# Option B: Merge (simpler but adds merge commits)git merge upstream/main
# If conflicts occur, resolve them then:git add .git rebase --continue # or git merge --continueStep 7: Push to Your Fork
Section titled “Step 7: Push to Your Fork”# Push your branch to your forkgit push origin feature/my-feature
# On subsequent pushesgit push
# If you rebased, you might need force push (use carefully!)git push --force-with-lease origin feature/my-featureStep 8: Create Pull Request
Section titled “Step 8: Create Pull Request”On GitHub Web Interface
Section titled “On GitHub Web Interface”- Go to your fork on GitHub
- You’ll see a notification to create a PR from your branch
- Click “Compare & pull request”
- Or manually click “New pull request” and select your branch
PR Title and Description
Section titled “PR Title and Description”Title Format:
<type>(<scope>): <subject>Examples:
feat(auth): add two-factor authenticationfix(forms): prevent XSS in text inputdocs: update installation guiderefactor(core): improve performanceDescription Template:
## DescriptionBrief explanation of what this PR does.
## Changes- Changed X from A to B- Added feature Y- Fixed bug Z
## Type of Change- [ ] New feature (adds new functionality)- [ ] Bug fix (fixes an issue)- [ ] Breaking change (API/behavior change)- [ ] Documentation update
## Testing- [ ] Added tests for new functionality- [ ] All existing tests pass- [ ] Manual testing performed
## Screenshots (if applicable)Include before/after screenshots for UI changes.
## Related IssuesCloses #123Related to #456
## Checklist- [ ] Code follows style guidelines- [ ] Self-reviewed own code- [ ] Commented complex code- [ ] Updated documentation- [ ] No new warnings generated- [ ] Tests pass locallyPR Review Checklist
Section titled “PR Review Checklist”Before submitting, ensure:
- Code follows PHP Standards
- Tests are included and pass
- Documentation updated (if needed)
- No merge conflicts
- Commit messages are clear
- Related issues are referenced
- PR description is detailed
- No debug code or console logs
Step 9: Respond to Feedback
Section titled “Step 9: Respond to Feedback”During Code Review
Section titled “During Code Review”- Read comments carefully - Understand the feedback
- Ask questions - If unclear, ask for clarification
- Discuss alternatives - Respectfully debate approaches
- Make requested changes - Update your branch
- Force-push updated commits - If rewriting history
# Make changesgit add .git commit --amend # Modify last commitgit push --force-with-lease origin feature/my-feature
# Or add new commitsgit commit -m "Address feedback on PR review"git push origin feature/my-featureExpect Iteration
Section titled “Expect Iteration”- Most PRs require multiple review rounds
- Be patient and constructive
- View feedback as learning opportunity
- Maintainers may suggest refactors
Step 10: Merge and Cleanup
Section titled “Step 10: Merge and Cleanup”After Approval
Section titled “After Approval”Once maintainers approve and merge:
- GitHub auto-merges or maintainer clicks merge
- Your branch is deleted (usually automatic)
- Changes are in upstream
Local Cleanup
Section titled “Local Cleanup”# Switch to main branchgit checkout main
# Update main with merged changesgit fetch upstreamgit merge upstream/main
# Delete local feature branchgit branch -d feature/my-feature
# Delete from your fork (if not auto-deleted)git push origin --delete feature/my-featureWorkflow Diagram
Section titled “Workflow Diagram”graph LR A[Fork Repository] --> B[Clone Fork] B --> C[Create Branch] C --> D[Make Changes] D --> E[Commit & Push] E --> F[Create PR] F --> G{Review} G -->|Approved| H[Merge] G -->|Changes Needed| I[Update PR] I --> G H --> J[Cleanup] J --> K[Done]Common Scenarios
Section titled “Common Scenarios”Syncing Before Starting
Section titled “Syncing Before Starting”# Always start freshgit fetch upstreamgit checkout -b feature/new-thing upstream/mainAdding More Commits
Section titled “Adding More Commits”# Just push againgit add .git commit -m "feat: additional changes"git push origin feature/new-thingFixing Mistakes
Section titled “Fixing Mistakes”# Last commit has wrong messagegit commit --amend -m "Correct message"git push --force-with-lease
# Revert to previous state (careful!)git reset --soft HEAD~1 # Keep changesgit reset --hard HEAD~1 # Discard changesHandling Merge Conflicts
Section titled “Handling Merge Conflicts”# Rebase and resolve conflictsgit fetch upstreamgit rebase upstream/main
# Edit conflicted files to resolve# Then continuegit add .git rebase --continuegit push --force-with-leaseBest Practices
Section titled “Best Practices”- Keep branches focused on single issues
- Make small, logical commits
- Write descriptive commit messages
- Update your branch frequently
- Test before pushing
- Document changes
- Be responsive to feedback
- Work directly on main/master branch
- Mix unrelated changes in one PR
- Commit generated files or node_modules
- Force push after PR is public (use —force-with-lease)
- Ignore code review feedback
- Create huge PRs (break into smaller ones)
- Commit sensitive data (API keys, passwords)
Tips for Success
Section titled “Tips for Success”Communicate
Section titled “Communicate”- Ask questions in issues before starting work
- Ask for guidance on complex changes
- Discuss approach in the PR description
- Respond to feedback promptly
Follow Standards
Section titled “Follow Standards”- Review PHP Standards
- Check Issue Reporting guidelines
- Read Contributing Overview
- Follow Pull Request Guidelines
Learn the Codebase
Section titled “Learn the Codebase”- Read existing code patterns
- Study similar implementations
- Understand the architecture
- Check Core Concepts
Related Documentation
Section titled “Related Documentation”- Code of Conduct
- Pull Request Guidelines
- Issue Reporting
- PHP Coding Standards
- Contributing Overview
#xoops #git #github #contributing #workflow #pull-request