OSDN Git Service

Finish Submodule Add Command
authorFrank Li <lznuaa@gmail.com>
Fri, 20 Mar 2009 05:43:09 +0000 (13:43 +0800)
committerFrank Li <lznuaa@gmail.com>
Fri, 20 Mar 2009 05:43:09 +0000 (13:43 +0800)
Signed-off-by: Frank Li <lznuaa@gmail.com>
src/Resources/TortoiseProcENG.rc
src/TortoiseProc/Commands/SubmoduleCommand.cpp
src/TortoiseProc/SubmoduleAddDlg.cpp
src/TortoiseProc/SubmoduleAddDlg.h

index 7b743fd..f031a30 100644 (file)
Binary files a/src/Resources/TortoiseProcENG.rc and b/src/Resources/TortoiseProcENG.rc differ
index d129be3..c10c75c 100644 (file)
 #include "DirFileEnum.h"\r
 #include "ShellUpdater.h"\r
 #include "SubmoduleAddDlg.h"\r
+#include "ProgressDlg.h"\r
 \r
 bool SubmoduleAddCommand::Execute()\r
 {\r
        bool bRet = false;\r
        CSubmoduleAddDlg dlg;\r
-\r
+       dlg.m_strPath = cmdLinePath.GetDirectory().GetWinPathString();\r
+       dlg.m_strProject = g_Git.m_CurrentDir;\r
        if( dlg.DoModal() == IDOK )\r
-               bRet = TRUE;\r
+       {\r
+               CString cmd;\r
+               if(dlg.m_strPath.Left(g_Git.m_CurrentDir.GetLength()) == g_Git.m_CurrentDir)\r
+                       dlg.m_strPath = dlg.m_strPath.Right(dlg.m_strPath.GetLength()-g_Git.m_CurrentDir.GetLength()-1);\r
+               \r
+               CString branch;\r
+               if(dlg.m_bBranch)\r
+                       branch.Format(_T(" -b %s "), dlg.m_strBranch);\r
+\r
+               cmd.Format(_T("git.exe submodule add %s -- \"%s\"  \"%s\""),\r
+                                               branch,\r
+                                               dlg.m_strRepos, dlg.m_strPath);\r
 \r
+               CProgressDlg progress;\r
+               progress.m_GitCmd=cmd;\r
+               progress.DoModal();\r
+\r
+               bRet = TRUE;\r
+       }\r
        return bRet;\r
 }\r
 \r
index 0e35064..13aa51b 100644 (file)
@@ -5,6 +5,7 @@
 #include "resource.h"\r
 #include "SubmoduleAddDlg.h"\r
 #include "BrowseFolder.h"\r
+#include "MessageBox.h"\r
 \r
 // CSubmoduleAddDlg dialog\r
 \r
@@ -65,8 +66,10 @@ BOOL CSubmoduleAddDlg::OnInitDialog()
 \r
        m_Repository.LoadHistory(_T("Software\\TortoiseGit\\History\\SubModuleRepoURLS"), _T("url"));\r
        m_PathCtrl.LoadHistory(_T("Software\\TortoiseGit\\History\\SubModulePath"), _T("url"));\r
+       m_PathCtrl.SetWindowText(m_strPath);\r
        m_Repository.SetCurSel(0);\r
 \r
+       GetDlgItem(IDC_GROUP_SUBMODULE)->SetWindowText(CString(_T("Submodule of Project: "))+m_strProject);\r
        \r
        return TRUE;\r
 }\r
@@ -88,7 +91,7 @@ void CSubmoduleAddDlg::OnPathBrowse()
        browseFolder.m_style = BIF_EDITBOX | BIF_NEWDIALOGSTYLE | BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS;\r
        CString strDirectory;\r
        this->m_PathCtrl.GetWindowTextW(strDirectory);\r
-       if (browseFolder.Show(GetSafeHwnd(), strDirectory) == CBrowseFolder::OK) \r
+       if (browseFolder.Show(GetSafeHwnd(), strDirectory,g_Git.m_CurrentDir) == CBrowseFolder::OK) \r
        {\r
                this->m_PathCtrl.SetWindowTextW(strDirectory);\r
        }\r
@@ -107,7 +110,33 @@ void CSubmoduleAddDlg::OnBranchCheck()
 \r
 void CSubmoduleAddDlg::OnOK()\r
 {\r
+       this->UpdateData();\r
+       if(m_bBranch)\r
+       {\r
+               m_strBranch.Trim();\r
+               if(m_strBranch.IsEmpty())\r
+               {\r
+                       CMessageBox::Show(NULL,_T("Branch can't be empty"),_T("TortoiseGit"),MB_OK|MB_ICONERROR);\r
+                       return ;\r
+               }\r
+       }\r
        m_Repository.SaveHistory();\r
        m_PathCtrl.SaveHistory();\r
+\r
+       this->m_strPath=m_PathCtrl.GetString();\r
+       this->m_strRepos=m_Repository.GetString();\r
+\r
+       m_strPath.Trim();\r
+       m_strRepos.Trim();\r
+       if(m_strPath.IsEmpty())\r
+       {\r
+               CMessageBox::Show(NULL,_T("Path can't be empty"),_T("TortoiseGit"),MB_OK|MB_ICONERROR);\r
+                       return ;\r
+       }\r
+       if(m_strRepos.IsEmpty())\r
+       {\r
+               CMessageBox::Show(NULL,_T("Repository can't be empty"),_T("TortoiseGit"),MB_OK|MB_ICONERROR);\r
+                       return ;\r
+       }\r
        __super::OnOK();\r
 }
\ No newline at end of file
index 9ee0eb1..51cd7d7 100644 (file)
@@ -30,4 +30,7 @@ public:
        BOOL m_bBranch;\r
 public:\r
        CString m_strBranch;\r
+       CString m_strPath;\r
+       CString m_strRepos;\r
+       CString m_strProject;\r
 };\r