Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1#!/usr/bin/env nix-shell 2/* 3#!nix-shell -i node -p nodejs 4*/ 5 6const typeConfig = { 7 master: ['development', 'primary'], 8 release: ['development', 'primary'], 9 staging: ['development', 'secondary'], 10 'staging-next': ['development', 'secondary'], 11 'haskell-updates': ['development', 'secondary'], 12 'python-updates': ['development', 'secondary'], 13 nixos: ['channel'], 14 nixpkgs: ['channel'], 15} 16 17function split(branch) { 18 return { ...branch.match(/(?<prefix>.+?)(-(?<version>\d{2}\.\d{2}|unstable)(?:-(?<suffix>.*))?)?$/).groups } 19} 20 21function classify(branch) { 22 const { prefix, version } = split(branch) 23 return { 24 stable: (version ?? 'unstable') !== 'unstable', 25 type: typeConfig[prefix] ?? [ 'wip' ] 26 } 27} 28 29module.exports = { classify } 30 31// If called directly via CLI, runs the following tests: 32if (!module.parent) { 33 console.log('split(branch)') 34 function testSplit(branch) { 35 console.log(branch, split(branch)) 36 } 37 testSplit('master') 38 testSplit('release-25.05') 39 testSplit('staging-next') 40 testSplit('staging-25.05') 41 testSplit('staging-next-25.05') 42 testSplit('nixpkgs-25.05-darwin') 43 testSplit('nixpkgs-unstable') 44 testSplit('haskell-updates') 45 testSplit('backport-123-to-release-25.05') 46 47 console.log('') 48 49 console.log('classify(branch)') 50 function testClassify(branch) { 51 console.log(branch, classify(branch)) 52 } 53 testClassify('master') 54 testClassify('release-25.05') 55 testClassify('staging-next') 56 testClassify('staging-25.05') 57 testClassify('staging-next-25.05') 58 testClassify('nixpkgs-25.05-darwin') 59 testClassify('nixpkgs-unstable') 60 testClassify('haskell-updates') 61 testClassify('backport-123-to-release-25.05') 62}