Exemplo n.º 1
0
 /// <summary>
 /// Возвращает информацию о коммите
 /// </summary>
 /// <param name="refcode"></param>
 /// <param name="returnNullIfNotExisted"></param>
 /// <returns></returns>
 public GitCommitInfo GetCommitInfo(string refcode = null, bool returnNullIfNotExisted = true)
 {
     try{
         if (null != refcode && refcode.Length == 40)             //IS full hash
         {
             if (CommitInfoCache.ContainsKey(refcode))
             {
                 return(CommitInfoCache[refcode]);
             }
         }
         if (string.IsNullOrWhiteSpace(refcode))
         {
             refcode = "HEAD";
         }
         var data   = ExecuteCommand("show", "--format=\"%H|%ct|%cN|%cE|%aN|%aE|%s\"  --quiet \"" + refcode + "\"");
         var result = GitUtils.ParseGitCommitInfo(data);
         if (refcode.Length == 40)
         {
             CommitInfoCache[refcode] = result;
         }
         return(result);
     }
     catch (Exception ex) {
         if (ex.Message.Contains("unknown"))
         {
             if (returnNullIfNotExisted)
             {
                 return(null);
             }
         }
         throw;
     }
 }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            var result = GitUtils.ConvertToChar(FirstState).ToString() + GitUtils.ConvertToChar(SecondState).ToString() + ' ' +
                         '"' + FileName + '"';

            if (!string.IsNullOrWhiteSpace(NewFileName))
            {
                result += " -> \"" + NewFileName + "\"";
            }
            return(result);
        }
Exemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="rawrecord"></param>
        public FileRecord(string rawrecord)
        {
            var    rawState   = rawrecord.Substring(0, 2);
            string firstfile  = rawrecord.Substring(2).Trim();
            string secondfile = "";

            var filesplit = firstfile.IndexOf("->");

            if (filesplit != -1)
            {
                secondfile = firstfile.Substring(filesplit + 2).Trim();
                firstfile  = firstfile.Substring(0, filesplit).Trim();
            }

            FileName    = GitUtils.ConvertToValidFileName(firstfile);
            NewFileName = GitUtils.ConvertToValidFileName(secondfile);
            FirstState  = GitUtils.ConvertToValidState(rawState[0]);
            SecondState = GitUtils.ConvertToValidState(rawState[1]);
        }