Skip to main content

Script-driven code changes with automated merge requests

Project description

repoactive - Script-driven code changes with automated merge requests

Warning: This project is in an early stage of development. Use at your own risk.

repoactive runs your scripts against a git repository and optionally keeps the corresponding merge requests up to date. You write the scripts that produce the code changes; repoactive handles the rest - branches, commits, and (with --create-prs) the full MR lifecycle.

How it works

You configure one or more jobs, each with a script (any shell command or executable) that modifies the repository's working tree. repoactive runs each script, captures the resulting diff, and records the change locally. With --create-prs it also:

  • opens a new merge request if one does not already exist for that job, or
  • updates the existing merge request branch if the diff has changed.

Branches and MR descriptions are managed automatically - the only code you need to write is the script that produces the change.

[your script] → diff → repoactive → branch
                                       ↓ (with --push or --create-prs)
                                    git push → merge request
                                                    ↑ (with --create-prs)
                                            (create or update)
  1. repoactive creates a new commit on top of the base branch or on top of other repoactive managed branches.
  2. It runs the job's script against the working tree.
  3. If the script produced a diff, it records the change. With --push or --create-prs, it pushes the branch; with --create-prs, it also creates or updates the merge request.
  4. If the script produced no diff, the branch is reset to the base. With --push or --create-prs, the reset branch is pushed without opening or updating an MR.

Use cases

  • Keeping generated files (API clients, protobuf bindings, lock files) in sync with their sources
  • Applying organization-wide refactors or policy changes across many repositories
  • Automating any periodic code transformation that should go through a review process

Configuration

repoactive is configured via .repoactive.toml in the repository root (or passed via --config).

[job-defaults]
# Prefix prepended to job.name to form the branch name
branch_prefix = "repoactive/"
# Prefix prepended to every MR/PR title (set to "" to disable)
mr_title_prefix = "[repoactive] "
# Prefix prepended to every commit title (set to "" to disable)
commit_title_prefix = "[repoactive] "
# Labels applied to every MR/PR unless overridden per job
labels = ["repoactive"]

[[job]]
# Unique identifier - branch name is always <branch_prefix><name>
name = "regenerate-api-client"
# Script run in the repo working directory; non-zero exit = failure
command = "python scripts/regen_api.py"
# MR/PR title
title = "api: regenerate API client"
# Optional: MR description
description = "Automated regeneration of the API client from the OpenAPI spec."
# Optional: extra labels (merged with job-defaults.labels)
labels = ["automated", "api"]
# Optional: target branch (default: repo default branch)
base_branch = "main"
# Optional: open the MR/PR as a draft (default: false)
draft = false
# Optional: create an MR/PR for this job (default: true). Set to false to
# push the branch without opening an MR/PR.
create_mr = true
# Optional: append the job's command and its output to the commit message
# (default: true). Set to false to keep the commit message clean.
output_in_commit = true

[[job]]
name = "sync-license-headers"
command = "./scripts/add_license_headers.sh"
title = "sync license headers"

[[job]]
name = "integration-tests-update"
command = "./scripts/update_integration_tests.py"
title = "tests: update integration tests"
# Optional: run this job on top of the merged output of the listed jobs
depends_on = ["regenerate-api-client", "sync-license-headers"]

For public GitHub.com or GitLab.com repositories no platform declaration is needed — repoactive detects the remote URL automatically. To use a self-hosted instance, add a [[platform]] section:

[[platform]]
# Base URL of the platform instance
url = "https://gitlab.example.com"
# Name of the env var holding the API token
token_env = "GITLAB_TOKEN"
# type must be either "github" or "gitlab"
type = "gitlab"

The branch for each job is always job-defaults.branch_prefix + job.name. Secrets are kept out of the config file by referencing environment variable names rather than inline values.

When depends_on is set, repoactive starts the job's script from a working tree that has all listed dependency branches merged together, rather than from the plain base branch. The resulting MR branch will therefore include both the dependency jobs and the new job on top. Links to the parent MRs are automatically added to the MR description.

Usage

# Print the installed version and exit
repoactive --version
repoactive run [OPTIONS] [JOBS]...

Run all configured jobs (or a named subset - dependencies are auto-included):

# Apply all jobs locally (no push, no MR creation)
repoactive run

# Apply specific jobs locally
repoactive run regenerate-api-client sync-license-headers

# Push branches to the remote without creating MRs
repoactive run --push

# Push branches and create or update merge requests
repoactive run --create-prs

# Enable debug logging
repoactive run --debug
Option Short Description
--config PATH -c Config file (default: .repoactive.toml); repeat to merge
--repo PATH -r jj repository path (default: .)
--push Push branches to the remote repository
--create-prs Push branches and create or update pull requests
--debug -d Enable debug logging

Validating configuration

repoactive validate-config [OPTIONS]

Check that a config file is syntactically and semantically valid without running any jobs:

# Validate the default .repoactive.toml
repoactive validate-config

# Validate a specific config file
repoactive validate-config --config myconfig.toml

# Validate a merged config (same merging rules as `run`)
repoactive validate-config --config base.toml --config override.toml

On success the command prints Config OK: N job(s) defined. and exits with code 0. On failure it prints the validation error to stderr and exits with code 1.

Validation checks include unknown keys, missing required fields, invalid depends_on references, and circular job dependencies.

Option Short Description
--config PATH -c Config file (default: .repoactive.toml); repeat to merge

Requirements

  • Python 3.11 or later
  • jj (Jujutsu) - repoactive uses jj to manage branches and commits in the target repository
  • A GitLab or GitHub API token exposed via the environment variable named in platform.token_env

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

repoactive-0.0.5.tar.gz (23.7 kB view details)

Uploaded Source

Built Distribution

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

repoactive-0.0.5-py3-none-any.whl (27.2 kB view details)

Uploaded Python 3

File details

Details for the file repoactive-0.0.5.tar.gz.

File metadata

  • Download URL: repoactive-0.0.5.tar.gz
  • Upload date:
  • Size: 23.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for repoactive-0.0.5.tar.gz
Algorithm Hash digest
SHA256 0f97e5a40b48e0a33e95b1a745c5737ad1c0bf7df77c42fa5648aeb648f36f9b
MD5 3d2862f20bf0d940026037762a1083bc
BLAKE2b-256 b1cfd85771504b3ff0a480ab9d6ab165e23de948acae514b76fadae77e97f4ef

See more details on using hashes here.

Provenance

The following attestation bundles were made for repoactive-0.0.5.tar.gz:

Publisher: publish.yml on schmir/repoactive

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file repoactive-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: repoactive-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 27.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for repoactive-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 47ba1de44ba391b85d7cccd2e5bc0ee3a572e07071a891824a69f2e9416e39e0
MD5 f6a45f964ff10ba06cd85d13d5cffb91
BLAKE2b-256 1b20ea94c6c9f9c6c567cf731992752d300a607b0bb76fcc2f63b4d90ed867db

See more details on using hashes here.

Provenance

The following attestation bundles were made for repoactive-0.0.5-py3-none-any.whl:

Publisher: publish.yml on schmir/repoactive

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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