azdo-cli 0.2.0-003-cli-settings.17 → 0.2.0-003-cli-settings.19

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.
Files changed (2) hide show
  1. package/dist/index.js +19 -8
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -201,7 +201,11 @@ function parseAzdoRemote(url) {
201
201
  for (const pattern of patterns) {
202
202
  const match = url.match(pattern);
203
203
  if (match) {
204
- return { org: match[1], project: match[2] };
204
+ const project = match[2];
205
+ if (/^DefaultCollection$/i.test(project)) {
206
+ return { org: match[1], project: "" };
207
+ }
208
+ return { org: match[1], project };
205
209
  }
206
210
  }
207
211
  return null;
@@ -214,7 +218,7 @@ function detectAzdoContext() {
214
218
  throw new Error("Not in a git repository. Provide --org and --project explicitly.");
215
219
  }
216
220
  const context = parseAzdoRemote(remoteUrl);
217
- if (!context) {
221
+ if (!context || !context.org && !context.project) {
218
222
  throw new Error('Git remote "origin" is not an Azure DevOps URL. Provide --org and --project explicitly.');
219
223
  }
220
224
  return context;
@@ -380,12 +384,19 @@ function createGetItemCommand() {
380
384
  if (options.org && options.project) {
381
385
  context = { org: options.org, project: options.project };
382
386
  } else {
383
- try {
384
- context = detectAzdoContext();
385
- } catch {
386
- const config = loadConfig();
387
- if (config.org && config.project) {
388
- context = { org: config.org, project: config.project };
387
+ const config = loadConfig();
388
+ if (config.org && config.project) {
389
+ context = { org: config.org, project: config.project };
390
+ } else {
391
+ let gitContext = null;
392
+ try {
393
+ gitContext = detectAzdoContext();
394
+ } catch {
395
+ }
396
+ const org = config.org || gitContext?.org;
397
+ const project = config.project || gitContext?.project;
398
+ if (org && project) {
399
+ context = { org, project };
389
400
  } else {
390
401
  throw new Error(
391
402
  'Could not determine org/project. Use --org and --project flags, work from an Azure DevOps git repo, or run "azdo config set org/project".'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "azdo-cli",
3
- "version": "0.2.0-003-cli-settings.17",
3
+ "version": "0.2.0-003-cli-settings.19",
4
4
  "description": "Azure DevOps CLI tool",
5
5
  "type": "module",
6
6
  "bin": {