Beispiel #1
0
        public static CommitWire Convert(this Commit model)
        {
            if (model == Commit.Empty)
            {
                return new CommitWire()
                       {
                           Message = string.Empty
                       }
            }
            ;

            var wire = new CommitWire();

            // TreeId
            wire.TreeId = model.TreeId.Sha1.Convert();

            // Parents
            switch (model.Parents.Count)
            {
            case 0:
                break;

            case 1:
            {
                var sha1 = model.Parents[0].Sha1.Convert();
                wire.Parents.Add(sha1);
            }
            break;

            default:
            {
                foreach (var parent in model.Parents)
                {
                    var sha1 = parent.Sha1.Convert();
                    wire.Parents.Add(sha1);
                }
            }
            break;
            }

            // Author
            wire.Author = model.Author.Convert();

            // Committer
            wire.Committer = model.Committer.Convert();

            // Message
            wire.Message = model.Message;

            return(wire);
        }
Beispiel #2
0
        public static CommitWire Convert(this Commit model)
        {
            var wire = new CommitWire
            {
                // TreeId
                TreeId = model.TreeId.Convert()
            };

            // Parents
            switch (model.Parents.Count)
            {
            case 0:
                break;

            case 1:
            {
                var sha1 = model.Parents[0].Sha1.Convert();
                wire.Parents.Add(sha1);
            }
            break;

            default:
            {
                foreach (var parent in model.Parents)
                {
                    var sha1 = parent.Sha1.Convert();
                    wire.Parents.Add(sha1);
                }
            }
            break;
            }

            // Author
            wire.Author = model.Author.Convert();

            // Committer
            wire.Committer = model.Committer.Convert();

            // Message
            wire.Message = new StringValue {
                Value = model.Message
            };

            return(wire);
        }
Beispiel #3
0
 public static Commit Convert(this CommitWire wire)
 {
     if (wire == null)
     {
         return(default);