<freeStyleBuild _class='hudson.model.FreeStyleBuild'><action _class='hudson.model.CauseAction'><cause _class='com.cloudbees.jenkins.GitHubPushCause'><shortDescription>Started by GitHub push by ti-chi-bot[bot]</shortDescription></cause><cause _class='com.cloudbees.jenkins.GitHubPushCause'><shortDescription>Started by GitHub push by ti-chi-bot[bot]</shortDescription></cause></action><action></action><action _class='jenkins.metrics.impl.TimeInQueueAction'><blockedDurationMillis>0</blockedDurationMillis><blockedTimeMillis>0</blockedTimeMillis><buildableDurationMillis>23252</buildableDurationMillis><buildableTimeMillis>23252</buildableTimeMillis><buildingDurationMillis>50221</buildingDurationMillis><executingTimeMillis>50221</executingTimeMillis><executorUtilization>1.0</executorUtilization><subTaskCount>0</subTaskCount><waitingDurationMillis>6363</waitingDurationMillis><waitingTimeMillis>6363</waitingTimeMillis></action><action _class='hudson.plugins.git.util.BuildData'><buildsByBranchName><originmain _class='hudson.plugins.git.util.Build'><buildNumber>1459</buildNumber><marked><SHA1>e658c118eaec6e9ff53b8f1ab59fbebb559cc30d</SHA1><branch><SHA1>e658c118eaec6e9ff53b8f1ab59fbebb559cc30d</SHA1><name>origin/main</name></branch></marked><revision><SHA1>e658c118eaec6e9ff53b8f1ab59fbebb559cc30d</SHA1><branch><SHA1>e658c118eaec6e9ff53b8f1ab59fbebb559cc30d</SHA1><name>origin/main</name></branch></revision></originmain></buildsByBranchName><lastBuiltRevision><SHA1>e658c118eaec6e9ff53b8f1ab59fbebb559cc30d</SHA1><branch><SHA1>e658c118eaec6e9ff53b8f1ab59fbebb559cc30d</SHA1><name>origin/main</name></branch></lastBuiltRevision><remoteUrl>https://github.com/PingCAP-QE/ci.git</remoteUrl><scmName></scmName></action><action></action><action></action><action></action><action></action><action></action><action></action><action _class='org.jenkinsci.plugins.displayurlapi.actions.RunDisplayAction'></action><building>false</building><displayName>#1459</displayName><duration>50221</duration><estimatedDuration>50732</estimatedDuration><fullDisplayName>seed #1459</fullDisplayName><id>1459</id><inProgress>false</inProgress><keepLog>false</keepLog><number>1459</number><queueId>3363867</queueId><result>SUCCESS</result><timestamp>1772610327845</timestamp><url>https://do.pingcap.net/jenkins/job/seed/1459/</url><builtOn>default-935wp</builtOn><changeSet _class='hudson.plugins.git.GitChangeSetList'><item _class='hudson.plugins.git.GitChangeSet'><affectedPath>libraries/tipipeline/vars/prow.groovy</affectedPath><commitId>e658c118eaec6e9ff53b8f1ab59fbebb559cc30d</commitId><timestamp>1772610293000</timestamp><author><absoluteUrl>https://do.pingcap.net/jenkins/user/noreply</absoluteUrl><fullName>noreply</fullName></author><authorEmail>noreply@github.com</authorEmail><comment>refactor(prow): extract _checkoutRefsImpl to deduplicate checkout logic (#4284)

`checkoutRefs` and `checkoutPrivateRefs` contained an identical ~80-line
bash block (git init → fetch → checkout → merge → submodule → gc),
differing only in remote URL scheme and SSH agent setup.

## Changes

- **New `_checkoutRefsImpl(refs, remoteUrl, timeout, withSubmodule)`** —
single canonical implementation of the shared bash checkout pipeline;
called by both public functions.
- **`checkoutRefs`** — computes HTTPS remote URL
(`${gitBaseUrl}/${org}/${repo}.git`) and delegates to
`_checkoutRefsImpl`. Signature unchanged.
- **`checkoutPrivateRefs`** — computes SSH remote URL
(`git@${gitSshHost}:${org}/${repo}.git`), retains its `sshagent` wrap
and `ssh-keyscan` step, then delegates to `_checkoutRefsImpl`. Signature
unchanged.

