GitSharp.ObjectDatabase.Find C# (CSharp) Метод

Find() публичный Метод

public Find ( string sha1Id ) : GitObject
sha1Id string
Результат GitObject
        public GitObject Find(string sha1Id)
        {
            if (sha1Id.Length != 40) throw new ArgumentException("Invalid SHA1 provided.", "sha1Id");

            string dirName = sha1Id.Substring(0, 2);
            string dirPath = Path.Combine(objectDir, dirName);

            if (!Directory.Exists(dirPath))
                throw new InvalidOperationException("Could not find SHA1 directory '" + dirName + "'.");

            string filename = sha1Id.Substring(2);
            string fullPath = Path.Combine(dirPath, filename);

            if (!File.Exists(fullPath))
                // should look in packs here?
                throw new InvalidOperationException("Could not find SHA1 file with path '" + fullPath + "'.");

            var uncompressedContent = zip.Decompress(fullPath);
            var stream = new GitObjectStream(uncompressedContent);

            return objectFactory.CreateFromContent(stream);
        }

Usage Example

        public void CanFindCommit()
        {
            var objectDb = new ObjectDatabase(@"testRepository\.git");
            var obj = objectDb.Find("2a38b629260b2ff9c32123be4c0da6302b7cdc11");

            Assert.That(obj, Is.TypeOf<Commit>());
        }