forked from qt-creator/qt-creator
Git: Add git bash to tools menu
Can be useful to perform tasks that don't have a dedicated UI in Creator. In my setup, git bash was directly in the git installation folder %ProgramFiles%\Git and therefore one level above git.exe itself. Change-Id: I1ca0d3439690170d7fb840bca17e2c412effe0a4 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
committed by
André Hartmann
parent
97165f0cb8
commit
f486ff7dab
@@ -2537,6 +2537,24 @@ FilePath GitClient::gitBinDirectory() const
|
||||
return FilePath::fromString(path);
|
||||
}
|
||||
|
||||
bool GitClient::launchGitBash(const QString &workingDirectory)
|
||||
{
|
||||
bool success = true;
|
||||
const QString git = vcsBinary().toString();
|
||||
|
||||
if (git.isEmpty()) {
|
||||
success = false;
|
||||
} else {
|
||||
const QString gitBash = QFileInfo(git).absolutePath() + "/../git-bash.exe";
|
||||
success = QProcess::startDetached(gitBash, {}, workingDirectory);
|
||||
}
|
||||
|
||||
if (!success)
|
||||
VcsOutputWindow::appendError(msgCannotLaunch("git-bash"));
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
FilePath GitClient::vcsBinary() const
|
||||
{
|
||||
bool ok;
|
||||
|
||||
@@ -336,6 +336,7 @@ public:
|
||||
void launchGitK(const QString &workingDirectory) const { launchGitK(workingDirectory, QString()); }
|
||||
bool launchGitGui(const QString &workingDirectory);
|
||||
Utils::FilePath gitBinDirectory() const;
|
||||
bool launchGitBash(const QString &workingDirectory);
|
||||
|
||||
void launchRepositoryBrowser(const QString &workingDirectory) const;
|
||||
|
||||
|
||||
@@ -303,6 +303,7 @@ public:
|
||||
void gitkForCurrentFile();
|
||||
void gitkForCurrentFolder();
|
||||
void gitGui();
|
||||
void gitBash();
|
||||
void cleanProject();
|
||||
void cleanRepository();
|
||||
void updateSubmodules();
|
||||
@@ -962,6 +963,14 @@ GitPluginPrivate::GitPluginPrivate()
|
||||
= createRepositoryAction(gitToolsMenu, tr("Merge Tool"), "Git.MergeTool",
|
||||
context, true, std::bind(&GitPluginPrivate::startMergeTool, this));
|
||||
|
||||
// --------------
|
||||
if (Utils::HostOsInfo::isWindowsHost()) {
|
||||
gitToolsMenu->addSeparator(context);
|
||||
|
||||
createRepositoryAction(gitToolsMenu, tr("Git Bash"), "Git.GitBash",
|
||||
context, true, std::bind(&GitPluginPrivate::gitBash, this));
|
||||
}
|
||||
|
||||
/* \"Git Tools" menu */
|
||||
|
||||
// --------------
|
||||
@@ -1282,6 +1291,13 @@ void GitPluginPrivate::gitGui()
|
||||
m_gitClient.launchGitGui(state.topLevel());
|
||||
}
|
||||
|
||||
void GitPluginPrivate::gitBash()
|
||||
{
|
||||
const VcsBasePluginState state = currentState();
|
||||
QTC_ASSERT(state.hasTopLevel(), return);
|
||||
m_gitClient.launchGitBash(state.topLevel());
|
||||
}
|
||||
|
||||
void GitPluginPrivate::startCommit(CommitType commitType)
|
||||
{
|
||||
if (!promptBeforeCommit())
|
||||
|
||||
Reference in New Issue
Block a user