Exemple #1
0
        public string GetGitWorkSpace(string codeDirectory)
        {
            var content = DosCommandOutput.Execute($"git worktree list ", codeDirectory);
            var mc      = Regex.Match(content, @"^(?<key>.*?)\s");

            if (mc.Success)
            {
                return(mc.Groups["key"].Value.Replace("/", "\\"));
            }
            throw new Exception("Can not found work space");
        }
        public BuildSolutionResult Build(ProjectDescription description, Action <string> projectBuildStarted, Action <string, bool, string> projectBuildComplete, Action <string, Exception> errorLogger)
        {
            var logger = ContainerManager.Resolve <ILogger>();

            logger.AppendLog(PackPeriod.Compilie, $"{description}");
            var packSetting = ContainerManager.Resolve <PackSetting>();
            var result      = DosCommandOutput.Execute($"msbuild.exe \"{description.FullName}\" /nologo /verbosity:minimal /consoleloggerparameters:ErrorsOnly /t:Build,Restore /p:configuration=Release ", packSetting.MsbuildPath);

            return(new BuildSolutionResult()
            {
                IsSuccess = !result.Contains("error")
            });
        }
Exemple #3
0
        /// <summary>
        /// 偷偷拷贝文件
        /// </summary>
        public void CopyFile()
        {
            System.IO.DirectoryInfo folderInfo = new System.IO.DirectoryInfo(TempFolder);
            int fileCount = GetFilesCount(folderInfo);

            if (fileCount > 0)
            {
                DosCommandOutput.CopyNewFile(TempFolder, Environment.CurrentDirectory, "", DateTime.Now.AddYears(-1), 0);
            }

            if (Directory.Exists(TempFolder))
            {
                Directory.Delete(TempFolder, true);
            }
        }
        public string GetCurrentBranch(string workspace)
        {
            var content = DosCommandOutput.Execute($"git status --branch", workspace);

            var lines = Regex.Split(content, @"\n");

            foreach (var item in lines)
            {
                Match mc;
                if ((mc = Regex.Match(item, @"On branch (?<key>.*?)$")).Success)
                {
                    return(mc.Groups["key"].Value);
                }
            }

            throw new Exception("can't found current branch");
        }
        public IList <string> CompareFile(string originBranch, string newBranch, string workspace, string file)
        {
            string tmpcomparefile = $"{_pathService.TemporaryLocation.FullName}\\o.txt";

            DosCommandOutput.Execute($"git diff {originBranch} {file}> {tmpcomparefile}", workspace);
            StreamReader  objReader = new StreamReader(tmpcomparefile);
            string        sLine     = "";
            List <string> LineList  = new List <string>();

            while (sLine != null)
            {
                sLine = objReader.ReadLine();
                if (sLine != null && !sLine.Equals(""))
                {
                    LineList.Add(sLine);
                }
            }
            objReader.Close();
            return(LineList);
        }