Files snapshot from clone-early

./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
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
98a839 Tucker McKnight
98a839 Tucker McKnight
98a839 Tucker McKnight
98a839 Tucker McKnight
98a839 Tucker McKnight
98a839 Tucker McKnight
98a839 Tucker McKnight
98a839 Tucker McKnight
98a839 Tucker McKnight
98a839 Tucker McKnight
98a839 Tucker McKnight
98a839 Tucker McKnight
98a839 Tucker McKnight
98a839 Tucker McKnight
98a839 Tucker McKnight
98a839 Tucker McKnight
98a839 Tucker McKnight
98a839 Tucker McKnight
98a839 Tucker McKnight
98a839 Tucker McKnight
98a839 Tucker McKnight
98a839 Tucker McKnight
98a839 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
```