Skip to main content

Diff Manifests via Gitiles API

Project description

๐Ÿ“‹ diffmanifests

A powerful tool for deep manifest comparison via Gerrit & Gitiles API

English | ็ฎ€ไฝ“ไธญๆ–‡

PyPI Coverage Status License Python Version


๐ŸŒŸ Overview

diffmanifests is a sophisticated CLI tool designed to reveal deeper differences between manifest files by leveraging the Gerrit and Gitiles APIs. It provides comprehensive change tracking, hashtag support, and detailed commit analysis for efficient manifest version management.

โœจ Key Highlights

  • ๐Ÿ” Deep Comparison: Analyze differences between manifest versions with precision
  • ๐Ÿท๏ธ Hashtag Integration: Full support for Gerrit hashtags and categorization
  • ๐Ÿ“Š Visual Reporting: Generate detailed JSON reports with comprehensive commit information
  • ๐Ÿ”„ API-Powered: Seamlessly integrates with Gerrit and Gitiles REST APIs
  • โšก Easy to Use: Simple command-line interface with clear configuration
  • ๐ŸŽจ VS Code Extension: Available for Visual Studio Code with GUI integration

๐Ÿ“‹ Table of Contents


๐Ÿ”ง Requirements

  • Python: >= 3.7
  • Dependencies:
    • colorama - Terminal color output
    • openpyxl - Excel file handling
    • requests - HTTP library
    • xmltodict - XML parsing

๐Ÿ“ฆ Installation

Install from PyPI

pip install diffmanifests

Upgrade to Latest Version

pip install diffmanifests --upgrade

Install from Source

git clone https://github.com/craftslab/diffmanifests.git
cd diffmanifests
pip install -e .

๐ŸŽจ VS Code Extension

A Visual Studio Code extension is available for seamless integration with your IDE!

Features

  • ๐Ÿ–ฑ๏ธ GUI Integration: Compare manifests directly from VS Code
  • ๐Ÿ“‹ Sidebar View: Dedicated sidebar with quick access to all features and settings
  • โšก Quick Actions: Compare manifests, check environment, and manage settings from sidebar
  • ๐Ÿ“‚ Recent Files: Track and quickly access recently compared files
  • โš™๏ธ Auto-Configuration: Automatic Python environment detection
  • ๐Ÿ“Š Multiple Output Formats: JSON and Excel support
  • ๐Ÿ”„ Auto-Installation: Automatically installs diffmanifests package
  • ๐ŸŒ Cross-Platform: Works on Windows, Ubuntu, and macOS

Quick Links

Installation

# Navigate to extension directory
cd vscode

# Install dependencies and build
npm install
npm run compile

# Package extension
vsce package

# Install in VS Code
code --install-extension diffmanifests-1.0.0.vsix

For detailed installation instructions, see the VS Code Extension Guide.


๐Ÿš€ Quick Start

Basic Usage

diffmanifests \
  --config-file config.json \
  --manifest1-file manifest1.xml \
  --manifest2-file manifest2.xml \
  --output-file output.json

Command Line Arguments

Argument Description Required
--config-file Path to configuration JSON file โœ…
--manifest1-file Path to first manifest XML file (older version) โœ…
--manifest2-file Path to second manifest XML file (newer version) โœ…
--output-file Path to output file for results (supports .json, .txt, .xlsx formats) โœ…

โš™๏ธ Configuration

Configuration parameters can be set in a JSON file. See the config directory for examples.

Configuration Structure

Create a config.json file with the following structure:

{
  "gerrit": {
    "url": "https://your-gerrit-instance.com",
    "user": "your-username",
    "pass": "your-password-or-token"
  },
  "gitiles": {
    "url": "https://your-gitiles-instance.com",
    "user": "your-username",
    "pass": "your-password-or-token",
    "retry": 3,
    "timeout": 30
  }
}

Configuration Parameters

Gerrit Settings

Parameter Type Description
url string Gerrit instance URL
user string Authentication username
pass string Authentication password or API token

Gitiles Settings

Parameter Type Description Default
url string Gitiles instance URL -
user string Authentication username -
pass string Authentication password or API token -
retry integer Number of retry attempts for failed requests 1
timeout integer Request timeout in seconds (-1 for no timeout) -1

๐ŸŽฏ Features

๐Ÿ“Š Manifest Comparison

Compare two manifest versions to identify changes between commits. The tool analyzes differences using a three-way comparison model:

branch

Comparison Logic:

  • Diagram A: Changes from commit 1 to commit 2
  • Diagram B: Alternative change paths
  • Diagram C: Merge scenarios

๐Ÿท๏ธ Hashtag Support

Comprehensive support for Gerrit hashtags through REST API v3.12.1, enabling better change tracking and categorization.

Key Benefits

โœ… Automatic hashtag extraction from Gerrit changes
โœ… Enhanced categorization and filtering capabilities
โœ… Seamless Gerrit workflow integration
โœ… Graceful fallback for changes without hashtags

Use Cases

Hashtags Use Case
["feature", "ui", "enhancement"] New UI features
["bugfix", "critical"] Critical bug fixes
["security", "cve"] Security-related changes
["refactor", "cleanup"] Code refactoring
[] Changes without hashtags

๐Ÿ“„ Output Format