```groovy
def checkoutRefs(refs, timeout = 5, credentialsId = '', gitBaseUrl = 'https://github.com', withSubmodule = false) {
    final remoteUrl = "${gitBaseUrl}/${refs.org}/${refs.repo}.git"
    _checkoutRefsImpl(refs, remoteUrl, timeout, withSubmodule)
}

def checkoutPrivateRefs(refs, credentialsId, timeout = 5, gitSshHost = 'github.com', withSubmodule = false) {
    final remoteUrl = "git@${gitSshHost}:${refs.org}/${refs.repo}.git"
    sshagent(credentials: [credentialsId]) {
        sh label: 'Know hosts', script: "..."
        _checkoutRefsImpl(refs, remoteUrl, timeout, withSubmodule)
    }
}
```

No behavioral changes — pure deduplication (~94 lines removed).

&lt;!-- START COPILOT ORIGINAL PROMPT --&gt;



&lt;details&gt;

&lt;summary&gt;Original prompt&lt;/summary&gt;

&gt; 请在仓库 `PingCAP-QE/ci` 中对 `libraries/tipipeline/vars/prow.groovy`
做一次重构并提交 PR：
&gt; 
&gt; 目标：
&gt; - 保持 `checkoutRefs` 与 `checkoutPrivateRefs`
**两个函数的签名完全不变**（参数列表、默认值都不改），以避免调用方需要修改。
&gt; - 将两者内部高度重复的 bash checkout/merge/submodule/gc 逻辑抽取为一个内部实现函数（例如
`_checkoutRefsImpl` 或等价命名），使两者仅在下列差异处保留各自逻辑：
&gt;   1) remote URL 形式：
&gt; - `checkoutRefs` 使用 HTTPS：`${gitBaseUrl}/${refs.org}/${refs.repo}.git`
&gt; - `checkoutPrivateRefs` 使用
SSH：`git@${gitSshHost}:${refs.org}/${refs.repo}.git`
&gt; 2) private checkout 仍需保留 `sshagent(credentials: [credentialsId]) { ...
}` 以及 `ssh-keyscan` 写入 `~/.ssh/known_hosts` 的步骤。
&gt; - 保持原有行为一致（fetch refspec、checkout base_sha、merge pulls SHAs、清理旧 PR
refs、防止缓存 `.git` 膨胀的 maintenance、可选 submodule 更新等），只做抽取和去重。
&gt; 
&gt; 实现约束/注意：
&gt; - 不做全局引用搜索，不调整其它文件。
&gt; - 确保 groovy 语法在 Jenkins shared library 环境下可用。
&gt; - 如需要增加新 helper 函数，请以当前文件内 `def` 方式实现。
&gt; - 最终打开一个 PR。
&gt; 
&gt; 涉及文件：
&gt; - `libraries/tipipeline/vars/prow.groovy`
&gt; 
&gt; 上下文片段（来自讨论线程，仅供参考，不是文件内容）：
&gt; ```groovy
&gt;         _checkoutRefsImpl(refs, remoteUrl, timeout, withSubmodule)
&gt; ```
&gt; 


&lt;/details&gt;



&lt;!-- START COPILOT CODING AGENT SUFFIX --&gt;

*This pull request was created from Copilot chat.*
&gt;

&lt;!-- START COPILOT CODING AGENT TIPS --&gt;
---

💡 You can make Copilot smarter by setting up custom instructions,
customizing its development environment and configuring Model Context
Protocol (MCP) servers. Learn more [Copilot coding agent
tips](https://gh.io/copilot-coding-agent-tips) in the docs.

---------

Co-authored-by: copilot-swe-agent[bot] &lt;198982749+Copilot@users.noreply.github.com&gt;
Co-authored-by: wuhuizuo &lt;2574558+wuhuizuo@users.noreply.github.com&gt;
</comment><date>2026-03-04 07:44:53 +0000</date><id>e658c118eaec6e9ff53b8f1ab59fbebb559cc30d</id><msg>refactor(prow): extract _checkoutRefsImpl to deduplicate checkout logic</msg><path><editType>edit</editType><file>libraries/tipipeline/vars/prow.groovy</file></path></item><kind>git</kind></changeSet><culprit><absoluteUrl>https://do.pingcap.net/jenkins/user/noreply</absoluteUrl><fullName>noreply</fullName></culprit></freeStyleBuild>