2020-05-15 04:25:43 +05:30
|
|
|
// Copyright 2019 The Gitea Authors. All rights reserved.
|
2022-11-27 23:50:29 +05:30
|
|
|
// SPDX-License-Identifier: MIT
|
2020-05-15 04:25:43 +05:30
|
|
|
|
2022-11-02 14:24:36 +05:30
|
|
|
package v1_12 //nolint
|
2020-05-15 04:25:43 +05:30
|
|
|
|
|
|
|
import (
|
|
|
|
"code.gitea.io/gitea/modules/setting"
|
|
|
|
|
|
|
|
"xorm.io/xorm"
|
|
|
|
)
|
|
|
|
|
2022-11-02 14:24:36 +05:30
|
|
|
func PrependRefsHeadsToIssueRefs(x *xorm.Engine) error {
|
2020-05-15 04:25:43 +05:30
|
|
|
var query string
|
|
|
|
|
|
|
|
switch {
|
2023-03-07 16:21:06 +05:30
|
|
|
case setting.Database.Type.IsMSSQL():
|
2020-05-15 04:25:43 +05:30
|
|
|
query = "UPDATE `issue` SET `ref` = 'refs/heads/' + `ref` WHERE `ref` IS NOT NULL AND `ref` <> '' AND `ref` NOT LIKE 'refs/%'"
|
2023-03-07 16:21:06 +05:30
|
|
|
case setting.Database.Type.IsMySQL():
|
2020-05-15 19:35:18 +05:30
|
|
|
query = "UPDATE `issue` SET `ref` = CONCAT('refs/heads/', `ref`) WHERE `ref` IS NOT NULL AND `ref` <> '' AND `ref` NOT LIKE 'refs/%';"
|
2020-05-15 04:25:43 +05:30
|
|
|
default:
|
|
|
|
query = "UPDATE `issue` SET `ref` = 'refs/heads/' || `ref` WHERE `ref` IS NOT NULL AND `ref` <> '' AND `ref` NOT LIKE 'refs/%'"
|
|
|
|
}
|
|
|
|
|
|
|
|
_, err := x.Exec(query)
|
|
|
|
return err
|
|
|
|
}
|