dotGit.Refs.Tag.Deserialize C# (CSharp) Method

Deserialize() public method

Loads the tag from the GitObjectReader
public Deserialize ( GitObjectReader input ) : void
input GitObjectReader A reader with inflated tag contents
return void
        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();

            }
        }

Same methods

Tag::Deserialize ( ) : void

Usage Example

Example #1
0
        public IStorableObject ToGitObject(Repository repo, string sha)
        {
            using (GitObjectReader objectReader = new GitObjectReader(Content))
              {
            IStorableObject obj;
            switch (Type)
            {
              case ObjectType.Commit:
              obj = new Commit(repo, sha);
              break;
            case ObjectType.Tree:
              obj = new Tree(repo, sha);
              break;
            case ObjectType.Blob:
              obj = new Blob(repo, sha);
              break;
            case ObjectType.Tag:
              obj = new Tag(repo, sha);
              break;
            default:
              throw new NotImplementedException();
            }

            obj.Deserialize(objectReader);
            return obj;
              }
        }