Umk: Git exe file path fix for windows builds. (#230)

This commit is contained in:
İsmail Yılmaz 2025-02-02 13:23:00 +03:00 committed by GitHub
parent 7cedb84877
commit 5b1eecd275
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 22 additions and 6 deletions

View file

@ -554,13 +554,14 @@ Vector<String> RepoInfo(const String& package)
if(repo == GIT_DIR) {
String h = GetCurrentDirectory();
SetCurrentDirectory(d);
String v = HostSys("git rev-list --count HEAD");
String gitpath = GetGitPath();
String v = HostSys(gitpath + " rev-list --count HEAD");
if(IsDigit(*v))
info.Add("#define bmGIT_REVCOUNT " + AsCString(TrimBoth(v)));
v = HostSys("git rev-parse HEAD");
v = HostSys(gitpath + " rev-parse HEAD");
if(v.GetCount())
info.Add("#define bmGIT_HASH " + AsCString(TrimBoth(v)));
v = HostSys("git rev-parse --abbrev-ref HEAD");
v = HostSys(gitpath + " rev-parse --abbrev-ref HEAD");
if(v.GetCount())
info.Add("#define bmGIT_BRANCH " + AsCString(TrimBoth(v)));
SetCurrentDirectory(h);

View file

@ -648,5 +648,6 @@ enum { NOT_REPO_DIR = 0, SVN_DIR, GIT_DIR };
int GetRepoKind(const String& p);
int GetRepo(String& path);
String GetGitPath();
#endif

View file

@ -25,3 +25,17 @@ int GetRepoKind(const String& p)
String pp = p;
return GetRepo(pp);
}
String GetGitPath()
{
#ifdef PLATFORM_WIN32
static String path;
ONCELOCK {
path = AppendFileName(GetExeFolder(), "\\bin\\mingit\\cmd\\git.exe");
path = FileExists(path) ? "\"" + path + "\"" : "git";
}
return path;
#else
return "git";
#endif
}

View file

@ -131,7 +131,7 @@ void UppHubDlg::Install(const Index<String>& ii_, bool update)
if(n) {
String dir = GetHubDir() + '/' + n->name;
if(!DirectoryExists(dir)) {
String cmd = "git clone ";
String cmd = GetGitPath() + " clone ";
if(n->branch.GetCount())
cmd << "-b " + n->branch << ' ';
cmd << n->repo;
@ -150,11 +150,11 @@ void UppHubDlg::Install(const Index<String>& ii_, bool update)
}
}
} else if (update) {
String cmd = "git -C ";
String cmd = GetGitPath() + " -C ";
cmd << dir << " clean -fxd";
PutConsole(cmd);
system(cmd);
cmd = "git -C ";
cmd = GetGitPath() + " -C ";
cmd << dir << " pull";
PutConsole(cmd);
system(cmd);