Skip to content

Commit 03ef311

Browse files
committed
Require Git 1.8.3
1 parent 044ddd1 commit 03ef311

File tree

6 files changed

+7
-58
lines changed

6 files changed

+7
-58
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ go:
1010
- 1.10.x
1111
- 1.11.x
1212
- 1.12.x
13+
- 1.13.x
1314

1415
script:
1516
- go get golang.org/x/tools/cmd/cover

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Package git-module is a Go module for Git access through shell commands.
55
## Limitations
66

77
- Go version must be at least **1.4**.
8-
- Git version must be no less than **1.7.1**, and greater than or equal to **1.8.3** is recommended.
8+
- Git version must be no less than **1.8.3**.
99
- For Windows users, try use as new a version as possible.
1010

1111
## License

commit.go

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ import (
1313
"net/http"
1414
"strconv"
1515
"strings"
16-
17-
goversion "github.com/mcuadros/go-version"
1816
)
1917

2018
// Commit represents a git commit.
@@ -140,14 +138,7 @@ func CommitChanges(repoPath string, opts CommitChangesOptions) error {
140138

141139
func commitsCount(repoPath, revision, relpath string) (int64, error) {
142140
var cmd *Command
143-
isFallback := false
144-
if goversion.Compare(gitVersion, "1.8.0", "<") {
145-
isFallback = true
146-
cmd = NewCommand("log", "--pretty=format:''")
147-
} else {
148-
cmd = NewCommand("rev-list", "--count")
149-
}
150-
cmd.AddArguments(revision)
141+
cmd = NewCommand("rev-list", "--count").AddArguments(revision)
151142
if len(relpath) > 0 {
152143
cmd.AddArguments("--", relpath)
153144
}
@@ -157,9 +148,6 @@ func commitsCount(repoPath, revision, relpath string) (int64, error) {
157148
return 0, err
158149
}
159150

160-
if isFallback {
161-
return int64(strings.Count(stdout, "\n")) + 1, nil
162-
}
163151
return strconv.ParseInt(strings.TrimSpace(stdout), 10, 64)
164152
}
165153

git.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,6 @@ import (
1010
"time"
1111
)
1212

13-
const version = "0.8.1"
14-
15-
func Version() string {
16-
return version
17-
}
18-
1913
var (
2014
// Debug enables verbose logging on everything.
2115
// This should be false in case Gogs starts in SSH mode.

repo_branch.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ package git
77
import (
88
"fmt"
99
"strings"
10-
11-
goversion "github.com/mcuadros/go-version"
1210
)
1311

1412
const BranchPrefix = "refs/heads/"
@@ -54,10 +52,6 @@ func (repo *Repository) GetHEADBranch() (*Branch, error) {
5452

5553
// SetDefaultBranch sets default branch of repository.
5654
func (repo *Repository) SetDefaultBranch(name string) error {
57-
if goversion.Compare(gitVersion, "1.7.10", "<") {
58-
return ErrUnsupportedVersion{"1.7.10"}
59-
}
60-
6155
_, err := NewCommand("symbolic-ref", "HEAD", BranchPrefix+name).RunInDir(repo.Path)
6256
return err
6357
}

repo_commit.go

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ import (
1111
"strconv"
1212
"strings"
1313
"time"
14-
15-
goversion "github.com/mcuadros/go-version"
1614
)
1715

1816
const RemotePrefix = "refs/remotes/"
@@ -257,37 +255,11 @@ func (repo *Repository) FilesCountBetween(startCommitID, endCommitID string) (in
257255

258256
// CommitsBetween returns a list that contains commits between [last, before).
259257
func (repo *Repository) CommitsBetween(last *Commit, before *Commit) (*list.List, error) {
260-
if goversion.Compare(gitVersion, "1.8.0", ">=") {
261-
stdout, err := NewCommand("rev-list", before.ID.String()+"..."+last.ID.String()).RunInDirBytes(repo.Path)
262-
if err != nil {
263-
return nil, err
264-
}
265-
return repo.parsePrettyFormatLogToList(bytes.TrimSpace(stdout))
266-
}
267-
268-
// Fallback to stupid solution, which iterates all commits of the repository
269-
// if before is not an ancestor of last.
270-
l := list.New()
271-
if last == nil || last.ParentCount() == 0 {
272-
return l, nil
273-
}
274-
275-
var err error
276-
cur := last
277-
for {
278-
if cur.ID.Equal(before.ID) {
279-
break
280-
}
281-
l.PushBack(cur)
282-
if cur.ParentCount() == 0 {
283-
break
284-
}
285-
cur, err = cur.Parent(0)
286-
if err != nil {
287-
return nil, err
288-
}
258+
stdout, err := NewCommand("rev-list", before.ID.String()+"..."+last.ID.String()).RunInDirBytes(repo.Path)
259+
if err != nil {
260+
return nil, err
289261
}
290-
return l, nil
262+
return repo.parsePrettyFormatLogToList(bytes.TrimSpace(stdout))
291263
}
292264

293265
func (repo *Repository) CommitsBetweenIDs(last, before string) (*list.List, error) {

0 commit comments

Comments
 (0)