コード例 #1
0
        ///	<summary>
        /// The constructor from commit and path
        ///	</summary>
        ///	<param name="base">The base configuration file</param>
        ///	<param name="commit">The commit that contains the object</param>
        ///	<param name="path">The path within the tree of the commit</param>
        /// <exception cref="FileNotFoundException">
        /// the path does not exist in the commit's tree.
        /// </exception>
        /// <exception cref="IOException">
        /// the tree and/or blob cannot be accessed.
        /// </exception>
        /// <exception cref="ConfigInvalidException">
        /// the blob is not a valid configuration format.
        /// </exception>
        public BlobBasedConfig(Config @base, Commit commit, string path)
            : base(@base)
        {
            if (commit == null)
            {
                throw new System.ArgumentNullException("commit");
            }

            ObjectId   treeId = commit.TreeId;
            Repository r      = commit.Repository;

            TreeWalk.TreeWalk tree = TreeWalk.TreeWalk.ForPath(r, path, treeId);
            if (tree == null)
            {
                throw new FileNotFoundException("Entry not found by path: " + path);
            }
            ObjectId     blobId = tree.getObjectId(0);
            ObjectLoader loader = tree.Repository.OpenBlob(blobId);

            if (loader == null)
            {
                throw new IOException("Blob not found: " + blobId + " for path: " + path);
            }

            fromText(RawParseUtils.decode(loader.Bytes));
        }
コード例 #2
0
        public virtual void testNoDF_NoGap()
        {
            DirCache tree0 = DirCache.read(db);
            DirCache tree1 = DirCache.read(db);

            {
                DirCacheBuilder b0 = tree0.builder();
                DirCacheBuilder b1 = tree1.builder();

                b0.add(makeEntry("a", REGULAR_FILE));
                b0.add(makeEntry("a.b", EXECUTABLE_FILE));
                b1.add(makeEntry("a/b", REGULAR_FILE));
                b0.add(makeEntry("a0b", SYMLINK));

                b0.finish();
                b1.finish();
                Assert.AreEqual(3, tree0.getEntryCount());
                Assert.AreEqual(1, tree1.getEntryCount());
            }

            GitSharp.Core.TreeWalk.TreeWalk tw = new GitSharp.Core.TreeWalk.TreeWalk(db);
            tw.reset();
            tw.addTree(new DirCacheIterator(tree0));
            tw.addTree(new DirCacheIterator(tree1));

            assertModes("a", REGULAR_FILE, MISSING, tw);
            assertModes("a.b", EXECUTABLE_FILE, MISSING, tw);
            assertModes("a", MISSING, TREE, tw);
            tw.enterSubtree();
            assertModes("a/b", MISSING, REGULAR_FILE, tw);
            assertModes("a0b", SYMLINK, MISSING, tw);
        }
コード例 #3
0
 private static void assertModes(string path, FileMode mode0, FileMode mode1, GitSharp.Core.TreeWalk.TreeWalk tw)
 {
     Assert.IsTrue(tw.next(), "has " + path);
     Assert.AreEqual(path, tw.getPathString());
     Assert.AreEqual(mode0, tw.getFileMode(0));
     Assert.AreEqual(mode1, tw.getFileMode(1));
 }
コード例 #4
0
		public virtual void testNoDF_NoGap()
		{
			DirCache tree0 = DirCache.read(db);
			DirCache tree1 = DirCache.read(db);
			{
				DirCacheBuilder b0 = tree0.builder();
				DirCacheBuilder b1 = tree1.builder();

				b0.add(makeEntry("a", REGULAR_FILE));
				b0.add(makeEntry("a.b", EXECUTABLE_FILE));
				b1.add(makeEntry("a/b", REGULAR_FILE));
				b0.add(makeEntry("a0b", SYMLINK));

				b0.finish();
				b1.finish();
				Assert.AreEqual(3, tree0.getEntryCount());
				Assert.AreEqual(1, tree1.getEntryCount());
			}

			GitSharp.Core.TreeWalk.TreeWalk tw = new GitSharp.Core.TreeWalk.TreeWalk(db);
			tw.reset();
			tw.addTree(new DirCacheIterator(tree0));
			tw.addTree(new DirCacheIterator(tree1));

			assertModes("a", REGULAR_FILE, MISSING, tw);
			assertModes("a.b", EXECUTABLE_FILE, MISSING, tw);
			assertModes("a", MISSING, TREE, tw);
			tw.enterSubtree();
			assertModes("a/b", MISSING, REGULAR_FILE, tw);
			assertModes("a0b", SYMLINK, MISSING, tw);
		}
