diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2019-06-27 02:15:26 +0800 |
---|---|---|
committer | techknowlogick <techknowlogick@gitea.io> | 2019-06-26 14:15:26 -0400 |
commit | edc94c70413048107ea728ff330f32ca3de6df88 (patch) | |
tree | cf5bcc5ba8ee4b2e585dc14a6cf7440ce88bc073 /models/git_diff.go | |
parent | 161e12e157a48f9bcd2de50c187c77444aa2a9a8 (diff) | |
download | gitea-edc94c70413048107ea728ff330f32ca3de6df88.tar.gz gitea-edc94c70413048107ea728ff330f32ca3de6df88.zip |
Monitor all git commands; move blame to git package and replace git as a variable (#6864)
* monitor all git commands; move blame to git package and replace git as a variable
* use git command but not other commands
* fix build
* move exec.Command to git.NewCommand
* fix fmt
* remove unrelated changes
* remove unrelated changes
* refactor IsEmpty and add tests
* fix tests
* fix tests
* fix tests
* fix tests
* remove gitLogger
* fix fmt
* fix isEmpty
* fix lint
* fix tests
Diffstat (limited to 'models/git_diff.go')
-rw-r--r-- | models/git_diff.go | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/models/git_diff.go b/models/git_diff.go index 29c424c11c..bc79a73a4e 100644 --- a/models/git_diff.go +++ b/models/git_diff.go @@ -675,7 +675,7 @@ func GetDiffRangeWithWhitespaceBehavior(repoPath, beforeCommitID, afterCommitID var cmd *exec.Cmd if len(beforeCommitID) == 0 && commit.ParentCount() == 0 { - cmd = exec.Command("git", "show", afterCommitID) + cmd = exec.Command(git.GitExecutable, "show", afterCommitID) } else { actualBeforeCommitID := beforeCommitID if len(actualBeforeCommitID) == 0 { @@ -688,7 +688,7 @@ func GetDiffRangeWithWhitespaceBehavior(repoPath, beforeCommitID, afterCommitID } diffArgs = append(diffArgs, actualBeforeCommitID) diffArgs = append(diffArgs, afterCommitID) - cmd = exec.Command("git", diffArgs...) + cmd = exec.Command(git.GitExecutable, diffArgs...) } cmd.Dir = repoPath cmd.Stderr = os.Stderr @@ -752,23 +752,23 @@ func GetRawDiffForFile(repoPath, startCommit, endCommit string, diffType RawDiff switch diffType { case RawDiffNormal: if len(startCommit) != 0 { - cmd = exec.Command("git", append([]string{"diff", "-M", startCommit, endCommit}, fileArgs...)...) + cmd = exec.Command(git.GitExecutable, append([]string{"diff", "-M", startCommit, endCommit}, fileArgs...)...) } else if commit.ParentCount() == 0 { - cmd = exec.Command("git", append([]string{"show", endCommit}, fileArgs...)...) + cmd = exec.Command(git.GitExecutable, append([]string{"show", endCommit}, fileArgs...)...) } else { c, _ := commit.Parent(0) - cmd = exec.Command("git", append([]string{"diff", "-M", c.ID.String(), endCommit}, fileArgs...)...) + cmd = exec.Command(git.GitExecutable, append([]string{"diff", "-M", c.ID.String(), endCommit}, fileArgs...)...) } case RawDiffPatch: if len(startCommit) != 0 { query := fmt.Sprintf("%s...%s", endCommit, startCommit) - cmd = exec.Command("git", append([]string{"format-patch", "--no-signature", "--stdout", "--root", query}, fileArgs...)...) + cmd = exec.Command(git.GitExecutable, append([]string{"format-patch", "--no-signature", "--stdout", "--root", query}, fileArgs...)...) } else if commit.ParentCount() == 0 { - cmd = exec.Command("git", append([]string{"format-patch", "--no-signature", "--stdout", "--root", endCommit}, fileArgs...)...) + cmd = exec.Command(git.GitExecutable, append([]string{"format-patch", "--no-signature", "--stdout", "--root", endCommit}, fileArgs...)...) } else { c, _ := commit.Parent(0) query := fmt.Sprintf("%s...%s", endCommit, c.ID.String()) - cmd = exec.Command("git", append([]string{"format-patch", "--no-signature", "--stdout", query}, fileArgs...)...) + cmd = exec.Command(git.GitExecutable, append([]string{"format-patch", "--no-signature", "--stdout", query}, fileArgs...)...) } default: return fmt.Errorf("invalid diffType: %s", diffType) |