コード例 #1
0
        internal void CopyAndCommit(List <CCElementVersion> ccHistory, DateTime since, DateTime until)
        {
            Git       git      = new Git(CreateGitInfo());
            ClearCase mainCC   = new ClearCase(CreateCCInfo("main"));
            ClearCase branchCC = new ClearCase(CreateCCInfo(this.BranchName));
            string    author   = "gicc <*****@*****.**>"; // todo : implement

            // main -> master
            mainCC.SetBranchCS(until);
            git.Checkout("master");

            List <string> mainFileList = mainCC.FindAllFilesInBranch(since, until);

            CopyFiles(mainFileList, VobPath, RepoPath);

            git.AddCommit("gicc", author);
            git.TagPull(); // todo : if changed

            // vob branch -> git branch
            branchCC.SetBranchCS(until);
            git.Checkout(BranchName);

            List <string> branchFileList = ccHistory
                                           .Where(elemVer => elemVer.CreatedDate > since && elemVer.CreatedDate <= until) // todo : pull 에서 날짜 제한 걸어주면 필요 없을 듯
                                           .Select(elemVer => elemVer.ElementName).ToList()
                                           .Distinct().ToList();

            CopyFiles(branchFileList, VobPath, RepoPath);

            git.AddCommit("gicc", author);
            git.TagPull(); // todo : if changed
        }
コード例 #2
0
        /// <summary>
        /// git repository 의 working branch 작업사항을 cc branch 에 push 합니다.
        /// </summary>
        public void PushWorkingBranch()
        {
            Git       git = new Git(CreateGitInfo());
            ClearCase cc  = new ClearCase(CreateCCInfo(this.BranchName));

            Dictionary <string, FileChangeType> committedFileDic = git.GetCommittedFilesAfterLastPP();

            // 1. validateion
            CheckCurrentBranchEqualsToWorkingBranch(git);
            git.CheckModifiedFileIsNotExist();
            cc.CheckCheckoutNotExists(committedFileDic.Keys.ToList());

            // 2. pull & merge
            if (cc.FindAllFilesInBranch(git.GetLastPPDate(), DateTime.Now).Count > 0)
            {
                string message = string.Empty;

                message += "There are new checked-in files in the VOB." + Environment.NewLine;
                // todo : checkout _gicctemp branch, reset --hard before pull
                message += "The checked-in file are automatically pulled to the " + BranchName + " branch," + Environment.NewLine;
                // todo : move to _gicctemp branch
                message += "and your commits are moved to the " + BranchName + "_gicctemp branch." + Environment.NewLine;
                message += "Please merge your commits into the " + BranchName + " branch and execute push again." + Environment.NewLine;

                throw new GiccException(message);
            }

            // 3. copy commited files after last pull/push tag & checkin
            CopyAndCheckin(committedFileDic,
                           "checked in with gicc" + Environment.NewLine
                           + "-git commit id : " + git.GetHeadCommitId());

            // 4. tag "push"
            git.TagPush();
        }
コード例 #3
0
        public List <string> ListCCFilesOnBranch(string branchName)
        {
            this.BranchName = branchName;
            ClearCase cc = new ClearCase(CreateCCInfo(branchName));

            return(cc.FindAllFilesInBranch());
        }
コード例 #4
0
        /// <summary>
        /// Pull changes from cc main branch and cc working branch.
        /// All changes after the last gicc_push or gicc_pull tagged commit will be pulled.
        /// </summary>
        public void Pull()
        {
            Git       git = new Git(CreateGitInfo());
            ClearCase cc  = new ClearCase(CreateCCInfo(this.BranchName));
            List <CCElementVersion> ccHistory = new List <CCElementVersion>();

            ////cc.CheckAllSymbolicLinksAreMounted(); // symbolic link 는 nuget 으로 관리
            cc.CheckCheckedoutFileNotExistsInCurrentView();
            git.CheckModifiedFileIsNotExist();

            cc.FindAllFilesInBranch(git.GetLastPPDate(), DateTime.Now)
            .ForEach(file => ccHistory.AddRange(cc.Lshistory(file)));

            // todo: GetCommitPoints 와 CopyAndCommit 로직이 이상하다.
            // branch 내의 파일로 GetCommitPoints 를 잡는데, CopyAndCommit 에서 메인 브랜치를 pull 할 때 이를 이용한다.
            // 이러면 main branch 를 제대로 pull 할 수 없다.
            throw new NotImplementedException();

            List <DateTime> commitPoints = GetCommitPoints(ccHistory);

            for (int i = 0; i < commitPoints.Count - 2; i++)
            {
                CopyAndCommit(ccHistory, commitPoints[i], commitPoints[i + 1]);
            }
        }