Skip to content

Commit 3a81fdf

Browse files
committed
rename fields
1 parent 6f0a41b commit 3a81fdf

20 files changed

+67
-46
lines changed

models/git_diff.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ func GetDiffRange(repoPath, beforeCommitId string, afterCommitId string, maxline
258258
cmd = exec.Command("git", "show", afterCommitId)
259259
} else {
260260
c, _ := commit.Parent(0)
261-
cmd = exec.Command("git", "diff", "-M", c.Id.String(), afterCommitId)
261+
cmd = exec.Command("git", "diff", "-M", c.ID.String(), afterCommitId)
262262
}
263263
} else {
264264
cmd = exec.Command("git", "diff", "-M", beforeCommitId, afterCommitId)

models/release.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func createTag(gitRepo *git.Repository, rel *Release) error {
6464
return err
6565
}
6666

67-
if err = gitRepo.CreateTag(rel.TagName, commit.Id.String()); err != nil {
67+
if err = gitRepo.CreateTag(rel.TagName, commit.ID.String()); err != nil {
6868
return err
6969
}
7070
} else {

models/update.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ func Update(refName, oldCommitId, newCommitId, userName, repoUserName, repoName
140140
actEmail = commit.Committer.Email
141141
}
142142
commits = append(commits,
143-
&base.PushCommit{commit.Id.String(),
143+
&base.PushCommit{commit.ID.String(),
144144
commit.Message(),
145145
commit.Author.Email,
146146
commit.Author.Name,

modules/git/blob.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ type Blob struct {
1818
}
1919

2020
func (b *Blob) Data() (io.Reader, error) {
21-
stdout, stderr, err := com.ExecCmdDirBytes(b.repo.Path, "git", "show", b.Id.String())
21+
stdout, stderr, err := com.ExecCmdDirBytes(b.repo.Path, "git", "show", b.ID.String())
2222
if err != nil {
2323
return nil, errors.New(string(stderr))
2424
}

modules/git/commit.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
// Commit represents a git commit.
1515
type Commit struct {
1616
Tree
17-
Id sha1 // The id of this commit object
17+
ID sha1 // The id of this commit object
1818
Author *Signature
1919
Committer *Signature
2020
CommitMessage string
@@ -35,7 +35,7 @@ func (c *Commit) Summary() string {
3535
// Return oid of the parent number n (0-based index). Return nil if no such parent exists.
3636
func (c *Commit) ParentId(n int) (id sha1, err error) {
3737
if n >= len(c.parents) {
38-
err = IdNotExist
38+
err = IDNotExist
3939
return
4040
}
4141
return c.parents[n], nil
@@ -61,7 +61,7 @@ func (c *Commit) ParentCount() int {
6161
}
6262

6363
func (c *Commit) CommitsBefore() (*list.List, error) {
64-
return c.repo.getCommitsBefore(c.Id)
64+
return c.repo.getCommitsBefore(c.ID)
6565
}
6666

6767
func (c *Commit) CommitsBeforeUntil(commitId string) (*list.List, error) {
@@ -73,19 +73,19 @@ func (c *Commit) CommitsBeforeUntil(commitId string) (*list.List, error) {
7373
}
7474

7575
func (c *Commit) CommitsCount() (int, error) {
76-
return c.repo.commitsCount(c.Id)
76+
return c.repo.commitsCount(c.ID)
7777
}
7878

7979
func (c *Commit) SearchCommits(keyword string) (*list.List, error) {
80-
return c.repo.searchCommits(c.Id, keyword)
80+
return c.repo.searchCommits(c.ID, keyword)
8181
}
8282

8383
func (c *Commit) CommitsByRange(page int) (*list.List, error) {
84-
return c.repo.commitsByRange(c.Id, page)
84+
return c.repo.commitsByRange(c.ID, page)
8585
}
8686

8787
func (c *Commit) GetCommitOfRelPath(relPath string) (*Commit, error) {
88-
return c.repo.getCommitOfRelPath(c.Id, relPath)
88+
return c.repo.getCommitOfRelPath(c.ID, relPath)
8989
}
9090

9191
func (c *Commit) GetSubModule(entryname string) (*SubModule, error) {

modules/git/commit_archive.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func (c *Commit) CreateArchive(path string, archiveType ArchiveType) error {
2828
return fmt.Errorf("unknown format: %v", archiveType)
2929
}
3030

31-
_, stderr, err := com.ExecCmdDir(c.repo.Path, "git", "archive", "--format="+format, "-o", path, c.Id.String())
31+
_, stderr, err := com.ExecCmdDir(c.repo.Path, "git", "archive", "--format="+format, "-o", path, c.ID.String())
3232
if err != nil {
3333
return fmt.Errorf("%s", stderr)
3434
}

modules/git/repo_commit.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ l:
7070
if err != nil {
7171
return nil, err
7272
}
73-
commit.Tree.Id = id
73+
commit.Tree.ID = id
7474
case "parent":
7575
// A commit can have one or more parents
7676
oid, err := NewIdFromString(string(line[spacepos+1:]))
@@ -121,7 +121,7 @@ func (repo *Repository) getCommit(id sha1) (*Commit, error) {
121121
return nil, err
122122
}
123123
commit.repo = repo
124-
commit.Id = id
124+
commit.ID = id
125125

126126
repo.commitCache[id] = commit
127127
return commit, nil
@@ -211,7 +211,7 @@ func (repo *Repository) CommitsBetween(last *Commit, before *Commit) (*list.List
211211
var err error
212212
cur := last
213213
for {
214-
if cur.Id.Equal(before.Id) {
214+
if cur.ID.Equal(before.ID) {
215215
break
216216
}
217217
l.PushBack(cur)
@@ -240,7 +240,7 @@ func (repo *Repository) commitsBefore(lock *sync.Mutex, l *list.List, parent *li
240240
for {
241241
if in == nil {
242242
break
243-
} else if in.Value.(*Commit).Id.Equal(commit.Id) {
243+
} else if in.Value.(*Commit).ID.Equal(commit.ID) {
244244
return nil
245245
} else {
246246
if in.Next() == nil {

modules/git/repo_tag.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func (repo *Repository) getTag(id sha1) (*Tag, error) {
6969
// Tag is a commit.
7070
if ObjectType(tp) == COMMIT {
7171
tag := &Tag{
72-
Id: id,
72+
ID: id,
7373
Object: id,
7474
Type: string(COMMIT),
7575
repo: repo,
@@ -89,7 +89,7 @@ func (repo *Repository) getTag(id sha1) (*Tag, error) {
8989
return nil, err
9090
}
9191

92-
tag.Id = id
92+
tag.ID = id
9393
tag.repo = repo
9494

9595
repo.tagCache[id] = tag

modules/git/sha1.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
)
1313

1414
var (
15-
IdNotExist = errors.New("sha1 id not exist")
15+
IDNotExist = errors.New("sha1 ID does not exist")
1616
)
1717

1818
type sha1 [20]byte

modules/git/signature.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,23 @@ type Signature struct {
2626
// FIXME: include timezone for timestamp!
2727
func newSignatureFromCommitline(line []byte) (_ *Signature, err error) {
2828
sig := new(Signature)
29-
emailstart := bytes.IndexByte(line, '<')
30-
sig.Name = string(line[:emailstart-1])
31-
emailstop := bytes.IndexByte(line, '>')
32-
sig.Email = string(line[emailstart+1 : emailstop])
29+
emailStart := bytes.IndexByte(line, '<')
30+
sig.Name = string(line[:emailStart-1])
31+
emailEnd := bytes.IndexByte(line, '>')
32+
sig.Email = string(line[emailStart+1 : emailEnd])
3333

3434
// Check date format.
35-
firstChar := line[emailstop+2]
35+
firstChar := line[emailEnd+2]
3636
if firstChar >= 48 && firstChar <= 57 {
37-
timestop := bytes.IndexByte(line[emailstop+2:], ' ')
38-
timestring := string(line[emailstop+2 : emailstop+2+timestop])
37+
timestop := bytes.IndexByte(line[emailEnd+2:], ' ')
38+
timestring := string(line[emailEnd+2 : emailEnd+2+timestop])
3939
seconds, err := strconv.ParseInt(timestring, 10, 64)
4040
if err != nil {
4141
return nil, err
4242
}
4343
sig.When = time.Unix(seconds, 0)
4444
} else {
45-
sig.When, err = time.Parse("Mon Jan _2 15:04:05 2006 -0700", string(line[emailstop+2:]))
45+
sig.When, err = time.Parse("Mon Jan _2 15:04:05 2006 -0700", string(line[emailEnd+2:]))
4646
if err != nil {
4747
return nil, err
4848
}

modules/git/signature_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 2015 The Gogs Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
5+
package git
6+
7+
import (
8+
"testing"
9+
10+
. "github.com/smartystreets/goconvey/convey"
11+
)
12+
13+
func Test_newSignatureFromCommitline(t *testing.T) {
14+
Convey("Parse signature from commit line", t, func() {
15+
line := "Intern <intern@macbook-intern.(none)> 1445412825 +0200"
16+
sig, err := newSignatureFromCommitline([]byte(line))
17+
So(err, ShouldBeNil)
18+
So(sig, ShouldNotBeNil)
19+
})
20+
}

modules/git/submodule.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package git
66

77
import (
88
"strings"
9+
910
"github.com/gogits/gogs/modules/setting"
1011
)
1112

@@ -53,7 +54,7 @@ func (sf *SubModuleFile) RefUrl() string {
5354
j := strings.LastIndex(url, ":")
5455
if i > -1 && j > -1 {
5556
// fix problem with reverse proxy works only with local server
56-
if strings.Contains(setting.AppUrl,url[i+1:j]) {
57+
if strings.Contains(setting.AppUrl, url[i+1:j]) {
5758
return setting.AppUrl + url[j+1:]
5859
} else {
5960
return "http://" + url[i+1:j] + "/" + url[j+1:]

modules/git/tag.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
// Tag represents a Git tag.
1212
type Tag struct {
1313
Name string
14-
Id sha1
14+
ID sha1
1515
repo *Repository
1616
Object sha1 // The id of this commit object
1717
Type string

modules/git/tree.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ var (
1818

1919
// A tree is a flat directory listing.
2020
type Tree struct {
21-
Id sha1
21+
ID sha1
2222
repo *Repository
2323

2424
// parent tree
@@ -66,7 +66,7 @@ func parseTreeData(tree *Tree, data []byte) ([]*TreeEntry, error) {
6666
if err != nil {
6767
return nil, err
6868
}
69-
entry.Id = id
69+
entry.ID = id
7070
pos += step + 1 // Skip half of sha1.
7171

7272
step = bytes.IndexByte(data[pos:], '\n')
@@ -100,7 +100,7 @@ func (t *Tree) SubTree(rpath string) (*Tree, error) {
100100
return nil, err
101101
}
102102

103-
g, err = t.repo.getTree(te.Id)
103+
g, err = t.repo.getTree(te.ID)
104104
if err != nil {
105105
return nil, err
106106
}
@@ -117,7 +117,7 @@ func (t *Tree) ListEntries(relpath string) (Entries, error) {
117117
t.entriesParsed = true
118118

119119
stdout, stderr, err := com.ExecCmdDirBytes(t.repo.Path,
120-
"git", "ls-tree", t.Id.String())
120+
"git", "ls-tree", t.ID.String())
121121
if err != nil {
122122
if strings.Contains(err.Error(), "exit status 128") {
123123
return nil, errors.New(strings.TrimSpace(string(stderr)))
@@ -130,7 +130,7 @@ func (t *Tree) ListEntries(relpath string) (Entries, error) {
130130

131131
func NewTree(repo *Repository, id sha1) *Tree {
132132
tree := new(Tree)
133-
tree.Id = id
133+
tree.ID = id
134134
tree.repo = repo
135135
return tree
136136
}

modules/git/tree_blob.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
func (t *Tree) GetTreeEntryByPath(relpath string) (*TreeEntry, error) {
1414
if len(relpath) == 0 {
1515
return &TreeEntry{
16-
Id: t.Id,
16+
ID: t.ID,
1717
Type: TREE,
1818
mode: ModeTree,
1919
}, nil

modules/git/tree_entry.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const (
2424
)
2525

2626
type TreeEntry struct {
27-
Id sha1
27+
ID sha1
2828
Type ObjectType
2929

3030
mode EntryMode
@@ -51,7 +51,7 @@ func (te *TreeEntry) Size() int64 {
5151
return te.size
5252
}
5353

54-
stdout, _, err := com.ExecCmdDir(te.ptree.repo.Path, "git", "cat-file", "-s", te.Id.String())
54+
stdout, _, err := com.ExecCmdDir(te.ptree.repo.Path, "git", "cat-file", "-s", te.ID.String())
5555
if err != nil {
5656
return 0
5757
}

modules/middleware/repo.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ func RepoRef() macaron.Handler {
118118
ctx.Handle(500, "GetCommitOfBranch", err)
119119
return
120120
}
121-
ctx.Repo.CommitID = ctx.Repo.Commit.Id.String()
121+
ctx.Repo.CommitID = ctx.Repo.Commit.ID.String()
122122
ctx.Repo.IsBranch = true
123123

124124
} else {
@@ -149,7 +149,7 @@ func RepoRef() macaron.Handler {
149149
ctx.Handle(500, "GetCommitOfBranch", err)
150150
return
151151
}
152-
ctx.Repo.CommitID = ctx.Repo.Commit.Id.String()
152+
ctx.Repo.CommitID = ctx.Repo.Commit.ID.String()
153153

154154
} else if ctx.Repo.GitRepo.IsTagExist(refName) {
155155
ctx.Repo.IsTag = true
@@ -158,7 +158,7 @@ func RepoRef() macaron.Handler {
158158
ctx.Handle(500, "GetCommitOfTag", err)
159159
return
160160
}
161-
ctx.Repo.CommitID = ctx.Repo.Commit.Id.String()
161+
ctx.Repo.CommitID = ctx.Repo.Commit.ID.String()
162162
} else if len(refName) == 40 {
163163
ctx.Repo.IsCommit = true
164164
ctx.Repo.CommitID = refName

routers/repo/release.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,10 @@ func Releases(ctx *middleware.Context) {
8888
tags[i] = &models.Release{
8989
Title: rawTag,
9090
TagName: rawTag,
91-
Sha1: commit.Id.String(),
91+
Sha1: commit.ID.String(),
9292
}
9393

94-
tags[i].NumCommits, err = ctx.Repo.GitRepo.CommitsCount(commit.Id.String())
94+
tags[i].NumCommits, err = ctx.Repo.GitRepo.CommitsCount(commit.ID.String())
9595
if err != nil {
9696
ctx.Handle(500, "CommitsCount", err)
9797
return
@@ -190,7 +190,7 @@ func NewReleasePost(ctx *middleware.Context, form auth.NewReleaseForm) {
190190
Title: form.Title,
191191
TagName: form.TagName,
192192
Target: form.Target,
193-
Sha1: commit.Id.String(),
193+
Sha1: commit.ID.String(),
194194
NumCommits: commitsCount,
195195
Note: form.Content,
196196
IsDraft: len(form.Draft) > 0,

routers/repo/repo.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,13 +317,13 @@ func Download(ctx *middleware.Context) {
317317
return
318318
}
319319

320-
archivePath = path.Join(archivePath, base.ShortSha(commit.Id.String())+ext)
320+
archivePath = path.Join(archivePath, base.ShortSha(commit.ID.String())+ext)
321321
if !com.IsFile(archivePath) {
322322
if err := commit.CreateArchive(archivePath, archiveType); err != nil {
323323
ctx.Handle(500, "Download -> CreateArchive "+archivePath, err)
324324
return
325325
}
326326
}
327327

328-
ctx.ServeFile(archivePath, ctx.Repo.Repository.Name+"-"+base.ShortSha(commit.Id.String())+ext)
328+
ctx.ServeFile(archivePath, ctx.Repo.Repository.Name+"-"+base.ShortSha(commit.ID.String())+ext)
329329
}

routers/repo/view.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ func Home(ctx *middleware.Context) {
151151
ctx.Handle(500, "GetCommitOfRelPath", err)
152152
return
153153
}
154-
files = append(files, []interface{}{te, git.NewSubModuleFile(c, smUrl, te.Id.String())})
154+
files = append(files, []interface{}{te, git.NewSubModuleFile(c, smUrl, te.ID.String())})
155155
}
156156
}
157157
ctx.Data["Files"] = files

0 commit comments

Comments
 (0)