Files snapshot from mithril-server-side-rendering

./wiki/projects/branch-globs.md

Branch Globs

Goal: allow users to specify a glob pattern (like deploy/**) instead of spelling out every branch name that will be included in their repository.

Git branch: branch-globs

  • Where are branches currently pulled?
    • There is getBranchNames in src/repos.ts.
    • If the branch is an object, like { glob: string, max: number}, then we should query for get all branches from the main repository and see if any match.
    • There could be a branch that matches multiple globs
    • Put branches in a hash, with keys being the glob that matched them.
    • Remove the oldest branches (by last commit?) to limit to the max number
    • Then merge the branches into a set so there are no duplicates -- we don't actually care which glob matched the branch, we just want to be able to enforce the max value for a glob.

Use node's path.matchesGlob() method: https://nodejs.org/docs/latest/api/path.html#pathmatchesglobpath-pattern.

path.matchesGlob('/foo/bar', '/foo/*'); // true

Jan 17, 2026

  • Update getBranchNames so that it 1) pulls all branches from the repo, and 2) figures out which ones match the given branch globs.
  • where does that get called?
    • it gets called when repos() is called
    • and repos() get called when main.ts runs, so after the beforehook is called.
    • we'll need to decide which branches get pulled in the before hook, so that the clone only pulls the branches we want
    • for a first-attempt solution, make a function that figures out which branches are available and call it multiple times: once when pulling the branches, and then also in subsequent calls when we're seeing which branches are available in the repo.
      • So, stop calling repoConfig.branchesToPull directly
    • currently failing locally because I don't have the updated beforeHook on this laptop. Push current work, update local repo to use the beforeHook from the clone-early branch, and see if that works. (update: Yes, that was the problem.)
      • this is a good reason to put the deployed repo config on the public site, too. I currently have different example site configs between my laptop and the deployed site.

Jan 18, 2026

An idea: allow the object with a glob in it to also specify things like the description and which parent branch the branch should be compared to.

Multiple branch patterns (let's use the word "pattern" instead of "glob") can match the same branch -- the more specific one should be used.

E.g.:

branchesToPull: [
  {
    pattern: "deploy/**",
    description: "A deployed branch",
  },
  {
    pattern: "deploy/v2**",
    description: "A version 2 deployed branch",
  }
]

In the above example, branch deploy/v1.0.1 should have the description "A deployed branch," but branch deploy/v2.0.1 should have the description "A version 2 deployed branch."

Is the "more specific pattern" just always the one that is longer? Try this for now.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
b3ebf3 Tucker McKnight
b3ebf3 Tucker McKnight
b3ebf3 Tucker McKnight
b3ebf3 Tucker McKnight
b3ebf3 Tucker McKnight
b3ebf3 Tucker McKnight
b3ebf3 Tucker McKnight
b3ebf3 Tucker McKnight
b3ebf3 Tucker McKnight
b3ebf3 Tucker McKnight
b3ebf3 Tucker McKnight
b3ebf3 Tucker McKnight
b3ebf3 Tucker McKnight
b3ebf3 Tucker McKnight
b3ebf3 Tucker McKnight
b3ebf3 Tucker McKnight
b3ebf3 Tucker McKnight
b3ebf3 Tucker McKnight
b3ebf3 Tucker McKnight
b3ebf3 Tucker McKnight
b3ebf3 Tucker McKnight
b3ebf3 Tucker McKnight
b3ebf3 Tucker McKnight
e2d4fd Tucker McKnight
e2d4fd Tucker McKnight
e2d4fd Tucker McKnight
e2d4fd Tucker McKnight
e2d4fd Tucker McKnight
e2d4fd Tucker McKnight
e2d4fd Tucker McKnight
e2d4fd Tucker McKnight
e2d4fd Tucker McKnight
e2d4fd Tucker McKnight
e2d4fd Tucker McKnight
e2d4fd Tucker McKnight
e2d4fd Tucker McKnight
e2d4fd Tucker McKnight
e2d4fd Tucker McKnight
e2d4fd Tucker McKnight
e2d4fd Tucker McKnight
e2d4fd Tucker McKnight
e2d4fd Tucker McKnight
e2d4fd Tucker McKnight
e2d4fd Tucker McKnight
01b859 Tucker McKnight
01b859 Tucker McKnight
01b859 Tucker McKnight
01b859 Tucker McKnight
01b859 Tucker McKnight
01b859 Tucker McKnight
01b859 Tucker McKnight
01b859 Tucker McKnight
01b859 Tucker McKnight
01b859 Tucker McKnight
01b859 Tucker McKnight
01b859 Tucker McKnight
01b859 Tucker McKnight
01b859 Tucker McKnight
01b859 Tucker McKnight
01b859 Tucker McKnight
01b859 Tucker McKnight
01b859 Tucker McKnight
01b859 Tucker McKnight
01b859 Tucker McKnight
01b859 Tucker McKnight
01b859 Tucker McKnight
01b859 Tucker McKnight
01b859 Tucker McKnight
01b859 Tucker McKnight
01b859 Tucker McKnight
01b859 Tucker McKnight
01b859 Tucker McKnight
01b859 Tucker McKnight
# Branch Globs

> Goal: allow users to specify a glob pattern (like `deploy/**`) instead of spelling out every branch name that will be included in their repository.

Git branch: `branch-globs`

- Where are branches currently pulled?
  - There is `getBranchNames` in `src/repos.ts`.
  - If the branch is an object, like `{ glob: string, max: number}`, then
    we should query for get all branches from the main repository and see
    if any match.
  - There could be a branch that matches multiple globs
  - Put branches in a hash, with keys being the glob that matched them.
  - Remove the oldest branches (by last commit?) to limit to the `max` number
  - Then merge the branches into a set so there are no duplicates -- we don't
    actually care which glob matched the branch, we just want to be able to
    enforce the `max` value for a glob.

Use node's `path.matchesGlob()` method: https://nodejs.org/docs/latest/api/path.html#pathmatchesglobpath-pattern.

```js
path.matchesGlob('/foo/bar', '/foo/*'); // true
```


## Jan 17, 2026

- Update getBranchNames so that it 1) pulls all branches from the repo, and 2)
  figures out which ones match the given branch globs.
- where does that get called?
  - it gets called when `repos()` is called
  - and `repos()` get called when main.ts runs, so after the beforehook is called.
  - we'll need to decide which branches get pulled in the before hook, so that the clone
    only pulls the branches we want
  - for a first-attempt solution, make a function that figures out which branches
    are available and call it multiple times: once when pulling the branches, and then also
    in subsequent calls when we're seeing which branches are available in the repo.
    - So, stop calling `repoConfig.branchesToPull` directly
  - currently failing locally because I don't have the updated beforeHook on this
    laptop. Push current work, update local repo to use the beforeHook from the
    clone-early branch, and see if that works. (update: Yes, that was the problem.)
    - this is a good reason to put the deployed repo config on the public site, too.
      I currently have different example site configs between my laptop and the deployed
      site.

## Jan 18, 2026

*An idea:* allow the object with a glob in it to also specify things like the description
and which parent branch the branch should be compared to.

Multiple branch patterns (let's use the word "pattern" instead of "glob") can match
the same branch -- the more specific one should be used.

E.g.:

```
branchesToPull: [
  {
    pattern: "deploy/**",
    description: "A deployed branch",
  },
  {
    pattern: "deploy/v2**",
    description: "A version 2 deployed branch",
  }
]
```

In the above example, branch `deploy/v1.0.1` should have the description "A deployed
branch," but branch `deploy/v2.0.1` should have the description "A version 2
deployed branch."

Is the "more specific pattern" just always the one that is longer? Try this for now.