Extend static functions in CAppUtils with a window handle parameter
[TortoiseGit.git] / src / TortoiseProc / Commands / FormatPatchCommand.cpp
blobcd7ce7a291b281783c93b01057919f243cae5eee
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2009, 2015-2016, 2018 - TortoiseGit
4 // Copyright (C) 2007-2008 - TortoiseSVN
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software Foundation,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #include "stdafx.h"
21 #include "FormatPatchCommand.h"
23 #include "FormatPatchDlg.h"
24 #include "Git.h"
25 #include "ShellUpdater.h"
26 #include "ProgressDlg.h"
27 #include "AppUtils.h"
29 bool FormatPatchCommand::Execute()
31 CFormatPatchDlg dlg;
32 // dlg.m_bIsTag=TRUE;
33 CString startval = parser.GetVal(L"startrev");
34 CString endval = parser.GetVal(L"endrev");
36 if( endval.IsEmpty() && (!startval.IsEmpty()))
38 dlg.m_Since=startval;
39 dlg.m_Radio = IDC_RADIO_SINCE;
41 else if( (!endval.IsEmpty()) && (!startval.IsEmpty()))
43 dlg.m_From=startval;
44 dlg.m_To=endval;
45 dlg.m_Radio = IDC_RADIO_RANGE;
48 if(dlg.DoModal()==IDOK)
50 CString cmd;
51 CString range;
53 switch(dlg.m_Radio)
55 case IDC_RADIO_SINCE:
56 range=g_Git.FixBranchName(dlg.m_Since);
57 break;
58 case IDC_RADIO_NUM:
59 range.Format(L"-%d", dlg.m_Num);
60 break;
61 case IDC_RADIO_RANGE:
62 range.Format(L"%s..%s", (LPCTSTR)dlg.m_From, (LPCTSTR)dlg.m_To);
63 break;
65 dlg.m_Dir.Replace(L'\\', L'/');
66 cmd.Format(L"git.exe format-patch%s -o \"%s\" %s",
67 dlg.m_bNoPrefix ? L" --no-prefix" : L"",
68 (LPCTSTR)dlg.m_Dir,
69 (LPCTSTR)range
72 CProgressDlg progress;
73 progress.m_GitCmd=cmd;
74 progress.DoModal();
76 CShellUpdater::Instance().AddPathForUpdate(CTGitPath(dlg.m_Dir));
77 CShellUpdater::Instance().Flush();
79 if(!progress.m_GitStatus)
81 if(dlg.m_bSendMail)
82 CAppUtils::SendPatchMail(hwndExplorer, cmd, progress.m_LogText, true);
84 return !progress.m_GitStatus;
86 return FALSE;