-
Notifications
You must be signed in to change notification settings - Fork 0
/
gitcommitop.cpp
101 lines (80 loc) · 2.93 KB
/
gitcommitop.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/* cbvcs Code::Blocks version control system plugin
Copyright (C) 2011 Dushara Jayasinghe.
cbvcs 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 3 of the License, or
(at your option) any later version.
cbvcs 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 cbvcs. If not, see <http://www.gnu.org/licenses/>.
*/
#include "gitcommitop.h"
#include "CommitMsgDialog.h"
#include <manager.h>
/***********************************************************************
* Method: GitCommitOp::execute
* Params: std::vector<VcsTreeItem *> &
* Returns: void
* Effects:
***********************************************************************/
void GitCommitOp::ExecuteImplementation(std::vector<VcsTreeItem*>& pathList) const
{
wxString path_string;
wxArrayString item_list;
std::vector<VcsTreeItem*>::const_iterator i;
for(i=pathList.begin(); i!= pathList.end(); i++)
{
AddCommitItem(item_list, *i);
}
if(item_list.size() == 0)
{
return;
}
wxString msg;
CommitMsgDialog dlg(Manager::Get()->GetAppWindow(), msg, item_list);
DumpOutput(item_list);
if(dlg.ShowModal() == wxID_OK)
{
wxArrayString outCapture, errCapture;
m_ShellUtils.execute(BuildCommitCmd(msg, item_list), outCapture, errCapture);
}
}
/***********************************************************************
* Method: GitCommitOp::BuildCommitCmd
* Params: const wxString &CommitMsg, const wxArrayString &ItemList
* Returns: wxString
* Effects:
***********************************************************************/
wxString GitCommitOp::BuildCommitCmd(const wxString &CommitMsg, const wxArrayString &ItemList) const
{
wxString Command = _("git commit -m " + CommitMsg);
for(unsigned int i=0; i<ItemList.Count(); i++)
{
Command += _(" ") + ItemList[i];
}
return Command;
}
/***********************************************************************
* Method: GitCommitOp::AddCommitItem
* Params: wxArrayString &ItemList, VcsTreeItem *FileItem
* Returns: void
* Effects:
***********************************************************************/
void
GitCommitOp::AddCommitItem(wxArrayString &ItemList, VcsTreeItem *FileItem) const
{
wxString relativeFilename = FileItem->GetRelativeName(m_VcsRootDir);
if(relativeFilename.length() == 0)
{
return;
}
if(FileItem->GetState() == Item_Added
|| FileItem->GetState() == Item_Modified
|| FileItem->GetState() == Item_Removed)
{
ItemList.Add(relativeFilename);
}
}