1
1
package com.huayi.intellijplatform.gitstats.utils
2
2
3
3
import git4idea.config.GitExecutableManager
4
+ import git4idea.config.GitExecutableDetector
4
5
import java.util.concurrent.TimeUnit
5
6
import com.intellij.openapi.project.Project
6
7
@@ -29,7 +30,11 @@ data class CommitFilesStats(
29
30
class GitUtils (project : Project ) {
30
31
private val gitExecutablePath: String = GitExecutableManager .getInstance().getExecutable(project).exePath
31
32
private val basePath: String = project.basePath as String
33
+ private val gitBashExecutablePath: String? = GitExecutableDetector .getBashExecutablePath(gitExecutablePath)
32
34
35
+ init {
36
+ println (gitBashExecutablePath)
37
+ }
33
38
// companion object {
34
39
// fun getGitExecutablePath(project: Project): String {
35
40
// return GitExecutableManager.getInstance().getExecutable(project).exePath
@@ -41,9 +46,9 @@ class GitUtils(project: Project) {
41
46
): Array <UserStats > {
42
47
val os = Utils .getOS()
43
48
val command = listOf (
44
- if (os == " Windows" ) " cmd" else " /bin/sh" ,
49
+ if (os == " Windows" ) gitBashExecutablePath ? : " cmd" else " /bin/sh" ,
45
50
if (os == " Windows" ) " /c" else " -c" ,
46
- " $gitExecutablePath log --format=\" %aN\" | sort -u | while read name; do echo \" \$ name\" ; git log --author=\" \$ name\" --pretty=tformat: --since= =\" $startDate \" --until=\" $endDate \" --numstat | awk '{ add += \$ 1; subs += \$ 2; file++ } END { printf \" added lines: %s, removed lines: %s, modified files: %s\\ n\" , add ? add : 0, subs ? subs : 0, file ? file : 0 }' -; done"
51
+ " $gitExecutablePath log --format=\" %aN\" | sort -u | while read name; do echo \" \$ name\" ; git log --author=\" \$ name\" --pretty=\" tformat:\" --since=\" $startDate \" --until=\" $endDate \" --numstat | awk '{ add += \$ 1; subs += \$ 2; file++ } END { printf \" added lines: %s, removed lines: %s, modified files: %s\\ n\" , add ? add : 0, subs ? subs : 0, file ? file : 0 }' -; done"
47
52
)
48
53
val process = Utils .runCommand(basePath, command, timeoutAmount, timeUnit)
49
54
val regex = Regex (" (.+)\\ n+added lines: (\\ d*), removed lines: (\\ d+), modified files: (\\ d+)" )
0 commit comments