Repository navigation
fix(watch): allow --board-owner override for org-owned ProjectV2 #1087
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -183,6 +183,7 @@ async function main(): Promise<void> { | |
| console.log(` --self-pull git fetch/pull at round start`); | ||
| console.log(` --board project board lifecycle + reconciliation`); | ||
| console.log(` --board-project N project number (default 1)`); | ||
| console.log(` --board-owner X project owner (default @me; use org name for org-owned ProjectV2)`); | ||
| console.log(` --monitor-teams scan Teams for actionable messages`); | ||
| console.log(` --monitor-email scan email for actionable items`); | ||
| console.log(` --two-pass lightweight list then hydrate actionable`); | ||
|
|
@@ -483,6 +484,15 @@ async function main(): Promise<void> { | |
| : { projectNumber: parseInt(args[boardProjectIdx + 1]!, 10) }; | ||
| } | ||
|
|
||
| // --board-owner sets the project owner (default @me, override for org-owned ProjectV2 boards) | ||
| const boardOwnerIdx = args.indexOf('--board-owner'); | ||
| if (boardOwnerIdx !== -1 && args[boardOwnerIdx + 1]) { | ||
| const existing = capabilities['board']; | ||
| capabilities['board'] = typeof existing === 'object' && existing !== null | ||
| ? { ...existing, owner: args[boardOwnerIdx + 1]! } | ||
| : { owner: args[boardOwnerIdx + 1]! }; | ||
| } | ||
|
Comment on lines
+487
to
+494
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @copilot apply changes based on this feedback
Comment on lines
+487
to
+494
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @copilot apply changes based on this feedback |
||
|
|
||
| // Load config: .squad/config.json merged with CLI overrides | ||
| const config = loadWatchConfig(getSquadStartDir(), { | ||
| interval, | ||
|
|
@@ -506,7 +516,7 @@ async function main(): Promise<void> { | |
| // After parsing all flags, check for positional args that look like prompts. | ||
| // Skip values that follow known value-flags (e.g. "--interval 5" → "5" is not positional). | ||
| const knownValueFlags = new Set([ | ||
| '--interval', '--copilot-flags', '--agent-cmd', '--max-concurrent', '--timeout', '--board-project', '--auth-user', | ||
| '--interval', '--copilot-flags', '--agent-cmd', '--max-concurrent', '--timeout', '--board-project', '--board-owner', '--auth-user', | ||
| '--dispatch-mode', '--log-file', '--notify-level', '--overnight-start', '--overnight-end', '--sentinel-file', '--state-backend', | ||
| ]); | ||
| const watchArgStart = args.indexOf(cmd) + 1; | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| /** | ||
| * Tests for BoardCapability — covers `--owner` propagation so org-owned | ||
| * ProjectV2 boards work (not just `@me` personal projects). | ||
| * | ||
| * Closes #1079 | ||
| */ | ||
|
|
||
| import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; | ||
|
|
||
| interface ExecFileCall { | ||
| cmd: string; | ||
| args: readonly string[]; | ||
| } | ||
|
|
||
| const cpMocks = vi.hoisted(() => { | ||
| const calls: ExecFileCall[] = []; | ||
| // promisify(execFile) uses util.promisify.custom — without that symbol, | ||
| // promisify falls back to (err, value) → resolve(value). Shape the value | ||
| // as { stdout, stderr } so destructuring in the capability still works. | ||
| type ExecCb = (err: Error | null, value: { stdout: string; stderr: string }) => void; | ||
| return { | ||
| calls, | ||
| execFile: vi.fn((cmd: string, args: readonly string[], ...rest: unknown[]) => { | ||
| calls.push({ cmd, args }); | ||
| const cb = rest[rest.length - 1] as ExecCb | undefined; | ||
| if (typeof cb === 'function') { | ||
| cb(null, { stdout: JSON.stringify({ items: [] }), stderr: '' }); | ||
| } | ||
| }), | ||
| execFileSync: vi.fn(() => 'owner/repo'), | ||
| }; | ||
| }); | ||
|
|
||
| vi.mock('node:child_process', async () => { | ||
| const actual = await vi.importActual<typeof import('node:child_process')>('node:child_process'); | ||
| return { ...actual, execFile: cpMocks.execFile, execFileSync: cpMocks.execFileSync }; | ||
| }); | ||
|
|
||
| import { BoardCapability } from '../packages/squad-cli/src/cli/commands/watch/capabilities/board.js'; | ||
| import type { WatchContext } from '../packages/squad-cli/src/cli/commands/watch/types.js'; | ||
|
|
||
| function makeContext(config: Record<string, unknown>): WatchContext { | ||
| return { | ||
| teamRoot: '/tmp/team', | ||
| // The capability never touches the adapter — only `config`. | ||
| adapter: {} as WatchContext['adapter'], | ||
| round: 1, | ||
| roster: [], | ||
| config, | ||
| }; | ||
| } | ||
|
|
||
| beforeEach(() => { | ||
| cpMocks.calls.length = 0; | ||
| cpMocks.execFile.mockClear(); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| vi.restoreAllMocks(); | ||
| }); | ||
|
|
||
| describe('BoardCapability owner config', () => { | ||
| it('passes a configured owner through to gh project item-list', async () => { | ||
| const cap = new BoardCapability(); | ||
| const result = await cap.execute(makeContext({ projectNumber: 22, owner: 'my-org' })); | ||
|
|
||
| expect(result.success).toBe(true); | ||
|
|
||
| const itemList = cpMocks.calls.find( | ||
| (c) => c.cmd === 'gh' && c.args[0] === 'project' && c.args[1] === 'item-list', | ||
| ); | ||
| expect(itemList).toBeDefined(); | ||
| const ownerIdx = itemList!.args.indexOf('--owner'); | ||
| expect(ownerIdx).toBeGreaterThan(-1); | ||
| expect(itemList!.args[ownerIdx + 1]).toBe('my-org'); | ||
| // Project number should also be respected | ||
| expect(itemList!.args[2]).toBe('22'); | ||
| }); | ||
|
|
||
| it('defaults owner to @me when none is configured', async () => { | ||
| const cap = new BoardCapability(); | ||
| await cap.execute(makeContext({ projectNumber: 1 })); | ||
|
|
||
| const itemList = cpMocks.calls.find( | ||
| (c) => c.cmd === 'gh' && c.args[0] === 'project' && c.args[1] === 'item-list', | ||
| ); | ||
| expect(itemList).toBeDefined(); | ||
| const ownerIdx = itemList!.args.indexOf('--owner'); | ||
| expect(itemList!.args[ownerIdx + 1]).toBe('@me'); | ||
| }); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot apply changes based on this feedback