gemini-code-assist[bot] commented on code in PR #19708:
URL: https://github.com/apache/tvm/pull/19708#discussion_r3384535649


##########
ci/jenkins/templates/utils/Prepare.groovy.j2:
##########
@@ -15,12 +15,15 @@ def init_git() {
   )
 
   // Determine merge commit to use for all stages
-  if (env.BRANCH_NAME == 'main') {
-    // Only set upstream_revision to HEAD and skip merging to avoid a race 
with another commit merged to main.
-    update_upstream_revision("HEAD")
+  if (env.CHANGE_TARGET != null) {

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   Using Groovy truthiness `if (env.CHANGE_TARGET)` is safer and more idiomatic 
than `if (env.CHANGE_TARGET != null)`. In Jenkins, environment variables can 
sometimes be empty strings (`""`). If `env.CHANGE_TARGET` is empty, 
`env.CHANGE_TARGET != null` evaluates to `true`, which would cause 
`merge_with_target()` to be called with an empty target branch, leading to a 
failure in `git fetch origin`.
   
   Using `if (env.CHANGE_TARGET)` ensures that the block is only executed if 
the variable is both non-null and non-empty.
   
   After applying this change to the template, please regenerate the 
Jenkinsfiles using `python3 jenkins/generate.py`.
   
   ```
     if (env.CHANGE_TARGET) {
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to