Skip to main content

Large scale VCS change management

Project description

Silver-Platter makes it possible to contribute automatable changes to source code in a version control system (codemods).

It automatically creates a local checkout of a remote repository, makes user-specified changes, publishes those changes on the remote hosting site and then creates a pull request.

In addition to that, it can also perform basic maintenance on branches that have been proposed for merging - such as restarting them if they have conflicts due to upstream changes.

Silver-Platter powers the Debian Janitor (https://janitor.debian.org/) and Kali Janitor (https://kali.janitor.org/). However, it is an independent project and can be used fine as a standalone tool. The UI is still a bit rough around the edges, I’d be grateful for any feedback from people using it - please file bugs in the issue tracker at https://github.com/jelmer/silver-platter/issues/new.

Getting started

To log in to a code-hosting site, use svp login:

svp login https://github.com/

The simplest way to create a change as a merge proposal is to run something like:

svp run --mode=propose ./framwork.sh https://github.com/jelmer/dulwich

where framwork.sh makes some modifications to a working copy and prints the commit message and body for the pull request to standard out. For example:

#!/bin/sh
sed -i 's/framwork/framework/' README.rst
echo "Fix common typo: framwork ⇒ framework"

If you leave pending changes, silver-platter will automatically create a commit and use the output from the script as the commit message. Scripts also create their own commits if they prefer - this is especially useful if they would like to create multiple commits.

Recipes

To make this process a little bit easier to repeat, recipe files can be used. For the example above, we could create a framwork.yaml with the following contents:

---
name: framwork
command: |-
 sed -i 's/framwork/framework/' README.rst
 echo "Fix common typo: framwork ⇒ framework"
mode: propose
merge-request:
  commit-message: Fix a typo
  description:
    markdown: |-
      I spotted that we often mistype *framework* as *framwork*.

To execute this recipe, run:

svp run --recipe=framwork.yaml https://github.com/jelmer/dulwich

See example.yaml for an example recipe with plenty of comments.

In addition, you can run a particular recipe over a set of repositories by specifying a candidate list. For example, if candidates.yaml looked like this:

---
- url: https://github.com/dulwich/dulwich
- url: https://github.com/jelmer/xandikos

then the following command would process each repository in turn:

svp run --recipe=framwork.yaml --candidates=candidates.yaml

Batch Mode

Use batch mode when you’re going to make a large number of changes and would like to review or modify the diffs before sending them out:

svp batch generate --recipe=framwork.yaml --candidates=candidate.syml framwork

This will then create a directory called “framwork”, with a file called batch.yaml with all the pending changes:

name: framwork
work:
- url: https://github.com/dulwich/dulwich
  name: dulwich
  description: I spotted that we often mistype *framework* as *framwork*.
  commit-message: Fix a typo
  mode: propose
- url: https://github.com/jelmer/xandikos
  name: dulwich
  description: I spotted that we often mistype *framework* as *framwork*.
  commit-message: Fix a typo
  mode: propose
recipe: ../framwork.yaml

For each of the candidates, a clone with the changes is created. You can introspect and modify the clones as appropriate.

After you review the changes, edit batch.yaml as you see fit - remove entries that don’t appear to be correct, edit the details for the merge requests, etc.

Once you’re happy, you can publish the results:

svp batch publish framwork

This will publish all the changes, using the mode and parameters specified in batch.yaml.

batch.yaml is automatically stripped of any entries in work that have fully landed, i.e. where the pull request has been merged or where the changes were pushed to the origin.

To check up on the status of your changes, run svp batch status:

svp batch status framwork

And to refresh any merge proposals that may have become out of date, run publish again:

svp batch publish framwork

Supported hosters

At the moment, the following code hosters are supported:

Working with Debian packages

Several common operations for Debian packages have dedicated subcommands under the debian-svp command. These will also automatically look up packaging repository location for any Debian package names that are specified.

  • upload-pending: Build and upload a package and push/propose the changelog updates.

  • run: Similar to svp run but specific to Debian packages: it ensures that the upstream and pristine-tar branches are available as well, can optionally update the changelog, and can test that the branch still builds.

Some Debian-specific example recipes are provided in examples/debian/:

  • lintian-fixes.yaml: Run the lintian-brush command to fix common issues reported by lintian.

  • new-upstream-release.yaml: Merge in a new upstream release.

  • multi-arch-hints.yaml: Apply multi-arch hints.

  • orphan.yaml: Mark a package as orphaned, update its Maintainer field and move it to the common Debian salsa group.

  • rules-requires-root.yaml: Mark a package as “Rules-Requires-Root: no”

  • cme.yaml: Run “cme fix dpkg”, from the cme package.

debian-svp run takes package name arguments that will be resolved to repository locations from the Vcs-Git field in the package.

See debian-svp COMMAND --help for more details.

Examples running debian-svp:

# Create merge proposal running lintian-brush against Samba
debian-svp run --recipe=examples/lintian-brush.yaml samba

# Upload pending changes for tdb
debian-svp upload-pending tdb

# Upload pending changes for any packages maintained by Jelmer,
# querying vcswatch.
debian-svp upload-pending --vcswatch --maintainer jelmer@debian.org

# Import the latest upstream release for tdb, without testing
# the build afterwards.
debian-svp run --recipe=examples/debian/new-upstream-release.yaml \
    --no-build-verify tdb

# Apply multi-arch hints to tdb
debian-svp run --recipe=examples/debian/multiarch-hints.yaml tdb

The following environment variables are provided for Debian packages:

  • DEB_SOURCE: the source package name

  • DEB_UPDATE_CHANGELOG: indicates whether a changelog entry should be added. Either “leave” (leave alone) or “update” (update changelog).

Credentials

The svp hosters subcommand can be used to display the hosting sites that silver-platter is aware of:

svp hosters

And to log into a new hosting site, simply run svp login BASE-URL, e.g.:

svp login https://launchpad.net/

Exit status

svp run will exit 0 if no changes have been made, 1 if at least one repository has been changed and 2 in case of trouble.

Python API

Other than the command-line API, silver-platter also has a Python API. The core class is the Workspace context manager, which exists in two forms:

  • silver_platter.workspace.Workspace (for generic projects)

  • silver_platter.debian.Workspace (for Debian packages)

An example, adding a new entry to a changelog file in the dulwich Debian package and creating a merge proposal with that change:

from silver_platter.debian import Workspace
import subprocess

with Workspace.from_apt_package(package="dulwich") as ws:
    subprocess.check_call(['dch', 'some change'], cwd=ws.path)
    ws.commit()  # Behaves like debcommit
    ws.publish(mode='propose')

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

silver-platter-0.5.20.tar.gz (51.6 kB view hashes)

Uploaded Source

Built Distributions

silver_platter-0.5.20-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.9 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

silver_platter-0.5.20-pp310-pypy310_pp73-macosx_10_9_x86_64.whl (2.4 MB view hashes)

Uploaded PyPy macOS 10.9+ x86-64

silver_platter-0.5.20-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.9 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

silver_platter-0.5.20-pp39-pypy39_pp73-macosx_10_9_x86_64.whl (2.4 MB view hashes)

Uploaded PyPy macOS 10.9+ x86-64

silver_platter-0.5.20-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.9 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

silver_platter-0.5.20-pp38-pypy38_pp73-macosx_10_9_x86_64.whl (2.4 MB view hashes)

Uploaded PyPy macOS 10.9+ x86-64

silver_platter-0.5.20-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.9 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

silver_platter-0.5.20-pp37-pypy37_pp73-macosx_10_9_x86_64.whl (2.4 MB view hashes)

Uploaded PyPy macOS 10.9+ x86-64

silver_platter-0.5.20-cp312-cp312-musllinux_1_1_x86_64.whl (5.1 MB view hashes)

Uploaded CPython 3.12 musllinux: musl 1.1+ x86-64

silver_platter-0.5.20-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.9 MB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

silver_platter-0.5.20-cp312-cp312-macosx_11_0_arm64.whl (2.3 MB view hashes)

Uploaded CPython 3.12 macOS 11.0+ ARM64

silver_platter-0.5.20-cp312-cp312-macosx_10_9_x86_64.whl (2.4 MB view hashes)

Uploaded CPython 3.12 macOS 10.9+ x86-64

silver_platter-0.5.20-cp312-cp312-macosx_10_9_universal2.whl (4.6 MB view hashes)

Uploaded CPython 3.12 macOS 10.9+ universal2 (ARM64, x86-64)

silver_platter-0.5.20-cp311-cp311-musllinux_1_1_x86_64.whl (5.1 MB view hashes)

Uploaded CPython 3.11 musllinux: musl 1.1+ x86-64

silver_platter-0.5.20-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.9 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

silver_platter-0.5.20-cp311-cp311-macosx_11_0_arm64.whl (2.3 MB view hashes)

Uploaded CPython 3.11 macOS 11.0+ ARM64

silver_platter-0.5.20-cp311-cp311-macosx_10_9_x86_64.whl (2.4 MB view hashes)

Uploaded CPython 3.11 macOS 10.9+ x86-64

silver_platter-0.5.20-cp311-cp311-macosx_10_9_universal2.whl (4.6 MB view hashes)

Uploaded CPython 3.11 macOS 10.9+ universal2 (ARM64, x86-64)

silver_platter-0.5.20-cp310-cp310-musllinux_1_1_x86_64.whl (5.1 MB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.1+ x86-64

silver_platter-0.5.20-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.9 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

silver_platter-0.5.20-cp310-cp310-macosx_11_0_arm64.whl (2.3 MB view hashes)

Uploaded CPython 3.10 macOS 11.0+ ARM64

silver_platter-0.5.20-cp310-cp310-macosx_10_9_x86_64.whl (2.4 MB view hashes)

Uploaded CPython 3.10 macOS 10.9+ x86-64

silver_platter-0.5.20-cp310-cp310-macosx_10_9_universal2.whl (4.6 MB view hashes)

Uploaded CPython 3.10 macOS 10.9+ universal2 (ARM64, x86-64)

silver_platter-0.5.20-cp39-cp39-musllinux_1_1_x86_64.whl (5.1 MB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.1+ x86-64

silver_platter-0.5.20-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.9 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

silver_platter-0.5.20-cp39-cp39-macosx_11_0_arm64.whl (2.3 MB view hashes)

Uploaded CPython 3.9 macOS 11.0+ ARM64

silver_platter-0.5.20-cp39-cp39-macosx_10_9_x86_64.whl (2.4 MB view hashes)

Uploaded CPython 3.9 macOS 10.9+ x86-64

silver_platter-0.5.20-cp39-cp39-macosx_10_9_universal2.whl (4.6 MB view hashes)

Uploaded CPython 3.9 macOS 10.9+ universal2 (ARM64, x86-64)

silver_platter-0.5.20-cp38-cp38-musllinux_1_1_x86_64.whl (5.1 MB view hashes)

Uploaded CPython 3.8 musllinux: musl 1.1+ x86-64

silver_platter-0.5.20-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.9 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

silver_platter-0.5.20-cp38-cp38-macosx_11_0_arm64.whl (2.3 MB view hashes)

Uploaded CPython 3.8 macOS 11.0+ ARM64

silver_platter-0.5.20-cp38-cp38-macosx_10_9_x86_64.whl (2.4 MB view hashes)

Uploaded CPython 3.8 macOS 10.9+ x86-64

silver_platter-0.5.20-cp38-cp38-macosx_10_9_universal2.whl (4.6 MB view hashes)

Uploaded CPython 3.8 macOS 10.9+ universal2 (ARM64, x86-64)

silver_platter-0.5.20-cp37-cp37m-musllinux_1_1_x86_64.whl (5.1 MB view hashes)

Uploaded CPython 3.7m musllinux: musl 1.1+ x86-64

silver_platter-0.5.20-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.9 MB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

silver_platter-0.5.20-cp37-cp37m-macosx_10_9_x86_64.whl (2.4 MB view hashes)

Uploaded CPython 3.7m macOS 10.9+ x86-64

Supported by

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