Skip to content

Commit 6c633cc

Browse files
committed
use char instead varchar
1 parent f05b354 commit 6c633cc

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

models/commit_status.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ package models
66

77
import (
88
"container/list"
9-
"crypto/md5"
9+
"crypto/sha1"
1010
"fmt"
1111
"strings"
1212

@@ -59,7 +59,7 @@ type CommitStatus struct {
5959
SHA string `xorm:"VARCHAR(64) NOT NULL INDEX UNIQUE(repo_sha_index)"`
6060
TargetURL string `xorm:"TEXT"`
6161
Description string `xorm:"TEXT"`
62-
ContextHash string `xorm:"varchar(40) index"`
62+
ContextHash string `xorm:"char(40) index"`
6363
Context string `xorm:"TEXT"`
6464
Creator *User `xorm:"-"`
6565
CreatorID int64
@@ -255,5 +255,5 @@ func ParseCommitsWithStatus(oldCommits *list.List, repo *Repository) *list.List
255255

256256
// HashCommitStatusContext hash context
257257
func HashCommitStatusContext(context string) string {
258-
return fmt.Sprintf("%x", md5.Sum([]byte(context)))
258+
return fmt.Sprintf("%x", sha1.Sum([]byte(context)))
259259
}

models/migrations/v88.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@
55
package migrations
66

77
import (
8-
"crypto/md5"
8+
"crypto/sha1"
99
"fmt"
1010

1111
"github.com/go-xorm/xorm"
1212
)
1313

1414
func hashContext(context string) string {
15-
return fmt.Sprintf("%x", md5.Sum([]byte(context)))
15+
return fmt.Sprintf("%x", sha1.Sum([]byte(context)))
1616
}
1717

1818
func addCommitStatusContext(x *xorm.Engine) error {
1919
type CommitStatus struct {
2020
ID int64 `xorm:"pk autoincr"`
21-
ContextHash string `xorm:"varchar(40) index"`
21+
ContextHash string `xorm:"char(40) index"`
2222
Context string `xorm:"TEXT"`
2323
}
2424

0 commit comments

Comments
 (0)