From 345821fed510781ddebf53e204ea17fb5af584ec Mon Sep 17 00:00:00 2001 From: Sven Strickroth Date: Sat, 10 Sep 2011 17:02:08 +0200 Subject: [PATCH] refatored CreateRepoCommand Signed-off-by: Sven Strickroth --- .../Commands/CreateRepositoryCommand.cpp | 58 ++++++++++++++++++++++ .../Commands/CreateRepositoryCommand.h | 42 ++-------------- src/TortoiseProc/TortoiseProc.vcproj | 4 ++ 3 files changed, 67 insertions(+), 37 deletions(-) create mode 100644 src/TortoiseProc/Commands/CreateRepositoryCommand.cpp diff --git a/src/TortoiseProc/Commands/CreateRepositoryCommand.cpp b/src/TortoiseProc/Commands/CreateRepositoryCommand.cpp new file mode 100644 index 000000000..48ebc78fd --- /dev/null +++ b/src/TortoiseProc/Commands/CreateRepositoryCommand.cpp @@ -0,0 +1,58 @@ +// TortoiseGit - a Windows shell extension for easy version control + +// Copyright (C) 2008-2011 - TortoiseGit + +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +// +#include "StdAfx.h" +#include "Command.h" +#include "CreateRepositoryCommand.h" + +#include "MessageBox.h" +#include "CommonResource.h" +#include "git.h" + +#include "CreateRepoDlg.h" + +bool CreateRepositoryCommand::Execute() +{ + CCreateRepoDlg dlg; + if(dlg.DoModal() == IDOK) + { + CGit git; + git.m_CurrentDir = this->orgCmdLinePath.GetWinPath(); + CString output; + int ret; + + if (dlg.m_bBare) + ret = git.Run(_T("git.exe init-db --bare"), &output, CP_UTF8); + else + ret = git.Run(_T("git.exe init-db"), &output, CP_UTF8); + + if (output.IsEmpty()) output = _T("git.Run() had no output"); + + if (ret) + { + CMessageBox::Show(hwndExplorer, output, _T("TortoiseGit"), MB_ICONERROR); + return false; + } + else + { + CMessageBox::Show(hwndExplorer, output, _T("TortoiseGit"), MB_OK | MB_ICONINFORMATION); + } + return true; + } + return false; +} diff --git a/src/TortoiseProc/Commands/CreateRepositoryCommand.h b/src/TortoiseProc/Commands/CreateRepositoryCommand.h index 40344cf63..40a58ec16 100644 --- a/src/TortoiseProc/Commands/CreateRepositoryCommand.h +++ b/src/TortoiseProc/Commands/CreateRepositoryCommand.h @@ -1,6 +1,7 @@ -// TortoiseSVN - a Windows shell extension for easy version control +// TortoiseGit - a Windows shell extension for easy version control -// Copyright (C) 2007-2008 - TortoiseSVN +// Copyright (C) 2011 - TortoiseGit +// Copyright (C) 2007 - TortoiseSVN // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -19,14 +20,9 @@ #pragma once #include "Command.h" -#include "MessageBox.h" -#include "CommonResource.h" -#include "git.h" - -#include "CreateRepoDlg.h" /** * \ingroup TortoiseProc - * Creates a repository + * Shows the create repository dialog. */ class CreateRepositoryCommand : public Command { @@ -34,34 +30,6 @@ public: /** * Executes the command. */ - virtual bool Execute() - { - CCreateRepoDlg dlg; - if(dlg.DoModal()==IDOK) - { - CGit git; - git.m_CurrentDir=this->orgCmdLinePath.GetWinPath(); - CString output; - int Ret; - - if (dlg.m_bBare) Ret = git.Run(_T("git.exe init-db --bare"),&output,CP_UTF8); - else Ret = git.Run(_T("git.exe init-db"),&output,CP_UTF8); - - if (output.IsEmpty()) output = _T("git.Run() had no output"); - - if (Ret) - { - CMessageBox::Show(hwndExplorer, output, _T("TortoiseGit"), MB_ICONERROR); - return false; - } - else - { - CMessageBox::Show(hwndExplorer, output, _T("TortoiseGit"), MB_OK | MB_ICONINFORMATION); - } - return true; - } - return false; - } + virtual bool Execute(); }; - diff --git a/src/TortoiseProc/TortoiseProc.vcproj b/src/TortoiseProc/TortoiseProc.vcproj index f825fa476..d1b77dd4a 100644 --- a/src/TortoiseProc/TortoiseProc.vcproj +++ b/src/TortoiseProc/TortoiseProc.vcproj @@ -2157,6 +2157,10 @@ > + + -- 2.11.4.GIT