Browse Source

Refactoring: rename and simplify pkg/tool functions

pull/3974/merge
Unknwon 8 years ago
parent
commit
0e271799f2
No known key found for this signature in database
GPG Key ID: 25B575AE3213B2B3
  1. 4
      models/migrations/migrations.go
  2. 2
      models/token.go
  3. 4
      models/two_factor.go
  4. 10
      models/user.go
  5. 2
      pkg/markup/markdown.go
  6. 2
      pkg/markup/markup.go
  7. 6
      pkg/template/template.go
  8. 26
      pkg/tool/tool.go
  9. 2
      routers/install.go
  10. 4
      routers/repo/commit.go
  11. 2
      routers/repo/http.go
  12. 2
      routers/repo/pull.go
  13. 2
      routers/repo/repo.go
  14. 2
      routers/user/setting.go
  15. 2
      templates/repo/branch_dropdown.tmpl
  16. 6
      templates/repo/commits_table.tmpl
  17. 4
      templates/repo/diff/page.tmpl
  18. 2
      templates/repo/release/list.tmpl
  19. 8
      templates/repo/view_list.tmpl
  20. 2
      templates/user/dashboard/feeds.tmpl

4
models/migrations/migrations.go

@ -159,10 +159,10 @@ func generateOrgRandsAndSalt(x *xorm.Engine) (err error) {
} }
for _, org := range orgs { for _, org := range orgs {
if org.Rands, err = tool.GetRandomString(10); err != nil { if org.Rands, err = tool.RandomString(10); err != nil {
return err return err
} }
if org.Salt, err = tool.GetRandomString(10); err != nil { if org.Salt, err = tool.RandomString(10); err != nil {
return err return err
} }
if _, err = sess.Id(org.ID).Update(org); err != nil { if _, err = sess.Id(org.ID).Update(org); err != nil {

2
models/token.go

@ -49,7 +49,7 @@ func (t *AccessToken) AfterSet(colName string, _ xorm.Cell) {
// NewAccessToken creates new access token. // NewAccessToken creates new access token.
func NewAccessToken(t *AccessToken) error { func NewAccessToken(t *AccessToken) error {
t.Sha1 = tool.EncodeSha1(gouuid.NewV4().String()) t.Sha1 = tool.SHA1(gouuid.NewV4().String())
_, err := x.Insert(t) _, err := x.Insert(t)
return err return err
} }

4
models/two_factor.go

@ -66,9 +66,9 @@ func IsUserEnabledTwoFactor(userID int64) bool {
func generateRecoveryCodes(userID int64) ([]*TwoFactorRecoveryCode, error) { func generateRecoveryCodes(userID int64) ([]*TwoFactorRecoveryCode, error) {
recoveryCodes := make([]*TwoFactorRecoveryCode, 10) recoveryCodes := make([]*TwoFactorRecoveryCode, 10)
for i := 0; i < 10; i++ { for i := 0; i < 10; i++ {
code, err := tool.GetRandomString(10) code, err := tool.RandomString(10)
if err != nil { if err != nil {
return nil, fmt.Errorf("GetRandomString: %v", err) return nil, fmt.Errorf("RandomString: %v", err)
} }
recoveryCodes[i] = &TwoFactorRecoveryCode{ recoveryCodes[i] = &TwoFactorRecoveryCode{
UserID: userID, UserID: userID,

10
models/user.go

@ -489,7 +489,7 @@ func IsUserExist(uid int64, name string) (bool, error) {
// GetUserSalt returns a ramdom user salt token. // GetUserSalt returns a ramdom user salt token.
func GetUserSalt() (string, error) { func GetUserSalt() (string, error) {
return tool.GetRandomString(10) return tool.RandomString(10)
} }
// NewGhostUser creates and returns a fake user for someone has deleted his/her account. // NewGhostUser creates and returns a fake user for someone has deleted his/her account.
@ -601,12 +601,12 @@ func Users(page, pageSize int) ([]*User, error) {
// get user by erify code // get user by erify code
func getVerifyUser(code string) (user *User) { func getVerifyUser(code string) (user *User) {
if len(code) <= tool.TimeLimitCodeLength { if len(code) <= tool.TIME_LIMIT_CODE_LENGTH {
return nil return nil
} }
// use tail hex username query user // use tail hex username query user
hexStr := code[tool.TimeLimitCodeLength:] hexStr := code[tool.TIME_LIMIT_CODE_LENGTH:]
if b, err := hex.DecodeString(hexStr); err == nil { if b, err := hex.DecodeString(hexStr); err == nil {
if user, err = GetUserByName(string(b)); user != nil { if user, err = GetUserByName(string(b)); user != nil {
return user return user
@ -623,7 +623,7 @@ func VerifyUserActiveCode(code string) (user *User) {
if user = getVerifyUser(code); user != nil { if user = getVerifyUser(code); user != nil {
// time limit code // time limit code
prefix := code[:tool.TimeLimitCodeLength] prefix := code[:tool.TIME_LIMIT_CODE_LENGTH]
data := com.ToStr(user.ID) + user.Email + user.LowerName + user.Passwd + user.Rands data := com.ToStr(user.ID) + user.Email + user.LowerName + user.Passwd + user.Rands
if tool.VerifyTimeLimitCode(data, minutes, prefix) { if tool.VerifyTimeLimitCode(data, minutes, prefix) {
@ -639,7 +639,7 @@ func VerifyActiveEmailCode(code, email string) *EmailAddress {
if user := getVerifyUser(code); user != nil { if user := getVerifyUser(code); user != nil {
// time limit code // time limit code
prefix := code[:tool.TimeLimitCodeLength] prefix := code[:tool.TIME_LIMIT_CODE_LENGTH]
data := com.ToStr(user.ID) + email + user.LowerName + user.Passwd + user.Rands data := com.ToStr(user.ID) + email + user.LowerName + user.Passwd + user.Rands
if tool.VerifyTimeLimitCode(data, minutes, prefix) { if tool.VerifyTimeLimitCode(data, minutes, prefix) {

2
pkg/markup/markdown.go

@ -72,7 +72,7 @@ func (r *MarkdownRenderer) AutoLink(out *bytes.Buffer, link []byte, kind int) {
if j == -1 { if j == -1 {
j = len(m) j = len(m)
} }
out.WriteString(fmt.Sprintf(` <code><a href="%s">%s</a></code>`, m, tool.ShortSha(string(m[i+7:j])))) out.WriteString(fmt.Sprintf(` <code><a href="%s">%s</a></code>`, m, tool.ShortSHA1(string(m[i+7:j]))))
return return
} }

2
pkg/markup/markup.go

@ -140,7 +140,7 @@ func RenderSha1CurrentPattern(rawBytes []byte, urlPrefix string) []byte {
if com.StrTo(m).MustInt() > 0 { if com.StrTo(m).MustInt() > 0 {
return m return m
} }
return fmt.Sprintf(`<a href="%s/commit/%s"><code>%s</code></a>`, urlPrefix, m, tool.ShortSha(string(m))) return fmt.Sprintf(`<a href="%s/commit/%s"><code>%s</code></a>`, urlPrefix, m, tool.ShortSHA1(string(m)))
})) }))
} }

6
pkg/template/template.go

@ -96,8 +96,8 @@ func NewFuncMap() []template.FuncMap {
"DiffTypeToStr": DiffTypeToStr, "DiffTypeToStr": DiffTypeToStr,
"DiffLineTypeToStr": DiffLineTypeToStr, "DiffLineTypeToStr": DiffLineTypeToStr,
"Sha1": Sha1, "Sha1": Sha1,
"ShortSha": tool.ShortSha, "ShortSHA1": tool.ShortSHA1,
"MD5": tool.EncodeMD5, "MD5": tool.MD5,
"ActionContent2Commits": ActionContent2Commits, "ActionContent2Commits": ActionContent2Commits,
"EscapePound": EscapePound, "EscapePound": EscapePound,
"RenderCommitMessage": RenderCommitMessage, "RenderCommitMessage": RenderCommitMessage,
@ -142,7 +142,7 @@ func List(l *list.List) chan interface{} {
} }
func Sha1(str string) string { func Sha1(str string) string {
return tool.EncodeSha1(str) return tool.SHA1(str)
} }
func ToUTF8WithErr(content []byte) (error, string) { func ToUTF8WithErr(content []byte) (error, string) {

26
pkg/tool/tool.go

@ -34,28 +34,30 @@ func MD5Bytes(str string) []byte {
return m.Sum(nil) return m.Sum(nil)
} }
// EncodeMD5 encodes string to MD5 hex value. // MD5 encodes string to MD5 hex value.
func EncodeMD5(str string) string { func MD5(str string) string {
return hex.EncodeToString(MD5Bytes(str)) return hex.EncodeToString(MD5Bytes(str))
} }
// Encode string to sha1 hex value. // SHA1 encodes string to SHA1 hex value.
func EncodeSha1(str string) string { func SHA1(str string) string {
h := sha1.New() h := sha1.New()
h.Write([]byte(str)) h.Write([]byte(str))
return hex.EncodeToString(h.Sum(nil)) return hex.EncodeToString(h.Sum(nil))
} }
func ShortSha(sha1 string) string { // ShortSHA1 truncates SHA1 string length to at most 10.
func ShortSHA1(sha1 string) string {
if len(sha1) > 10 { if len(sha1) > 10 {
return sha1[:10] return sha1[:10]
} }
return sha1 return sha1
} }
// DetectEncoding returns best guess of encoding of given content.
func DetectEncoding(content []byte) (string, error) { func DetectEncoding(content []byte) (string, error) {
if utf8.Valid(content) { if utf8.Valid(content) {
log.Trace("Detected encoding: utf-8 (fast)") log.Trace("Detected encoding: UTF-8 (fast)")
return "UTF-8", nil return "UTF-8", nil
} }
@ -69,6 +71,8 @@ func DetectEncoding(content []byte) (string, error) {
return result.Charset, err return result.Charset, err
} }
// BasicAuthDecode decodes username and password portions of HTTP Basic Authentication
// from encoded content.
func BasicAuthDecode(encoded string) (string, string, error) { func BasicAuthDecode(encoded string) (string, string, error) {
s, err := base64.StdEncoding.DecodeString(encoded) s, err := base64.StdEncoding.DecodeString(encoded)
if err != nil { if err != nil {
@ -79,14 +83,16 @@ func BasicAuthDecode(encoded string) (string, string, error) {
return auth[0], auth[1], nil return auth[0], auth[1], nil
} }
// BasicAuthEncode encodes username and password in HTTP Basic Authentication format.
func BasicAuthEncode(username, password string) string { func BasicAuthEncode(username, password string) string {
return base64.StdEncoding.EncodeToString([]byte(username + ":" + password)) return base64.StdEncoding.EncodeToString([]byte(username + ":" + password))
} }
// GetRandomString generate random string by specify chars. const alphanum = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
func GetRandomString(n int) (string, error) {
const alphanum = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
// RandomString returns generated random string in given length of characters.
// It also returns possible error during generation.
func RandomString(n int) (string, error) {
buffer := make([]byte, n) buffer := make([]byte, n)
max := big.NewInt(int64(len(alphanum))) max := big.NewInt(int64(len(alphanum)))
@ -138,7 +144,7 @@ func VerifyTimeLimitCode(data string, minutes int, code string) bool {
return false return false
} }
const TimeLimitCodeLength = 12 + 6 + 40 const TIME_LIMIT_CODE_LENGTH = 12 + 6 + 40
// create a time limit code // create a time limit code
// code format: 12 length date time string + 6 minutes string + 40 sha1 encoded string // code format: 12 length date time string + 6 minutes string + 40 sha1 encoded string

2
routers/install.go

@ -344,7 +344,7 @@ func InstallPost(ctx *context.Context, f form.Install) {
cfg.Section("log").Key("ROOT_PATH").SetValue(f.LogRootPath) cfg.Section("log").Key("ROOT_PATH").SetValue(f.LogRootPath)
cfg.Section("security").Key("INSTALL_LOCK").SetValue("true") cfg.Section("security").Key("INSTALL_LOCK").SetValue("true")
secretKey, err := tool.GetRandomString(15) secretKey, err := tool.RandomString(15)
if err != nil { if err != nil {
ctx.RenderWithErr(ctx.Tr("install.secret_key_failed", err), INSTALL, &f) ctx.RenderWithErr(ctx.Tr("install.secret_key_failed", err), INSTALL, &f)
return return

4
routers/repo/commit.go

@ -165,7 +165,7 @@ func Diff(ctx *context.Context) {
ctx.Data["Username"] = userName ctx.Data["Username"] = userName
ctx.Data["Reponame"] = repoName ctx.Data["Reponame"] = repoName
ctx.Data["IsImageFile"] = commit.IsImageFile ctx.Data["IsImageFile"] = commit.IsImageFile
ctx.Data["Title"] = commit.Summary() + " · " + tool.ShortSha(commitID) ctx.Data["Title"] = commit.Summary() + " · " + tool.ShortSHA1(commitID)
ctx.Data["Commit"] = commit ctx.Data["Commit"] = commit
ctx.Data["Author"] = models.ValidateCommitWithEmail(commit) ctx.Data["Author"] = models.ValidateCommitWithEmail(commit)
ctx.Data["Diff"] = diff ctx.Data["Diff"] = diff
@ -228,7 +228,7 @@ func CompareDiff(ctx *context.Context) {
ctx.Data["Username"] = userName ctx.Data["Username"] = userName
ctx.Data["Reponame"] = repoName ctx.Data["Reponame"] = repoName
ctx.Data["IsImageFile"] = commit.IsImageFile ctx.Data["IsImageFile"] = commit.IsImageFile
ctx.Data["Title"] = "Comparing " + tool.ShortSha(beforeCommitID) + "..." + tool.ShortSha(afterCommitID) + " · " + userName + "/" + repoName ctx.Data["Title"] = "Comparing " + tool.ShortSHA1(beforeCommitID) + "..." + tool.ShortSHA1(afterCommitID) + " · " + userName + "/" + repoName
ctx.Data["Commit"] = commit ctx.Data["Commit"] = commit
ctx.Data["Diff"] = diff ctx.Data["Diff"] = diff
ctx.Data["DiffNotAvailable"] = diff.NumFiles() == 0 ctx.Data["DiffNotAvailable"] = diff.NumFiles() == 0

2
routers/repo/http.go

@ -232,7 +232,7 @@ func ComposeHookEnvs(opts ComposeHookEnvsOptions) []string {
ENV_AUTH_USER_NAME + "=" + opts.AuthUser.Name, ENV_AUTH_USER_NAME + "=" + opts.AuthUser.Name,
ENV_AUTH_USER_EMAIL + "=" + opts.AuthUser.Email, ENV_AUTH_USER_EMAIL + "=" + opts.AuthUser.Email,
ENV_REPO_OWNER_NAME + "=" + opts.OwnerName, ENV_REPO_OWNER_NAME + "=" + opts.OwnerName,
ENV_REPO_OWNER_SALT_MD5 + "=" + tool.EncodeMD5(opts.OwnerSalt), ENV_REPO_OWNER_SALT_MD5 + "=" + tool.MD5(opts.OwnerSalt),
ENV_REPO_ID + "=" + com.ToStr(opts.RepoID), ENV_REPO_ID + "=" + com.ToStr(opts.RepoID),
ENV_REPO_NAME + "=" + opts.RepoName, ENV_REPO_NAME + "=" + opts.RepoName,
ENV_REPO_CUSTOM_HOOKS_PATH + "=" + path.Join(opts.RepoPath, "custom_hooks"), ENV_REPO_CUSTOM_HOOKS_PATH + "=" + path.Join(opts.RepoPath, "custom_hooks"),

2
routers/repo/pull.go

@ -738,7 +738,7 @@ func TriggerTask(ctx *context.Context) {
if ctx.Written() { if ctx.Written() {
return return
} }
if secret != tool.EncodeMD5(owner.Salt) { if secret != tool.MD5(owner.Salt) {
ctx.Error(404) ctx.Error(404)
log.Trace("TriggerTask [%s/%s]: invalid secret", owner.Name, repo.Name) log.Trace("TriggerTask [%s/%s]: invalid secret", owner.Name, repo.Name)
return return

2
routers/repo/repo.go

@ -323,7 +323,7 @@ func Download(ctx *context.Context) {
return return
} }
archivePath = path.Join(archivePath, tool.ShortSha(commit.ID.String())+ext) archivePath = path.Join(archivePath, tool.ShortSHA1(commit.ID.String())+ext)
if !com.IsFile(archivePath) { if !com.IsFile(archivePath) {
if err := commit.CreateArchive(archivePath, archiveType); err != nil { if err := commit.CreateArchive(archivePath, archiveType); err != nil {
ctx.Handle(500, "Download -> CreateArchive "+archivePath, err) ctx.Handle(500, "Download -> CreateArchive "+archivePath, err)

2
routers/user/setting.go

@ -123,7 +123,7 @@ func SettingsPost(ctx *context.Context, f form.UpdateProfile) {
func UpdateAvatarSetting(ctx *context.Context, f form.Avatar, ctxUser *models.User) error { func UpdateAvatarSetting(ctx *context.Context, f form.Avatar, ctxUser *models.User) error {
ctxUser.UseCustomAvatar = f.Source == form.AVATAR_LOCAL ctxUser.UseCustomAvatar = f.Source == form.AVATAR_LOCAL
if len(f.Gravatar) > 0 { if len(f.Gravatar) > 0 {
ctxUser.Avatar = tool.EncodeMD5(f.Gravatar) ctxUser.Avatar = tool.MD5(f.Gravatar)
ctxUser.AvatarEmail = f.Gravatar ctxUser.AvatarEmail = f.Gravatar
} }

2
templates/repo/branch_dropdown.tmpl

@ -4,7 +4,7 @@
<span class="text"> <span class="text">
<i class="octicon octicon-git-branch"></i> <i class="octicon octicon-git-branch"></i>
{{if .IsViewBranch}}{{.i18n.Tr "repo.branch"}}{{else}}{{.i18n.Tr "repo.tree"}}{{end}}: {{if .IsViewBranch}}{{.i18n.Tr "repo.branch"}}{{else}}{{.i18n.Tr "repo.tree"}}{{end}}:
<strong>{{if .IsViewBranch}}{{.BranchName}}{{else}}{{ShortSha .BranchName}}{{end}}</strong> <strong>{{if .IsViewBranch}}{{.BranchName}}{{else}}{{ShortSHA1 .BranchName}}{{end}}</strong>
</span> </span>
<i class="dropdown icon"></i> <i class="dropdown icon"></i>
</div> </div>

6
templates/repo/commits_table.tmpl

@ -14,7 +14,7 @@
</form> </form>
</div> </div>
{{else if .IsDiffCompare}} {{else if .IsDiffCompare}}
<a href="{{$.CommitRepoLink}}/commit/{{.BeforeCommitID}}" class="ui green sha label">{{ShortSha .BeforeCommitID}}</a> ... <a href="{{$.CommitRepoLink}}/commit/{{.AfterCommitID}}" class="ui green sha label">{{ShortSha .AfterCommitID}}</a> <a href="{{$.CommitRepoLink}}/commit/{{.BeforeCommitID}}" class="ui green sha label">{{ShortSHA1 .BeforeCommitID}}</a> ... <a href="{{$.CommitRepoLink}}/commit/{{.AfterCommitID}}" class="ui green sha label">{{ShortSHA1 .AfterCommitID}}</a>
{{end}} {{end}}
</h4> </h4>
@ -43,9 +43,9 @@
<td class="message collapsing has-emoji"> <td class="message collapsing has-emoji">
{{/* Username or Reponame doesn't present we assume the source repository no longer exists */}} {{/* Username or Reponame doesn't present we assume the source repository no longer exists */}}
{{if not (and $.Username $.Reponame)}} {{if not (and $.Username $.Reponame)}}
<span class="ui sha label">{{ShortSha .ID.String}}</span> <span class="ui sha label">{{ShortSHA1 .ID.String}}</span>
{{else}} {{else}}
<a rel="nofollow" class="ui sha label" href="{{AppSubUrl}}/{{$.Username}}/{{$.Reponame}}/commit/{{.ID}}">{{ShortSha .ID.String}}</a> <a rel="nofollow" class="ui sha label" href="{{AppSubUrl}}/{{$.Username}}/{{$.Reponame}}/commit/{{.ID}}">{{ShortSHA1 .ID.String}}</a>
{{end}} {{end}}
<span {{if gt .ParentCount 1}}class="grey text"{{end}}>{{RenderCommitMessage false .Summary $.RepoLink $.Repository.ComposeMetas}}</span> <span {{if gt .ParentCount 1}}class="grey text"{{end}}>{{RenderCommitMessage false .Summary $.RepoLink $.Repository.ComposeMetas}}</span>
</td> </td>

4
templates/repo/diff/page.tmpl

@ -28,12 +28,12 @@
</div> </div>
<div class="item"> <div class="item">
{{range .Parents}} {{range .Parents}}
<a class="ui blue sha label" href="{{$.RepoLink}}/commit/{{.}}">{{ShortSha .}}</a> <a class="ui blue sha label" href="{{$.RepoLink}}/commit/{{.}}">{{ShortSHA1 .}}</a>
{{end}} {{end}}
</div> </div>
{{end}} {{end}}
<div class="item">{{.i18n.Tr "repo.diff.commit"}}</div> <div class="item">{{.i18n.Tr "repo.diff.commit"}}</div>
<div class="item"><span class="ui blue sha label">{{ShortSha .CommitID}}</span></div> <div class="item"><span class="ui blue sha label">{{ShortSHA1 .CommitID}}</span></div>
</div> </div>
</div> </div>
</div> </div>

2
templates/repo/release/list.tmpl

@ -28,7 +28,7 @@
</span> </span>
{{end}} {{end}}
<span class="commit"> <span class="commit">
<a href="{{$.RepoLink}}/src/{{.Sha1}}" rel="nofollow"><i class="code icon"></i> {{ShortSha .Sha1}}</a> <a href="{{$.RepoLink}}/src/{{.Sha1}}" rel="nofollow"><i class="code icon"></i> {{ShortSHA1 .Sha1}}</a>
</span> </span>
</div> </div>
<div class="ui twelve wide column detail"> <div class="ui twelve wide column detail">

8
templates/repo/view_list.tmpl

@ -9,7 +9,7 @@
<img class="ui avatar image img-12" src="{{AvatarLink .LatestCommit.Author.Email}}" /> <img class="ui avatar image img-12" src="{{AvatarLink .LatestCommit.Author.Email}}" />
<strong>{{.LatestCommit.Author.Name}}</strong> <strong>{{.LatestCommit.Author.Name}}</strong>
{{end}} {{end}}
<a rel="nofollow" class="ui sha label" href="{{.RepoLink}}/commit/{{.LatestCommit.ID}}" rel="nofollow">{{ShortSha .LatestCommit.ID.String}}</a> <a rel="nofollow" class="ui sha label" href="{{.RepoLink}}/commit/{{.LatestCommit.ID}}" rel="nofollow">{{ShortSHA1 .LatestCommit.ID.String}}</a>
<span class="grey has-emoji">{{RenderCommitMessage false .LatestCommit.Summary .RepoLink $.Repository.ComposeMetas}}</span> <span class="grey has-emoji">{{RenderCommitMessage false .LatestCommit.Summary .RepoLink $.Repository.ComposeMetas}}</span>
</th> </th>
<th class="nine wide"> <th class="nine wide">
@ -32,9 +32,9 @@
<span class="octicon octicon-file-submodule"></span> <span class="octicon octicon-file-submodule"></span>
{{$refURL := $commit.RefURL AppUrl $.BranchLink}} {{$refURL := $commit.RefURL AppUrl $.BranchLink}}
{{if $refURL}} {{if $refURL}}
<a href="{{$refURL}}">{{$entry.Name}}</a> @ <a href="{{$refURL}}/commit/{{$commit.RefID}}">{{ShortSha $commit.RefID}}</a> <a href="{{$refURL}}">{{$entry.Name}}</a> @ <a href="{{$refURL}}/commit/{{$commit.RefID}}">{{ShortSHA1 $commit.RefID}}</a>
{{else}} {{else}}
{{$entry.Name}} @ {{ShortSha $commit.RefID}} {{$entry.Name}} @ {{ShortSHA1 $commit.RefID}}
{{end}} {{end}}
</td> </td>
{{else}} {{else}}
@ -44,7 +44,7 @@
</td> </td>
{{end}} {{end}}
<td class="message collapsing has-emoji"> <td class="message collapsing has-emoji">
<a rel="nofollow" class="ui sha label" href="{{$.RepoLink}}/commit/{{$commit.ID}}">{{ShortSha $commit.ID.String}}</a> <a rel="nofollow" class="ui sha label" href="{{$.RepoLink}}/commit/{{$commit.ID}}">{{ShortSHA1 $commit.ID.String}}</a>
{{RenderCommitMessage false $commit.Summary $.RepoLink $.Repository.ComposeMetas}} {{RenderCommitMessage false $commit.Summary $.RepoLink $.Repository.ComposeMetas}}
</td> </td>
<td class="text grey right age">{{TimeSince $commit.Committer.When $.Lang}}</td> <td class="text grey right age">{{TimeSince $commit.Committer.When $.Lang}}</td>

2
templates/user/dashboard/feeds.tmpl

@ -62,7 +62,7 @@
{{ $repoLink := .GetRepoLink}} {{ $repoLink := .GetRepoLink}}
{{if $push.Commits}} {{if $push.Commits}}
{{range $push.Commits}} {{range $push.Commits}}
<li><img class="img-8" src="{{$push.AvatarLink .AuthorEmail}}"> <a class="commit-id" href="{{$repoLink}}/commit/{{.Sha1}}">{{ShortSha .Sha1}}</a> <span class="text truncate light grey has-emoji">{{.Message}}</span></li> <li><img class="img-8" src="{{$push.AvatarLink .AuthorEmail}}"> <a class="commit-id" href="{{$repoLink}}/commit/{{.Sha1}}">{{ShortSHA1 .Sha1}}</a> <span class="text truncate light grey has-emoji">{{.Message}}</span></li>
{{end}} {{end}}
{{end}} {{end}}
{{if and (gt $push.Len 1) $push.CompareURL}}<li><a href="{{AppSubUrl}}/{{$push.CompareURL}}">{{$.i18n.Tr "action.compare_commits" $push.Len}} »</a></li>{{end}} {{if and (gt $push.Len 1) $push.CompareURL}}<li><a href="{{AppSubUrl}}/{{$push.CompareURL}}">{{$.i18n.Tr "action.compare_commits" $push.Len}} »</a></li>{{end}}

Loading…
Cancel
Save