Пример #1
0
bool SubmoduleUpdateCommand::Execute()
{
	CString bkpath;
	if (parser.HasKey(_T("bkpath")))
		bkpath = parser.GetVal(_T("bkpath"));
	else
	{
		bkpath = this->orgPathList[0].GetWinPathString();
		int start = bkpath.ReverseFind(_T('\\'));
		if (start >= 0)
			bkpath = bkpath.Left(start);
	}

	CString super = g_GitAdminDir.GetSuperProjectRoot(bkpath);
	if (super.IsEmpty())
	{
		CMessageBox::Show(NULL,IDS_ERR_NOTFOUND_SUPER_PRJECT,IDS_APPNAME,MB_OK|MB_ICONERROR);
		//change current project root to super project
		return false;
	}

	CSubmoduleUpdateDlg submoduleUpdateDlg;
	if (submoduleUpdateDlg.DoModal() != IDOK)
		return false;

	CProgressDlg progress;

	g_Git.m_CurrentDir = super;

	CString params;
	if (submoduleUpdateDlg.m_bInit)
		params = _T(" --init");
	if (submoduleUpdateDlg.m_bRecursive)
		params += _T(" --recursive");

	for (int i = 0; i < this->orgPathList.GetCount(); i++)
	{
		if (orgPathList[i].IsDirectory())
		{
			CString str;
			str.Format(_T("git.exe submodule update%s \"%s\""), params, ((CTGitPath &)orgPathList[i]).GetSubPath(CTGitPath(super)).GetGitPathString());
			progress.m_GitCmdList.push_back(str);
		}
	}

	progress.DoModal();

	return !progress.m_GitStatus;
}
Пример #2
0
bool SubmoduleUpdateCommand::Execute()
{
	CString bkpath;
	if (parser.HasKey(_T("bkpath")))
		bkpath = parser.GetVal(_T("bkpath"));
	else
	{
		bkpath = this->orgPathList[0].GetWinPathString();
		int start = bkpath.ReverseFind(_T('\\'));
		if (start >= 0)
			bkpath = bkpath.Left(start);
	}

	CString super = GitAdminDir::GetSuperProjectRoot(bkpath);
	if (super.IsEmpty())
	{
		CMessageBox::Show(NULL,IDS_ERR_NOTFOUND_SUPER_PRJECT,IDS_APPNAME,MB_OK|MB_ICONERROR);
		//change current project root to super project
		return false;
	}

	STRING_VECTOR pathFilterList;
	for (int i = 0; i < orgPathList.GetCount(); i++)
	{
		if (orgPathList[i].IsDirectory())
		{
			CString path = ((CTGitPath &)orgPathList[i]).GetSubPath(CTGitPath(super)).GetGitPathString();
			if (!path.IsEmpty())
				pathFilterList.push_back(path);
		}
	}

	CSubmoduleUpdateDlg submoduleUpdateDlg;
	submoduleUpdateDlg.m_PathFilterList = pathFilterList;
	if (parser.HasKey(_T("selectedpath")))
	{
		CString selectedPath = parser.GetVal(_T("selectedpath"));
		selectedPath.Replace(_T('\\'), _T('/'));
		submoduleUpdateDlg.m_PathList.push_back(selectedPath);
	}
	if (submoduleUpdateDlg.DoModal() != IDOK)
		return false;

	CProgressDlg progress;

	g_Git.m_CurrentDir = super;

	CString params;
	if (submoduleUpdateDlg.m_bInit)
		params = _T(" --init");
	if (submoduleUpdateDlg.m_bRecursive)
		params += _T(" --recursive");
	if (submoduleUpdateDlg.m_bForce)
		params += _T(" --force");
	if (submoduleUpdateDlg.m_bNoFetch)
		params += _T(" --no-fetch");
	if (submoduleUpdateDlg.m_bMerge)
		params += _T(" --merge");
	if (submoduleUpdateDlg.m_bRebase)
		params += _T(" --rebase");
	if (submoduleUpdateDlg.m_bRemote)
		params += _T(" --remote");

	for (size_t i = 0; i < submoduleUpdateDlg.m_PathList.size(); ++i)
	{
		CString str;
		str.Format(_T("git.exe submodule update%s -- \"%s\""), (LPCTSTR)params, (LPCTSTR)submoduleUpdateDlg.m_PathList[i]);
		progress.m_GitCmdList.push_back(str);
	}

	progress.DoModal();

	return !progress.m_GitStatus;
}