The tool supports three output formats determined by the file extension:

  • .json - Structured JSON format for programmatic processing
  • .txt - Human-readable plain text format
  • .xlsx - Excel spreadsheet format for analysis and reporting

JSON Output Structure

{
  "author": "Developer Name <dev@example.com>",
  "branch": "master",
  "change": "https://gerrit.example.com/c/12345",
  "commit": "abc123def456789...",
  "committer": "Developer Name <dev@example.com>",
  "date": "2025-08-20 12:00:00 +0000",
  "diff": "ADD COMMIT",
  "hashtags": ["security", "cve", "bugfix"],
  "message": "Fix security vulnerability CVE-2025-1234",
  "repo": "platform/frameworks/base",
  "topic": "security-fix",
  "url": "https://android.googlesource.com/platform/frameworks/base/+/abc123def456789"
}

Output Fields

Field Type Description
author string Original commit author
branch string Target branch name
change string Gerrit change URL
commit string Git commit SHA
committer string Person who committed the change
date string Commit timestamp
diff string Type of change (ADD COMMIT, REMOVE COMMIT, etc.)
hashtags array List of associated hashtags
message string Commit message
repo string Repository path
topic string Gerrit topic name
url string Gitiles commit URL

๐Ÿ’ก Examples

Example 1: Basic Comparison (JSON Output)

diffmanifests \
  --config-file ./config/config.json \
  --manifest1-file ./data/android-11.xml \
  --manifest2-file ./data/android-12.xml \
  --output-file ./results/diff-output.json

Alternative Output Formats:

# Plain text format
diffmanifests \
  --config-file ./config/config.json \
  --manifest1-file ./data/android-11.xml \
  --manifest2-file ./data/android-12.xml \
  --output-file ./results/diff-output.txt

# Excel format
diffmanifests \
  --config-file ./config/config.json \
  --manifest1-file ./data/android-11.xml \
  --manifest2-file ./data/android-12.xml \
  --output-file ./results/diff-output.xlsx

Example 2: With Custom Configuration

# config.json
{
  "gerrit": {
    "url": "https://android-review.googlesource.com",
    "user": "developer",
    "pass": "your-token"
  },
  "gitiles": {
    "url": "https://android.googlesource.com",
    "user": "developer",
    "pass": "your-token",
    "retry": 5,
    "timeout": 60
  }
}

# Run comparison
diffmanifests \
  --config-file config.json \
  --manifest1-file old-manifest.xml \
  --manifest2-file new-manifest.xml \
  --output-file changes.json

Example 3: Analyzing Output

import json

# Load the output
with open('output.json', 'r') as f:
    changes = json.load(f)

# Filter security-related changes
security_changes = [
    c for c in changes
    if 'security' in c.get('hashtags', []) or 'cve' in c.get('hashtags', [])
]

print(f"Found {len(security_changes)} security-related changes")

๐Ÿ› ๏ธ Development

Setting Up Development Environment

# Clone the repository
git clone https://github.com/craftslab/diffmanifests.git
cd diffmanifests

# Install development dependencies
pip install -e .[dev]

# Run tests
pytest tests/

# Run tests with coverage
coverage run -m pytest tests/
coverage report

Running Tests

# Run all tests
pytest

# Run specific test module
pytest tests/differ/test_differ.py

# Run with verbose output
pytest -v

# Run with coverage report
pytest --cov=diffmanifests tests/

Project Scripts

Located in the script/ directory:

  • clean.sh - Clean build artifacts and cache files
  • dist.sh - Build distribution packages
  • install.sh - Install the package locally
  • run.sh - Run the tool with test data
  • test.sh - Execute test suite

๐Ÿ“œ License

This project is licensed under the Apache License 2.0.

See LICENSE for full details.


๐Ÿ“š References


๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

How to Contribute

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

๐Ÿ“ž Support


Made with โค๏ธ by craftslab

โญ Star this repository if you find it helpful!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

diffmanifests-3.7.9.tar.gz (22.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

diffmanifests-3.7.9-py2.py3-none-any.whl (18.9 kB view details)

Uploaded Python 2Python 3

File details

Details for the file diffmanifests-3.7.9.tar.gz.

File metadata

  • Download URL: diffmanifests-3.7.9.tar.gz
  • Upload date:
  • Size: 22.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for diffmanifests-3.7.9.tar.gz
Algorithm Hash digest
SHA256 3afa80d0fc3e797e23542846b2b9d97cc4a3069d92389d338fc89d78832fda54
MD5 886394fcf875f7ac2c2c4ba779d31065
BLAKE2b-256 4788c87e286420d1daccbd8ba9a3a04dd8b5d0a19321940e2e34778e52287057

See more details on using hashes here.

File details

Details for the file diffmanifests-3.7.9-py2.py3-none-any.whl.

File metadata

  • Download URL: diffmanifests-3.7.9-py2.py3-none-any.whl
  • Upload date:
  • Size: 18.9 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for diffmanifests-3.7.9-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 c2f0fe89111a38e41e2aeb59d19f7f0539ec07f09317e711cd4bc5904e5fe4ef
MD5 aa2d295b27fc5ef5ee2ec66f9f37e5ad
BLAKE2b-256 3d27164e3d2d90b6dedbf6d8da8bd00866206335bdf68678dc2eca283793a50d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page