Skip to content

albertywu/revue

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Revue

A modern, patch-based code review tool designed for scalability and high availability while maintaining simplicity for single-node deployments. Revue provides an alternative to Phabricator with a focus on performance and modern development practices.

Features

  • Patch-based workflow: Similar to Phabricator/arc, not git branch dependent
  • REST API: Comprehensive API for all operations
  • CLI tool: Command-line interface for developers
  • Review workflow: Create, approve, reject, and merge reviews
  • Comments: General and inline comments on patches
  • Herald system: Event-driven automation with V8 JavaScript rules
  • PostgreSQL storage: Reliable and scalable data storage
  • Modern Go backend: High-performance server implementation

Architecture

┌─────────────────┐    ┌─────────────────┐    ┌─────────────────┐
│   CLI Tool      │    │   REST API      │    │   Herald Engine │
│   (cr)          │────│   (Go/Gin)      │────│   (V8 isolates) │
└─────────────────┘    └─────────────────┘    └─────────────────┘
                                │
                       ┌─────────────────┐
                       │   PostgreSQL    │
                       │   Database      │
                       └─────────────────┘

Installation

Prerequisites

  • Go 1.21 or later
  • PostgreSQL 12 or later
  • Git

Build from source

git clone https://github.com/albertywu/revue
cd revue
go mod download
go build -o cr

Usage

1. Start the server

# Create PostgreSQL database
createdb revue

# Start the server (runs migrations automatically)
./cr server --port 8080 --db-url "postgres://localhost/revue?sslmode=disable"

2. Set up environment variables

export REVUE_SERVER_URL="http://localhost:8080"
export REVUE_USER_ID="1"  # Your user ID

3. Create a user

curl -X POST http://localhost:8080/api/v1/users \
  -H "Content-Type: application/json" \
  -d '{"username": "john", "email": "[email protected]", "display_name": "John Doe"}'

4. Use the CLI tool

# Create a patch and merge request from your current git changes
./cr diff --title "Fix authentication bug" --message "This fixes the issue with login validation" --reviewers alice,bob

# List merge requests
./cr list

# Show merge request details
./cr show 123

# Approve a merge request
./cr approve 123 --comment "Looks good to me!"

# Add a comment
./cr comment 123 "Please add unit tests for this change"

# Add an inline comment
./cr comment 123 "This function could be optimized" --file "src/auth.go" --line 42

# Reject a merge request
./cr reject 123 --comment "Needs more error handling"

# Land (merge) an approved merge request
./cr land 123

API Endpoints

Users

  • POST /api/v1/users - Create user
  • GET /api/v1/users/{id} - Get user by ID
  • GET /api/v1/users - List users
  • PUT /api/v1/users/{id} - Update user
  • DELETE /api/v1/users/{id} - Delete user

Patches

  • POST /api/v1/patches - Create patch
  • GET /api/v1/patches/{id} - Get patch by ID
  • GET /api/v1/patches - List patches
  • PUT /api/v1/patches/{id} - Update patch
  • DELETE /api/v1/patches/{id} - Delete patch

Merge Requests

  • POST /api/v1/merge-requests - Create merge request
  • GET /api/v1/merge-requests/{id} - Get merge request by ID
  • GET /api/v1/merge-requests - List merge requests
  • PUT /api/v1/merge-requests/{id} - Update merge request
  • DELETE /api/v1/merge-requests/{id} - Delete merge request
  • GET /api/v1/merge-requests/{id}/comments - Get merge request comments
  • GET /api/v1/merge-requests/{id}/reviews - Get merge request reviews

Reviews

  • POST /api/v1/reviews - Create review action
  • GET /api/v1/reviews/{id} - Get review by ID
  • PUT /api/v1/reviews/{id} - Update review
  • DELETE /api/v1/reviews/{id} - Delete review

Comments

  • POST /api/v1/comments - Create comment
  • GET /api/v1/comments/{id} - Get comment by ID
  • PUT /api/v1/comments/{id} - Update comment
  • DELETE /api/v1/comments/{id} - Delete comment

Herald Rules

Herald rules allow you to automate actions based on events in Revue. Rules are written in JavaScript and executed in isolated V8 contexts.

Example Herald Rule

// Rule to trigger CI for JavaScript/TypeScript changes
export function shouldTriggerRule(context) {
  if (context.noun === "patch" && context.verb === "created") {
    return context.patch.files.some(file => 
      file.path.endsWith('.js') || 
      file.path.endsWith('.ts') || 
      file.path.endsWith('.jsx') || 
      file.path.endsWith('.tsx')
    );
  }
  return false;
}

Herald Actions

  • webhook: Send HTTP POST to external service
  • comment: Add automated comment to review
  • ci_trigger: Trigger CI/CD pipeline

Database Schema

Revue uses PostgreSQL with the following main tables:

  • users - User information
  • patches - Git diffs and metadata
  • merge_requests - Merge request state and metadata
  • reviews - Review actions (approve/reject/comment)
  • comments - General and inline comments
  • events - Event log for Herald system
  • herald_rules - Automation rules

Configuration

Environment Variables

  • REVUE_SERVER_URL - API server URL (default: http://localhost:8080)
  • REVUE_USER_ID - Current user ID for CLI operations

CLI Configuration

Create ~/.cr.yaml:

server_url: "http://localhost:8080"
user_id: 1
default_reviewers:
  - alice
  - bob

Development

Running Tests

go test ./...

Database Migrations

Migrations are run automatically when the server starts. Migration files are in the migrations/ directory.

Adding New Features

  1. Update database schema in migrations/
  2. Add models in internal/models/
  3. Implement repository methods in internal/repository/
  4. Add API handlers in internal/server/handlers/
  5. Update CLI commands in cmd/

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests
  5. Submit a pull request

License

MIT License - see LICENSE file for details.

About

A modern patch-based code review tool

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published