Skip to content

Commit 069c56c

Browse files
steipetebrianleach
andcommitted
fix(ios): normalize team IDs before preferred match
Co-authored-by: Brian Leach <[email protected]>
1 parent 1ae8c0a commit 069c56c

2 files changed

Lines changed: 41 additions & 0 deletions

File tree

scripts/ios-team-id.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ preferred_team="${IOS_PREFERRED_TEAM_ID:-${OPENCLAW_IOS_DEFAULT_TEAM_ID:-Y5PE65H
1010
preferred_team_name="${IOS_PREFERRED_TEAM_NAME:-}"
1111
allow_keychain_fallback="${IOS_ALLOW_KEYCHAIN_TEAM_FALLBACK:-0}"
1212
prefer_non_free_team="${IOS_PREFER_NON_FREE_TEAM:-1}"
13+
preferred_team="${preferred_team//$'\r'/}"
14+
preferred_team_name="${preferred_team_name//$'\r'/}"
1315

1416
declare -a team_ids=()
1517
declare -a team_is_free=()
@@ -34,6 +36,9 @@ append_team() {
3436
local candidate_id="$1"
3537
local candidate_is_free="$2"
3638
local candidate_name="$3"
39+
candidate_id="${candidate_id//$'\r'/}"
40+
candidate_is_free="${candidate_is_free//$'\r'/}"
41+
candidate_name="${candidate_name//$'\r'/}"
3742
[[ -z "$candidate_id" ]] && return
3843

3944
local i

test/scripts/ios-team-id.test.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,4 +192,40 @@ exit 0`,
192192
expect(result.ok).toBe(true);
193193
expect(result.stdout).toBe("BBBBB22222");
194194
});
195+
196+
it("matches preferred team IDs even when parser output uses CRLF line endings", async () => {
197+
const homeDir = await mkdtemp(path.join(os.tmpdir(), "openclaw-ios-team-id-"));
198+
const binDir = path.join(homeDir, "bin");
199+
await mkdir(binDir, { recursive: true });
200+
await mkdir(path.join(homeDir, "Library", "Preferences"), { recursive: true });
201+
await writeFile(path.join(homeDir, "Library", "Preferences", "com.apple.dt.Xcode.plist"), "");
202+
203+
await writeExecutable(
204+
path.join(binDir, "plutil"),
205+
`#!/usr/bin/env bash
206+
echo '{}'`,
207+
);
208+
await writeExecutable(
209+
path.join(binDir, "defaults"),
210+
`#!/usr/bin/env bash
211+
if [[ "$3" == "DVTDeveloperAccountManagerAppleIDLists" ]]; then
212+
echo '(identifier = "[email protected]";)'
213+
exit 0
214+
fi
215+
exit 0`,
216+
);
217+
await writeExecutable(
218+
path.join(binDir, "fake-python"),
219+
`#!/usr/bin/env bash
220+
printf 'AAAAA11111\\t0\\tAlpha Team\\r\\n'
221+
printf 'BBBBB22222\\t0\\tBeta Team\\r\\n'`,
222+
);
223+
224+
const result = runScript(homeDir, {
225+
IOS_PYTHON_BIN: path.join(binDir, "fake-python"),
226+
IOS_PREFERRED_TEAM_ID: "BBBBB22222",
227+
});
228+
expect(result.ok).toBe(true);
229+
expect(result.stdout).toBe("BBBBB22222");
230+
});
195231
});

0 commit comments

Comments
 (0)