Showing the changes to modules/git/repo_commit.go (1 of 54 files). Show all
Unified · Split
| @@ -10,7 +10,7 @@ import ( · 9 unmodified lines | ||
| 10 | 10 | "strconv" |
| 11 | 11 | "strings" |
| 12 | 12 | |
| 13 | − version "github.com/mcuadros/go-version" | |
| 13 | + "github.com/mcuadros/go-version" | |
| 14 | 14 | ) |
| 15 | 15 | |
| 16 | 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 | 270 | return repo.parsePrettyFormatLogToList(stdout) |
| 271 | 271 | } |
| 272 | 272 | |
| 273 | −func (repo *Repository) getFilesChanged(id1 string, id2 string) ([]string, error) { | |
| 273 | +func (repo *Repository) getFilesChanged(id1, id2 string) ([]string, error) { | |
| 274 | 274 | stdout, err := NewCommand("diff", "--name-only", id1, id2).RunInDirBytes(repo.Path) |
| 275 | 275 | if err != nil { |
| 276 | 276 | return nil, err |
| @@ -278,6 +278,15 @@ func (repo *Repository) getFilesChanged(id1 string, id2 string) ([]string, error · 1 unmodified line | ||
| 278 | 278 | 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 | |
| 282 | +func (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 | 290 | // FileCommitsCount return the number of files at a revison |
| 282 | 291 | func (repo *Repository) FileCommitsCount(revision, file string) (int64, error) { |
| 283 | 292 | return commitsCount(repo.Path, revision, file) |