nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
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 'staging-nixos': ['development', 'secondary'],
12 'haskell-updates': ['development', 'secondary'],
13 nixos: ['channel'],
14 nixpkgs: ['channel'],
15}
16
17// "order" ranks the development branches by how likely they are the intended base branch
18// when they are an otherwise equally good fit according to ci/github-script/prepare.js.
19const orderConfig = {
20 master: 0,
21 release: 1,
22 staging: 2,
23 'staging-nixos': 2,
24 'haskell-updates': 3,
25 'staging-next': 4,
26}
27
28function split(branch) {
29 return {
30 ...branch.match(
31 /(?<prefix>.+?)(-(?<version>\d{2}\.\d{2}|unstable)(?:-(?<suffix>.*))?)?$/,
32 ).groups,
33 }
34}
35
36function classify(branch) {
37 const { prefix, version } = split(branch)
38 return {
39 branch,
40 order: orderConfig[prefix] ?? Infinity,
41 stable: (version ?? 'unstable') !== 'unstable',
42 type: typeConfig[prefix] ?? ['wip'],
43 version: version ?? 'unstable',
44 }
45}
46
47module.exports = { classify, split }
48
49// If called directly via CLI, runs the following tests:
50if (!module.parent) {
51 console.log('split(branch)')
52 function testSplit(branch) {
53 console.log(branch, split(branch))
54 }
55 testSplit('master')
56 testSplit('release-25.05')
57 testSplit('staging')
58 testSplit('staging-next')
59 testSplit('staging-25.05')
60 testSplit('staging-next-25.05')
61 testSplit('nixpkgs-25.05-darwin')
62 testSplit('nixpkgs-unstable')
63 testSplit('haskell-updates')
64 testSplit('backport-123-to-release-25.05')
65
66 console.log('')
67
68 console.log('classify(branch)')
69 function testClassify(branch) {
70 console.log(branch, classify(branch))
71 }
72 testClassify('master')
73 testClassify('release-25.05')
74 testClassify('staging')
75 testClassify('staging-next')
76 testClassify('staging-25.05')
77 testClassify('staging-next-25.05')
78 testClassify('nixpkgs-25.05-darwin')
79 testClassify('nixpkgs-unstable')
80 testClassify('haskell-updates')
81 testClassify('backport-123-to-release-25.05')
82}