@@ -15,7 +15,7 @@ import (
1515 goversion "github.com/mcuadros/go-version"
1616)
1717
18- const REMOTE_PREFIX = "refs/remotes/"
18+ const RemotePrefix = "refs/remotes/"
1919
2020// getRefCommitID returns the last commit ID string of given reference (branch or tag).
2121func (repo * Repository ) getRefCommitID (name string ) (string , error ) {
@@ -31,17 +31,17 @@ func (repo *Repository) getRefCommitID(name string) (string, error) {
3131
3232// GetBranchCommitID returns last commit ID string of given branch.
3333func (repo * Repository ) GetBranchCommitID (name string ) (string , error ) {
34- return repo .getRefCommitID (BRANCH_PREFIX + name )
34+ return repo .getRefCommitID (BranchPrefix + name )
3535}
3636
3737// GetTagCommitID returns last commit ID string of given tag.
3838func (repo * Repository ) GetTagCommitID (name string ) (string , error ) {
39- return repo .getRefCommitID (TAG_PREFIX + name )
39+ return repo .getRefCommitID (TagPrefix + name )
4040}
4141
4242// GetRemoteBranchCommitID returns last commit ID string of given remote branch.
4343func (repo * Repository ) GetRemoteBranchCommitID (name string ) (string , error ) {
44- return repo .getRefCommitID (REMOTE_PREFIX + name )
44+ return repo .getRefCommitID (RemotePrefix + name )
4545}
4646
4747// parseCommitData parses commit information from the (uncompressed) raw
@@ -172,7 +172,7 @@ func (repo *Repository) getCommitByPathWithID(id sha1, relpath string) (*Commit,
172172 relpath = `\` + relpath
173173 }
174174
175- stdout , err := NewCommand ("log" , "-1" , _PRETTY_LOG_FORMAT , id .String (), "--" , relpath ).RunInDir (repo .Path )
175+ stdout , err := NewCommand ("log" , "-1" , prettyLogFormat , id .String (), "--" , relpath ).RunInDir (repo .Path )
176176 if err != nil {
177177 return nil , err
178178 }
@@ -187,7 +187,7 @@ func (repo *Repository) getCommitByPathWithID(id sha1, relpath string) (*Commit,
187187
188188// GetCommitByPath returns the last commit of relative path.
189189func (repo * Repository ) GetCommitByPath (relpath string ) (* Commit , error ) {
190- stdout , err := NewCommand ("log" , "-1" , _PRETTY_LOG_FORMAT , "--" , relpath ).RunInDirBytes (repo .Path )
190+ stdout , err := NewCommand ("log" , "-1" , prettyLogFormat , "--" , relpath ).RunInDirBytes (repo .Path )
191191 if err != nil {
192192 return nil , err
193193 }
@@ -201,7 +201,7 @@ func (repo *Repository) GetCommitByPath(relpath string) (*Commit, error) {
201201
202202func (repo * Repository ) CommitsByRangeSize (revision string , page , size int ) (* list.List , error ) {
203203 stdout , err := NewCommand ("log" , revision , "--skip=" + strconv .Itoa ((page - 1 )* size ),
204- "--max-count=" + strconv .Itoa (size ), _PRETTY_LOG_FORMAT ).RunInDirBytes (repo .Path )
204+ "--max-count=" + strconv .Itoa (size ), prettyLogFormat ).RunInDirBytes (repo .Path )
205205 if err != nil {
206206 return nil , err
207207 }
@@ -215,7 +215,7 @@ func (repo *Repository) CommitsByRange(revision string, page int) (*list.List, e
215215}
216216
217217func (repo * Repository ) searchCommits (id sha1 , keyword string ) (* list.List , error ) {
218- stdout , err := NewCommand ("log" , id .String (), "-100" , "-i" , "--grep=" + keyword , _PRETTY_LOG_FORMAT ).RunInDirBytes (repo .Path )
218+ stdout , err := NewCommand ("log" , id .String (), "-100" , "-i" , "--grep=" + keyword , prettyLogFormat ).RunInDirBytes (repo .Path )
219219 if err != nil {
220220 return nil , err
221221 }
@@ -236,7 +236,7 @@ func (repo *Repository) FileCommitsCount(revision, file string) (int64, error) {
236236
237237func (repo * Repository ) CommitsByFileAndRangeSize (revision , file string , page , size int ) (* list.List , error ) {
238238 stdout , err := NewCommand ("log" , revision , "--skip=" + strconv .Itoa ((page - 1 )* size ),
239- "--max-count=" + strconv .Itoa (size ), _PRETTY_LOG_FORMAT , "--" , file ).RunInDirBytes (repo .Path )
239+ "--max-count=" + strconv .Itoa (size ), prettyLogFormat , "--" , file ).RunInDirBytes (repo .Path )
240240 if err != nil {
241241 return nil , err
242242 }
@@ -379,7 +379,7 @@ func (repo *Repository) getCommitsBeforeLimit(id sha1, num int) (*list.List, err
379379// CommitsAfterDate returns a list of commits which committed after given date.
380380// The format of date should be in RFC3339.
381381func (repo * Repository ) CommitsAfterDate (date string ) (* list.List , error ) {
382- stdout , err := NewCommand ("log" , _PRETTY_LOG_FORMAT , "--since=" + date ).RunInDirBytes (repo .Path )
382+ stdout , err := NewCommand ("log" , prettyLogFormat , "--since=" + date ).RunInDirBytes (repo .Path )
383383 if err != nil {
384384 return nil , err
385385 }
0 commit comments