Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public GitCommitInfo[] GetTags()
        {
            var data  = ExecuteCommand("show-ref", "--tags", allowinvstate: true);
            var lines = data.SmartSplit(false, true, '\r', '\n');

            return(lines.Select(_ => {
                var pair = _.SmartSplit(false, true, ' ');
                var hash = pair[0];
                var name = pair[1].Substring(10);
                var commit = new GitCommitInfo {
                    Hash = hash, ShortHash = hash.Substring(0, 7), Name = name
                };
                return commit;
            }).ToArray());
        }
Example #2
0
        /// <summary>
        /// Парсит информацию о коммите
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public static GitCommitInfo ParseGitCommitInfo(string data)
        {
            var parts = data.Split('|');

            if (parts.Length < 7)
            {
                throw new Exception("cannot parse data as valid commit info '" + data + "'");
            }
            var result = new GitCommitInfo {
                Hash          = parts[0],
                ShortHash     = parts[0].Substring(0, 7),
                Commiter      = parts[2],
                CommiterEmail = parts[3],
                Author        = parts[4],
                AuthorEmail   = parts[5],

                GlobalRevisionTime = new DateTime(1970, 1, 1).AddSeconds(Convert.ToInt32(parts[1]))
            };

            if (!string.IsNullOrWhiteSpace(result.Hash))
            {
                result.Hash = result.Hash.Trim(new[] { '\r', '\n', ' ' });
            }
            var comment = parts[6];

            if (!String.IsNullOrWhiteSpace(comment))
            {
                comment = Encoding.UTF8.GetString(Encoding.GetEncoding(1251).GetBytes(comment));
                if (parts.Length > 7)
                {
                    for (var i = 7; i < parts.Length - 1; i++)
                    {
                        var p = Encoding.UTF8.GetString(Encoding.GetEncoding(1251).GetBytes(parts[i]));
                        comment += "|" + p;
                    }
                }
                result.Comment = comment;
            }

            result.LocalRevisionTime = result.GlobalRevisionTime.ToLocalTime();
            return(result);
        }
Example #3
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="other"></param>
		/// <returns></returns>
		protected bool Equals(GitCommitInfo other){
			return string.Equals(ShortHash, other.ShortHash);
		}
Example #4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="other"></param>
 /// <returns></returns>
 protected bool Equals(GitCommitInfo other)
 {
     return(string.Equals(ShortHash, other.ShortHash));
 }
Example #5
0
		/// <summary>
		/// 
		/// </summary>
		/// <returns></returns>
		public GitCommitInfo[] GetTags(){
			var data = ExecuteCommand("show-ref", "--tags",allowinvstate:true);
			var lines = data.SmartSplit(false, true, '\r', '\n');
			return lines.Select(_ =>{
				var pair = _.SmartSplit(false, true, ' ');
				var hash = pair[0];
				var name = pair[1].Substring(10);
				var commit = new GitCommitInfo{Hash = hash, ShortHash = hash.Substring(0, 7), Name = name};
				return commit;
			}).ToArray();
		}