@@ -21,14 +21,13 @@ rm -f "$CLONE_DONE_PATH" "$CLONE_FAIL_PATH"
2121CLONE_OK=1`
2222
2323const renderCloneRemotes = ( config : TemplateConfig ) : string =>
24- `if [[ "$CLONE_OK" -eq 1 && -n "$FORK_REPO_URL" && -d "$TARGET_DIR/.git" ]]; then
25- AUTH_FORK_URL="$FORK_REPO_URL"
26- if [[ -n "$GIT_AUTH_TOKEN" && "$FORK_REPO_URL" == https://* ]]; then
27- AUTH_FORK_URL="$(printf "%s" "$FORK_REPO_URL" | sed "s#^https://#https://\${GIT_AUTH_USER}:\${GIT_AUTH_TOKEN}@#")"
28- fi
29- if [[ "$FORK_REPO_URL" != "$REPO_URL" ]]; then
30- su - ${ config . sshUser } -c "cd '$TARGET_DIR' && git remote set-url origin '$AUTH_FORK_URL'" || true
31- su - ${ config . sshUser } -c "cd '$TARGET_DIR' && git remote add upstream '$AUTH_REPO_URL' 2>/dev/null || git remote set-url upstream '$AUTH_REPO_URL'" || true
24+ `if [[ "$CLONE_OK" -eq 1 && -d "$TARGET_DIR/.git" ]]; then
25+ if [[ -n "$FORK_REPO_URL" && "$FORK_REPO_URL" != "$REPO_URL" ]]; then
26+ su - ${ config . sshUser } -c "cd '$TARGET_DIR' && git remote set-url origin '$FORK_REPO_URL'" || true
27+ su - ${ config . sshUser } -c "cd '$TARGET_DIR' && git remote add upstream '$REPO_URL' 2>/dev/null || git remote set-url upstream '$REPO_URL'" || true
28+ else
29+ su - ${ config . sshUser } -c "cd '$TARGET_DIR' && git remote set-url origin '$REPO_URL'" || true
30+ su - ${ config . sshUser } -c "cd '$TARGET_DIR' && git remote remove upstream >/dev/null 2>&1 || true" || true
3231 fi
3332fi`
3433
@@ -97,16 +96,19 @@ const renderIssueWorkspaceAgents = (): string =>
9796 if [[ "$REPO_URL" == https://github.com/* ]]; then
9897 ISSUE_REPO="$(printf "%s" "$REPO_URL" | sed -E 's#^https://github.com/##; s#[.]git$##; s#/*$##')"
9998 if [[ -n "$ISSUE_REPO" ]]; then
100- ISSUE_URL="https://github.com/\${ ISSUE_REPO} /issues/\${ ISSUE_ID} "
99+ ISSUE_URL="https://github.com/$ ISSUE_REPO/issues/$ ISSUE_ID"
101100 fi
102101 fi
102+ if [[ -z "$ISSUE_URL" ]]; then
103+ ISSUE_URL="n/a"
104+ fi
103105
104106 ISSUE_AGENTS_PATH="$TARGET_DIR/AGENTS.md"
105107 if [[ ! -e "$ISSUE_AGENTS_PATH" ]]; then
106108 cat <<EOF > "$ISSUE_AGENTS_PATH"
107109# docker-git issue workspace
108- Issue workspace: #\${ ISSUE_ID}
109- Issue URL: \${ ISSUE_URL:-n/a}
110+ Issue workspace: #$ ISSUE_ID
111+ Issue URL: $ ISSUE_URL
110112Workspace path: $TARGET_DIR
111113
112114Работай только над этим issue, если пользователь не попросил другое.
@@ -128,11 +130,11 @@ const renderCloneBody = (config: TemplateConfig): string =>
128130 [
129131 renderCloneBodyStart ( config ) ,
130132 renderCloneBodyRef ( config ) ,
133+ "fi" ,
131134 "" ,
132135 renderCloneRemotes ( config ) ,
133136 "" ,
134- renderIssueWorkspaceAgents ( ) ,
135- "fi"
137+ renderIssueWorkspaceAgents ( )
136138 ] . join ( "\n" )
137139
138140const renderCloneFinalize = ( ) : string =>
0 commit comments