/// <summary> /// Loads the tag from the GitObjectReader /// </summary> /// <param name="input">A reader with inflated tag contents</param> public void Deserialize(GitObjectReader input) { string sha; if (Utility.IsValidSHA(input.GetString(20), out sha)) { // Tag contains a regular SHA so we can assume it's an IStorableObject Object = Repo.Storage.GetObject(sha); return; } else { input.Rewind(); // Skip header input.ReadToNull(); // Skip object keyword input.ReadWord(); TaggedObjectSHA = input.ReadLine().GetString().Trim(); if (!Utility.IsValidSHA(TaggedObjectSHA)) { throw new ParseException("Invalid sha from tag content"); } // Load object; a ParseException will be thrown for unknown types Object = Repo.Storage.GetObject(TaggedObjectSHA); // Skip type and tag input.ReadLine(); input.ReadLine(); // Tagger input.ReadWord(); string taggerLine = input.ReadLine().GetString(); TagDate = Utility.StripDate(taggerLine, out taggerLine); Tagger = Contributer.Parse(taggerLine); //Skip extra '\n' and read message input.ReadBytes(1); Message = input.ReadToEnd().GetString().TrimEnd(); } }
/// <summary> /// Loads the commit from the GitObjectReader /// </summary> /// <param name="input">A reader with inflated commit contents</param> public override void Deserialize(GitObjectReader input) { //Skip 'tree' at beginning of line and read tree sha input.ReadWord(); _treeSha = input.ReadLine().GetString(); // Check for 'parent' at beginning of line _parentShas = new List <string>(); string parentOrAuthor = input.ReadWord().GetString(); // TODO: Make recursive while (parentOrAuthor == "parent") { _parentShas.Add(input.GetString(40)); input.Position++; // Skip 'author' parentOrAuthor = input.ReadWord().GetString(); } // Author string authorLine = input.ReadLine().GetString(); AuthoredDate = Utility.StripDate(authorLine, out authorLine); Author = Contributer.Parse(authorLine); // Committer input.ReadWord(); string committerLine = input.ReadLine().GetString(); CommittedDate = Utility.StripDate(committerLine, out committerLine); Committer = Contributer.Parse(committerLine); //Skip extra '\n' input.Position++; Message = input.ReadToEnd().GetString().TrimEnd(); }