Show Push Dialog after close commit dialog
[TortoiseGit.git] / src / TortoiseProc / Commands / CommitCommand.cpp
blob301b1c65f2fdb539b79423e9061a69c47bb25313
1 // TortoiseSVN - a Windows shell extension for easy version control
3 // Copyright (C) 2007-2008 - TortoiseSVN
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #include "StdAfx.h"
20 #include "CommitCommand.h"
21 #include "CommonResource.h"
22 #include "CommitDlg.h"
23 //#include "SVNProgressDlg.h"
24 #include "StringUtils.h"
25 #include "Hooks.h"
26 #include "MessageBox.h"
27 #include "AppUtils.h"
29 CString CommitCommand::LoadLogMessage()
31 CString msg;
32 if (parser.HasKey(_T("logmsg")))
34 msg = parser.GetVal(_T("logmsg"));
36 if (parser.HasKey(_T("logmsgfile")))
38 CString logmsgfile = parser.GetVal(_T("logmsgfile"));
39 CStringUtils::ReadStringFromTextFile(logmsgfile, msg);
41 return msg;
44 bool CommitCommand::Execute()
46 bool bRet = false;
47 bool bFailed = true;
48 CTGitPathList selectedList;
49 if (parser.HasKey(_T("logmsg")) && (parser.HasKey(_T("logmsgfile"))))
51 CMessageBox::Show(hwndExplorer, IDS_ERR_TWOLOGPARAMS, IDS_APPNAME, MB_ICONERROR);
52 return false;
54 CString sLogMsg = LoadLogMessage();
55 bool bSelectFilesForCommit = !!DWORD(CRegStdWORD(_T("Software\\TortoiseGit\\SelectFilesForCommit"), TRUE));
56 DWORD exitcode = 0;
57 CString error;
58 #if 0
59 if (CHooks::Instance().StartCommit(pathList, sLogMsg, exitcode, error))
61 if (exitcode)
63 CString temp;
64 temp.Format(IDS_ERR_HOOKFAILED, (LPCTSTR)error);
65 CMessageBox::Show(hwndExplorer, temp, _T("TortoiseGit"), MB_ICONERROR);
66 return false;
69 #endif
71 while (bFailed)
73 bFailed = false;
74 CCommitDlg dlg;
75 if (parser.HasKey(_T("bugid")))
77 dlg.m_sBugID = parser.GetVal(_T("bugid"));
80 if (parser.HasKey(_T("wholeproject")))
82 dlg.m_bWholeProject = TRUE;
85 dlg.m_sLogMessage = sLogMsg;
86 dlg.m_pathList = pathList;
87 dlg.m_checkedPathList = selectedList;
88 dlg.m_bSelectFilesForCommit = bSelectFilesForCommit;
89 if (dlg.DoModal() == IDOK)
91 if (dlg.m_pathList.GetCount()==0)
92 return false;
93 // if the user hasn't changed the list of selected items
94 // we don't use that list. Because if we would use the list
95 // of pre-checked items, the dialog would show different
96 // checked items on the next startup: it would only try
97 // to check the parent folder (which might not even show)
98 // instead, we simply use an empty list and let the
99 // default checking do its job.
100 if (!dlg.m_pathList.IsEqual(pathList))
101 selectedList = dlg.m_pathList;
102 pathList = dlg.m_updatedPathList;
103 sLogMsg = dlg.m_sLogMessage;
104 bSelectFilesForCommit = true;
106 if( dlg.m_bPushAfterCommit )
108 CAppUtils::Push();
110 // CGitProgressDlg progDlg;
111 // progDlg.SetChangeList(dlg.m_sChangeList, !!dlg.m_bKeepChangeList);
112 // if (parser.HasVal(_T("closeonend")))
113 // progDlg.SetAutoClose(parser.GetLongVal(_T("closeonend")));
114 // progDlg.SetCommand(CGitProgressDlg::GitProgress_Commit);
115 // progDlg.SetOptions(dlg.m_bKeepLocks ? ProgOptKeeplocks : ProgOptNone);
116 // progDlg.SetPathList(dlg.m_pathList);
117 // progDlg.SetCommitMessage(dlg.m_sLogMessage);
118 // progDlg.SetDepth(dlg.m_bRecursive ? Git_depth_infinity : svn_depth_empty);
119 // progDlg.SetSelectedList(dlg.m_selectedPathList);
120 // progDlg.SetItemCount(dlg.m_itemsCount);
121 // progDlg.SetBugTraqProvider(dlg.m_BugTraqProvider);
122 // progDlg.DoModal();
123 // CRegDWORD err = CRegDWORD(_T("Software\\TortoiseGit\\ErrorOccurred"), FALSE);
124 // err = (DWORD)progDlg.DidErrorsOccur();
125 // bFailed = progDlg.DidErrorsOccur();
126 // bRet = progDlg.DidErrorsOccur();
127 // CRegDWORD bFailRepeat = CRegDWORD(_T("Software\\TortoiseGit\\CommitReopen"), FALSE);
128 // if (DWORD(bFailRepeat)==0)
129 // bFailed = false; // do not repeat if the user chose not to in the settings.
132 return bRet;