@imfelixyeung/git-swarm 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -55,37 +55,66 @@ git swarm checkout feature/my-branch
55
55
  <!-- prettier-ignore -->
56
56
  | Option | Description |
57
57
  |---|---|
58
- | `--where <query>` | Filter repos using a URL query-string syntax |
58
+ | `--where <expression>` | Filter repos using a JEXL expression |
59
59
  | `--parallel <count>` | Run operations in parallel (default: 1) |
60
60
  | `--no-progress` | Disable the progress bar (defaults to enabled only when stdout is a TTY) |
61
61
 
62
62
  ### Filtering with `--where`
63
63
 
64
- Use `--where` to selectively target repos based on branch, clean/dirty state, or remote attributes:
64
+ Use `--where` to selectively target repos with a [JEXL](https://www.npmjs.com/package/jexl) expression evaluated against each repo's context:
65
65
 
66
66
  ```bash
67
67
  # Only repos on the main branch
68
- git swarm --where "branch=main" status
68
+ git swarm --where 'branch == "main"' status
69
69
 
70
70
  # Only dirty repos with a GitHub remote
71
- git swarm --where "clean=false&remote.provider=github" status
71
+ git swarm --where 'clean == false && remote.provider == "github"' status
72
72
 
73
73
  # Only repos owned by a specific user
74
- git swarm --where "remote.owner=imfelixyeung" pull
74
+ git swarm --where 'remote.owner == "imfelixyeung"' pull
75
+
76
+ # Only repos that are ahead of their upstream by at least 2 commits
77
+ git swarm --where 'ahead >= 2' push
78
+
79
+ # Only repos on a feature branch, not touching main
80
+ git swarm --where '"feature/" in branch && branch != "main"' status
81
+
82
+ # Only repos that have a branch named feature/cool
83
+ git swarm --where '"feature/cool" in branches' status
84
+
85
+ # Only repos with a tracking branch for origin/main
86
+ git swarm --where '"remotes/origin/main" in branches' status
87
+
88
+ # Only repos whose remote is hosted under github.com/imfelixyeung
89
+ git swarm --where 'remote.host == "github.com" && remote.owner == "imfelixyeung"' pull
75
90
  ```
76
91
 
77
- Available filter keys:
92
+ Available context fields:
78
93
 
79
94
  <!-- prettier-ignore -->
80
- | Key | Description |
95
+ | Field | Description |
81
96
  |---|---|
82
- | `branch` | Current branch name |
83
- | `clean` | Whether the working tree is clean (`true`/`false`) |
84
- | `remote.provider` | Remote provider (`github`, `gitlab`, `bitbucket`) |
85
- | `remote.owner` | Repository owner |
86
- | `remote.name` | Repository name |
97
+ | `name` | Repository directory name |
98
+ | `path` | Repository path relative to the swarm root |
99
+ | `branch` | Current branch name, or `null` when detached |
100
+ | `branches` | Names of all branches, including remote-tracking branches |
101
+ | `localBranches` | Names of all local branches |
102
+ | `detached` | Whether HEAD is detached |
103
+ | `clean` | Whether the working tree is clean |
104
+ | `stagedFiles` | Number of staged files |
105
+ | `modifiedFiles` | Number of modified files |
106
+ | `untrackedFiles` | Number of untracked files |
107
+ | `ahead` | Commits ahead of the upstream |
108
+ | `behind` | Commits behind the upstream |
109
+ | `hasUpstream` | Whether an upstream is configured |
110
+ | `remote.provider` | Remote host provider (`github`, `gitlab`, `bitbucket`, `other`, or `null`) |
87
111
  | `remote.host` | Remote host |
88
- | `remote.ref` | Full remote URL |
112
+ | `remote.owner` | Repository owner |
113
+ | `remote.repo` | Repository name |
114
+
115
+ The `remote.*` fields describe the `origin` remote when present, otherwise the first remote. Fields that require `git status` (branch, divergence, worktree counts, ...), the branch lists, and the `remote.*` fields are only fetched when the expression references them.
116
+
117
+ Use JEXL operators: `==`, `!=`, `<`, `<=`, `>`, `>=`, `&&`, `||`, `!`, and `in` for substring checks on strings (for example `'"issue" in branch'`) or membership checks on arrays (for example `'"feature/cool" in branches'`).
89
118
 
90
119
  ### Parallel Execution
91
120
 
@@ -113,7 +142,7 @@ git swarm exec "git clean -fd"
113
142
  git swarm fetch --prune
114
143
 
115
144
  # Only pull repos that are behind their upstream
116
- git swarm --where "branch=main&clean=true" pull
145
+ git swarm --where 'branch == "main" && clean' pull
117
146
  ```
118
147
 
119
148
  ## Development