( session: ExecutionSession, workspacePath: string, gitUrl: string, gitToken: string, platform?: ManagedGitPlatform )
| 898 | |
| 899 | export async function updateGitAuthor( |
| 900 | session: ExecutionSession, |
| 901 | workspacePath: string, |
| 902 | gitAuthor: GitAuthorConfig |
| 903 | ): Promise<void> { |
| 904 | const nameResult = await timedExec( |
| 905 | session, |
| 906 | `git config user.name ${shellQuote(gitAuthor.name)}`, |
| 907 | 'git.config.userName', |
| 908 | { cwd: workspacePath } |
| 909 | ); |
| 910 | const emailResult = await timedExec( |
| 911 | session, |
| 912 | `git config user.email ${shellQuote(gitAuthor.email)}`, |
| 913 | 'git.config.userEmail', |
| 914 | { cwd: workspacePath } |
| 915 | ); |
| 916 | if (nameResult.exitCode !== 0 || emailResult.exitCode !== 0) { |
| 917 | throw new Error('Failed to configure git author identity'); |
| 918 | } |
| 919 | } |
| 920 | |
| 921 | export async function updateGitRemoteUrl( |
| 922 | session: ExecutionSession, |
| 923 | workspacePath: string, |
| 924 | gitUrl: string |
| 925 | ): Promise<void> { |
| 926 | let originUrl = gitUrl; |
| 927 | try { |
| 928 | const canonicalUrl = new URL(gitUrl); |
| 929 | canonicalUrl.username = ''; |
| 930 | canonicalUrl.password = ''; |
| 931 | originUrl = canonicalUrl.toString(); |
| 932 | } catch { |
| 933 | // SCP-style remotes are already credential-free; leave them unchanged. |
| 934 | } |
no test coverage detected