// throws ProcessException public void Process() { try { var srcRepo = git.OpenGitRepo(srcRepoPath); IGitRepo intermediateRepo; var intermediateRepoPath = config.GetIntermediateRepoPath(srcRepoPath); // 이미 리포지토리가 있으면 더 이상 진행하지 않는다 if (intermediateRepoPath == null) { intermediateRepoPath = MakeNewIntermidateRepoPath(srcRepoPath); // 클론 시켜서 임시저장소를 하나 더 만든다 git.Clone(srcRepoPath, intermediateRepoPath); config.AddIntermediateRepo(srcRepoPath, intermediateRepoPath); intermediateRepo = git.OpenGitRepo(intermediateRepoPath); } else { intermediateRepo = git.OpenGitRepo(intermediateRepoPath); } // var branchName = srcRepo.GetCurrentBranchName(); // branchName에 auto자가 붙으면 저장하지 않는다 if (branchName.StartsWith("autosave/")) { throw new ProcessException(ProcessException.Reason.WorkingOnAutosaveBranch); } intermediateRepo.FetchBranch("origin", branchName); var autosaveBranchName = $"autosave/{branchName}"; if (intermediateRepo.BranchExists(autosaveBranchName)) { // git checkout autosave/master intermediateRepo.CheckoutBranch(autosaveBranchName); } else { // git checkout -b autosave/master --track origin/master intermediateRepo.CheckoutNewBranchTrackingOriginBranch(autosaveBranchName, branchName); } intermediateRepo.MergeOurs("origin", branchName); intermediateRepo.ReadTree("origin", branchName); MirrorWorkingTree(srcRepo, srcRepoPath, intermediateRepoPath, true); intermediateRepo.AddAll(); // DateTime. intermediateRepo.Commit($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")} {branchName}"); intermediateRepo.PushBranch("origin", autosaveBranchName); } catch (GitCloneException) { throw new ProcessException(ProcessException.Reason.CloneFailed); } catch { throw new UnreachableCodeException(); } }