Thank you for your interest in contributing to PyElevate! This document provides guidelines and instructions for contributing.
Be respectful, inclusive, and professional in all interactions.
- Rust 1.70 or later
- Git
- A Unix-like environment (Linux, macOS, WSL2 on Windows)
# Clone the repository
git clone https://github.com/pro-grammer-SD/pyelevate
cd pyelevate
# Build the project
cargo build
# Run tests
cargo test
# Run with logging
RUST_LOG=debug cargo rungit checkout -b feature/your-feature-name
# or
git checkout -b fix/issue-numberUse descriptive names:
feature/fuzzy-search-improvementfix/pypi-timeout-handlingdocs/update-readme
- Keep changes focused and logical
- Follow Rust conventions (use
cargo fmt) - Add tests for new functionality
- Update documentation as needed
# Format code
cargo fmt
# Check for issues
cargo clippy -- -D warnings
# Run tests
cargo testUse clear, descriptive commit messages:
Add fuzzy search for package filtering
- Implement fuzzy matcher integration
- Add /: search hotkey binding
- Update help text with search instructions
- Add tests for search filtering
git push origin feature/your-feature-nameThen create a Pull Request on GitHub with:
- Clear title describing the change
- Description of what changed and why
- Reference to related issues (e.g.,
Fixes #123) - Screenshots for UI changes
src/
βββ main.rs # CLI and event loop
βββ lib.rs # Module definitions
βββ app.rs # State management
βββ models.rs # Data structures
βββ parser.rs # requirements.txt parsing
βββ pypi.rs # PyPI API client
βββ ui.rs # Ratatui rendering
βββ upgrade.rs # Upgrade logic
βββ styles.rs # Theming
-
Plan the architecture
- Update relevant modules
- Design data flow
- Consider edge cases
-
Implement
- Add code following style guidelines
- Write tests
- Document public APIs
-
Test
- Unit tests:
cargo test - Integration tests
- Manual testing with example files
- Unit tests:
-
Document
- Update README.md if user-facing
- Add doc comments to public items
- Update CHANGELOG if applicable
Place tests in the same file as the code:
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_feature_behavior() {
// Arrange
let input = "test";
// Act
let result = some_function(input);
// Assert
assert_eq!(result, "expected");
}
}For async code, use #[tokio::test]:
#[tokio::test]
async fn test_async_operation() {
let result = async_function().await;
assert!(result.is_ok());
}# All tests
cargo test
# Specific test
cargo test test_feature_behavior
# With output
cargo test -- --nocapture
# Specific module
cargo test --lib app::tests/// Fetches the latest version of a package from PyPI.
///
/// # Arguments
/// * `package_name` - The name of the package
///
/// # Returns
/// * `Result<String>` - Latest version or error
///
/// # Example
/// ```
/// let version = client.fetch_latest_version("requests").await?;
/// ```
pub async fn fetch_latest_version(&self, package_name: &str) -> Result<String> {
// Implementation
}cargo test --doc- Use async/await for I/O operations
- Cache PyPI responses
- Minimize allocations in hot paths
- Profile with:
cargo flamegraph
# Debug build with logging
RUST_LOG=debug cargo run
# More verbose logging
RUST_LOG=trace cargo run
# Attach debugger (lldb on macOS)
rust-lldb ./target/debug/pyelevate- Code compiles:
cargo build --release - Tests pass:
cargo test - Formatted:
cargo fmt - No warnings:
cargo clippy - Documentation updated
- Commits are clean and logical
## Description
Brief description of changes
## Type of Change
- [ ] Bug fix
- [ ] New feature
- [ ] Breaking change
- [ ] Documentation update
## Related Issues
Fixes #issue_number
## Testing
Describe how to test these changes
## Checklist
- [ ] Code compiles
- [ ] All tests pass
- [ ] New tests added
- [ ] Documentation updated- Automated checks must pass (CI/CD)
- Code review by maintainers
- Approval and merge
Include:
- PyElevate version
- OS and Rust version
- Steps to reproduce
- Expected vs actual behavior
- Relevant logs (
--verboseoutput)
Include:
- Use case/motivation
- Proposed behavior
- Alternatives considered
- Acceptance criteria
- Check existing issues and discussions
- Open a new discussion
- Contact maintainers
Contributors will be recognized in:
- CONTRIBUTORS.md file
- Release notes
- Project documentation
Thank you for contributing! π