コード例 #5
0
ファイル: NotTreeFilterTest.cs プロジェクト: dev218/GitSharp
 public void testWrap()
 {
     GitSharp.Core.TreeWalk.TreeWalk tw = new GitSharp.Core.TreeWalk.TreeWalk(db);
     TreeFilter a = TreeFilter.ALL;
     TreeFilter n = NotTreeFilter.create(a);
     Assert.IsNotNull(n);
     Assert.IsTrue(a.include(tw));
     Assert.IsFalse(n.include(tw));
 }
コード例 #6
0
ファイル: NotTreeFilterTest.cs プロジェクト: kkl713/GitSharp
        public void testWrap()
        {
            GitSharp.Core.TreeWalk.TreeWalk tw = new GitSharp.Core.TreeWalk.TreeWalk(db);
            TreeFilter a = TreeFilter.ALL;
            TreeFilter n = NotTreeFilter.create(a);

            Assert.IsNotNull(n);
            Assert.IsTrue(a.include(tw));
            Assert.IsFalse(n.include(tw));
        }
コード例 #7
0
 public void testANY_DIFF_IncludesSingleTreeCase()
 {
     GitSharp.Core.TreeWalk.TreeWalk tw = new GitSharp.Core.TreeWalk.TreeWalk(db);
     Assert.IsTrue(TreeFilter.ANY_DIFF.include(tw));
 }
コード例 #8
0
 public void testNotALL_IncludesNothing()
 {
     GitSharp.Core.TreeWalk.TreeWalk tw = new GitSharp.Core.TreeWalk.TreeWalk(db);
     Assert.IsFalse(TreeFilter.ALL.negate().include(tw));
 }
コード例 #9
0
 public void testALL_IncludesAnything()
 {
     GitSharp.Core.TreeWalk.TreeWalk tw = new GitSharp.Core.TreeWalk.TreeWalk(db);
     Assert.IsTrue(TreeFilter.ALL.include(tw));
 }
コード例 #10
0
 public override bool include(GitSharp.Core.TreeWalk.TreeWalk walker)
 {
     return(false);
 }
コード例 #11
0
ファイル: TreeFilterTest.cs プロジェクト: dev218/GitSharp
 public void testANY_DIFF_IncludesSingleTreeCase()
 {
     GitSharp.Core.TreeWalk.TreeWalk tw = new GitSharp.Core.TreeWalk.TreeWalk(db);
     Assert.IsTrue(TreeFilter.ANY_DIFF.include(tw));
 }
コード例 #12
0
ファイル: TreeFilterTest.cs プロジェクト: dev218/GitSharp
 public void testNotALL_IncludesNothing()
 {
     GitSharp.Core.TreeWalk.TreeWalk tw = new GitSharp.Core.TreeWalk.TreeWalk(db);
     Assert.IsFalse(TreeFilter.ALL.negate().include(tw));
 }
コード例 #13
0
ファイル: TreeFilterTest.cs プロジェクト: dev218/GitSharp
 public void testALL_IncludesAnything()
 {
     GitSharp.Core.TreeWalk.TreeWalk tw = new GitSharp.Core.TreeWalk.TreeWalk(db);
     Assert.IsTrue(TreeFilter.ALL.include(tw));
 }