History

Fixes 4762 - Content API for Creating, Updating, Deleting Files (#6314)

Richard Mahn committed 7 years ago

Commit 22628111 parent 059195b54 files · +4154 −563Browse files

Showing the changes to modules/git/repo_commit.go (1 of 54 files). Show all

Unified · Split

modules/git/repo_commit.go+11−2
@@ -10,7 +10,7 @@ import ( · 9 unmodified lines
10 "strconv"10 "strconv"
11 "strings"11 "strings"
12 12
13 version "github.com/mcuadros/go-version"13 "github.com/mcuadros/go-version"
14)14)
15 15
16// GetRefCommitID returns the last commit ID string of given reference (branch or tag).16// GetRefCommitID returns the last commit ID string of given reference (branch or tag).
@@ -270,7 +270,7 @@ func (repo *Repository) searchCommits(id SHA1, opts SearchCommitsOptions) (*list · 253 unmodified lines
270 return repo.parsePrettyFormatLogToList(stdout)270 return repo.parsePrettyFormatLogToList(stdout)
271}271}
272 272
273func (repo *Repository) getFilesChanged(id1 string, id2 string) ([]string, error) {273func (repo *Repository) getFilesChanged(id1, id2 string) ([]string, error) {
274 stdout, err := NewCommand("diff", "--name-only", id1, id2).RunInDirBytes(repo.Path)274 stdout, err := NewCommand("diff", "--name-only", id1, id2).RunInDirBytes(repo.Path)
275 if err != nil {275 if err != nil {
276 return nil, err276 return nil, err
@@ -278,6 +278,15 @@ func (repo *Repository) getFilesChanged(id1 string, id2 string) ([]string, error · 1 unmodified line
278 return strings.Split(string(stdout), "\n"), nil278 return strings.Split(string(stdout), "\n"), nil
279}279}
280 280
281// FileChangedBetweenCommits Returns true if the file changed between commit IDs id1 and id2
282func (repo *Repository) FileChangedBetweenCommits(filename, id1, id2 string) (bool, error) {
283 stdout, err := NewCommand("diff", "--name-only", "-z", id1, id2, "--", filename).RunInDirBytes(repo.Path)
284 if err != nil {
285 return false, err
286 }
287 return len(strings.TrimSpace(string(stdout))) > 0, nil
288}
289
281// FileCommitsCount return the number of files at a revison290// FileCommitsCount return the number of files at a revison
282func (repo *Repository) FileCommitsCount(revision, file string) (int64, error) {291func (repo *Repository) FileCommitsCount(revision, file string) (int64, error) {
283 return commitsCount(repo.Path, revision, file)292 return commitsCount(repo.Path, revision, file)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t