maint: Add script to backport my pull requests from nixpkgs
Normally, ~/source/nixpkgs follows the releases, but when I contribute to nixpkgs, it is convenient to have access to my changes in ~/source/nixpkgs before next release, ideally even before pull request hits the master.
This commit is contained in:
parent
91ab5402c3
commit
2c8893870f
27
maint/import-commit
Executable file
27
maint/import-commit
Executable file
@ -0,0 +1,27 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""
|
||||||
|
Import commit from specified local repository into a prefix of this monorepository.
|
||||||
|
"""
|
||||||
|
import click
|
||||||
|
import os
|
||||||
|
import tempfile
|
||||||
|
from subprocess import check_output, check_call
|
||||||
|
|
||||||
|
@click.command()
|
||||||
|
@click.option("-s", "--source", default="/home/kaction/devel/nix/nixpkgs")
|
||||||
|
@click.option("-P", "--prefix", default="nixpkgs")
|
||||||
|
@click.argument("rev")
|
||||||
|
def main(source, prefix, rev):
|
||||||
|
with tempfile.TemporaryDirectory() as tempdir:
|
||||||
|
patch_filename = f"{tempdir}/out.patch"
|
||||||
|
here = check_output("git rev-parse --show-toplevel".split(), text=True).strip()
|
||||||
|
|
||||||
|
with open(patch_filename, "w") as fp:
|
||||||
|
os.chdir(source)
|
||||||
|
check_call(["git", "format-patch", "--stdout", f"{rev}~..{rev}"], stdout=fp)
|
||||||
|
|
||||||
|
with open(patch_filename) as fp:
|
||||||
|
os.chdir(here)
|
||||||
|
check_call(["./maint/prefix-patch", prefix], stdin=fp)
|
||||||
|
|
||||||
|
main()
|
Loading…
Reference in New Issue
Block a user