forked from mirrors/nixpkgs
Merge pull request #161260 from jtojnar/gnome-update-bump
gnome.updateScript: Various improvements
This commit is contained in:
commit
2427ba619c
|
@ -147,7 +147,7 @@ let
|
|||
|
||||
to run update script for specific package, or
|
||||
|
||||
% nix-shell maintainers/scripts/update.nix --arg predicate '(path: pkg: builtins.isList pkg.updateScript && builtins.length pkg.updateScript >= 1 && (let script = builtins.head pkg.updateScript; in builtins.isAttrs script && script.name == "gnome-update-script"))'
|
||||
% nix-shell maintainers/scripts/update.nix --arg predicate '(path: pkg: pkg.updateScript.name or null == "gnome-update-script")'
|
||||
|
||||
to run update script for all packages matching given predicate, or
|
||||
|
||||
|
|
|
@ -88,6 +88,10 @@ async def commit_changes(name: str, merge_lock: asyncio.Lock, worktree: str, bra
|
|||
async with merge_lock:
|
||||
await check_subprocess('git', 'add', *change['files'], cwd=worktree)
|
||||
commit_message = '{attrPath}: {oldVersion} → {newVersion}'.format(**change)
|
||||
if 'commitMessage' in change:
|
||||
commit_message = change['commitMessage']
|
||||
elif 'commitBody' in change:
|
||||
commit_message = commit_message + '\n\n' + change['commitBody']
|
||||
await check_subprocess('git', 'commit', '--quiet', '-m', commit_message, cwd=worktree)
|
||||
await check_subprocess('git', 'cherry-pick', branch)
|
||||
|
||||
|
|
|
@ -1,26 +1,42 @@
|
|||
{ stdenv, pkgs, lib, writeScript, python3, common-updater-scripts }:
|
||||
{ stdenv, bash, pkgs, lib, writeScript, python3, common-updater-scripts }:
|
||||
{ packageName, attrPath ? packageName, versionPolicy ? "tagged", freeze ? false }:
|
||||
|
||||
let
|
||||
python = python3.withPackages (p: [ p.requests p.libversion ]);
|
||||
upperBoundFlag =
|
||||
package = lib.attrByPath (lib.splitString "." attrPath) (throw "Cannot find attribute ‘${attrPath}’.") pkgs;
|
||||
packageVersion = lib.getVersion package;
|
||||
upperBound =
|
||||
let
|
||||
package = lib.attrByPath (lib.splitString "." attrPath) (throw "Cannot find attribute ‘${attrPath}’.") pkgs;
|
||||
packageVersion = lib.getVersion package;
|
||||
versionComponents = lib.versions.splitVersion packageVersion;
|
||||
minorVersion = lib.versions.minor packageVersion;
|
||||
minorAvailable = builtins.length versionComponents > 1 && builtins.match "[0-9]+" minorVersion != null;
|
||||
nextMinor = builtins.fromJSON minorVersion + 1;
|
||||
upperBound = "${lib.versions.major packageVersion}.${builtins.toString nextMinor}";
|
||||
in lib.optionalString (freeze && minorAvailable) ''--upper-bound="${upperBound}"'';
|
||||
in lib.optionals (freeze && minorAvailable) [ upperBound ];
|
||||
updateScript = writeScript "gnome-update-script" ''
|
||||
#!${stdenv.shell}
|
||||
#!${bash}/bin/bash
|
||||
set -o errexit
|
||||
package_name="$1"
|
||||
attr_path="$2"
|
||||
version_policy="$3"
|
||||
attr_path="$1"
|
||||
package_name="$2"
|
||||
package_version="$3"
|
||||
version_policy="$4"
|
||||
|
||||
flvFlags=("$package_name" "$version_policy" "''${GNOME_UPDATE_STABILITY:-stable}")
|
||||
|
||||
if (( $# >= 5 )); then
|
||||
upper_bound="$5"
|
||||
flvFlags+=("--upper-bound=$upper_bound")
|
||||
fi
|
||||
|
||||
PATH=${lib.makeBinPath [ common-updater-scripts python ]}
|
||||
latest_tag=$(python "${./find-latest-version.py}" "$package_name" "$version_policy" "stable" ${upperBoundFlag})
|
||||
latest_tag=$(python "${./find-latest-version.py}" "''${flvFlags[@]}")
|
||||
update-source-version "$attr_path" "$latest_tag"
|
||||
echo '[ { "commitBody": "https://gitlab.gnome.org/GNOME/'$package_name'/-/compare/'$package_version'...'$latest_tag'" } ]'
|
||||
'';
|
||||
in [ updateScript packageName attrPath versionPolicy ]
|
||||
in {
|
||||
name = "gnome-update-script";
|
||||
command = [ updateScript attrPath packageName packageVersion versionPolicy ] ++ upperBound;
|
||||
supportedFeatures = [
|
||||
"commit"
|
||||
];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue