@commonlyai/cli 0.1.181 → 0.1.182

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commonlyai/cli",
3
- "version": "0.1.181",
3
+ "version": "0.1.182",
4
4
  "license": "Apache-2.0",
5
5
  "description": "The Commonly CLI — connect agents, manage pods, iterate fast",
6
6
  "type": "module",
@@ -127,16 +127,28 @@ const TOP_LEVEL = Object.freeze([
127
127
  ]);
128
128
 
129
129
  // A %G placeholder (%G?, %GG, %GS, %GK, %GF, %GP, %GT) runs gpg on each signed
130
- // commit. A value with no %, no format: and no tformat: is looked up by
131
- // prefix among the built-in formats and the repository's `pretty.<name>`
132
- // aliases, and an alias can hold one, so only a built-in name is taken.
133
- const FORMAT_ARGUMENT = /^--(?:pretty|format)=([\s\S]*)$/;
130
+ // commit, and git reads one behind a `+`, `-` or space modifier (`%+G?`,
131
+ // `%-GG`, `% GS`) as the same placeholder. A value with no %, no format: and
132
+ // no tformat: is looked up by prefix among the built-in formats and the
133
+ // repository's `pretty.<name>` aliases, and an alias can hold one, so only a
134
+ // built-in name is taken.
135
+ const SIGNATURE_PLACEHOLDER = /%[-+ ]?G/;
134
136
  const BUILTIN_FORMATS = Object.freeze(['oneline', 'short', 'medium', 'full', 'fuller', 'reference', 'email', 'mboxrd', 'raw']);
137
+ // Git's revision parser reads --pretty and --format only by their exact names,
138
+ // and their format only after `=`: a bare --pretty means medium, and a bare
139
+ // --format is an unrecognized argument. The check does not depend on that. An
140
+ // abbreviation (`--form=`, `--pret=`) is checked like the full name, and a
141
+ // --format that would take its format from the next argument is refused.
142
+ const FORMAT_OPTIONS = Object.freeze(['--pretty', '--format']);
135
143
  const checkFormat = (arg) => {
136
- const match = FORMAT_ARGUMENT.exec(arg);
137
- if (!match) return null;
138
- const value = match[1];
139
- if (value.includes('%G')) return `${arg} is refused: a %G placeholder runs gpg to check a signature`;
144
+ const [name] = arg.split('=', 1);
145
+ const option = name.length >= 3 && FORMAT_OPTIONS.find((full) => full.startsWith(name));
146
+ if (!option) return null;
147
+ if (name === arg) {
148
+ return option === '--format' ? `${arg} is refused: give the format in the same argument, as --format=<format>` : null;
149
+ }
150
+ const value = arg.slice(name.length + 1);
151
+ if (SIGNATURE_PLACEHOLDER.test(value)) return `${arg} is refused: a %G placeholder runs gpg to check a signature`;
140
152
  const userFormat = value === '' || value.startsWith('format:') || value.startsWith('tformat:') || value.includes('%');
141
153
  if (userFormat || BUILTIN_FORMATS.includes(value.toLowerCase())) return null;
142
154
  return `${arg} is refused: name a built-in format (${BUILTIN_FORMATS.join(', ')}) or give format:<placeholders>`;