Esempio n. 1
0
        internal string ZeroString()
        {
            switch (Type)
            {
            case GitUpdateReferenceType.Update:
                if (!GitReference.ValidName(Name, true))
                {
                    throw new InvalidOperationException($"'{Name}' is not a valid reference name");
                }
                if (Target != null && OldTarget != null)
                {
                    return($"update {Name}\0{Target}\0{OldTarget}\0");
                }
                else if (Target != null)
                {
                    return($"update {Name}\0{Target}\0\0");
                }
                else if (SymbolicTarget != null)
                {
                    if (!GitReference.ValidName(SymbolicTarget, true))
                    {
                        throw new InvalidOperationException($"'{SymbolicTarget}' is not a valid reference name");
                    }

                    return($"update {Name}\0{SymbolicTarget}\0");
                }
                else
                {
                    throw new InvalidOperationException();
                }

            default:
                throw new NotImplementedException($"Update reference type {Type} not implemented yet");
            }
        }
Esempio n. 2
0
        public ValueTask <GitReference?> GetAsync(string name)
        {
            if (!GitReference.ValidName(name, true))
            {
                throw new ArgumentOutOfRangeException(nameof(name), name, "Invalid Reference name");
            }

            return(GetUnsafeAsync(name));
        }
Esempio n. 3
0
        private protected void ParseLineToPeel(BucketBytes line, ref GitRefPeel?last, int idLength)
        {
            if (char.IsLetterOrDigit((char)line[0]) && line.Length > idLength + 1)
            {
                if (GitId.TryParse(line.Slice(0, idLength), out var oid))
                {
                    string name = line.Slice(idLength + 1).Trim().ToUTF8String();

                    if (GitReference.ValidName(name, false))
                    {
                        _peelRefs ![name] = last = new GitRefPeel {