• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Core.Repository类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中GitSharp.Core.Repository的典型用法代码示例。如果您正苦于以下问题:C# Repository类的具体用法?C# Repository怎么用?C# Repository使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Repository类属于GitSharp.Core命名空间,在下文中一共展示了Repository类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: ObjectWriter

 ///	<summary>
 /// Construct an object writer for the specified repository.
 /// </summary>
 ///	<param name="repo"> </param>
 public ObjectWriter(Repository repo)
 {
     _r = repo;
     _buf = new byte[0x2000];
     _md = new MessageDigest();
     _def = new Deflater(_r.Config.getCore().getCompression());
 }
开发者ID:jagregory,项目名称:GitSharp,代码行数:11,代码来源:ObjectWriter.cs


示例2: IgnoreHandler

		public IgnoreHandler(Repository repo)
		{
			if (repo == null)
			{
				throw new ArgumentNullException("repo");
			}

			_repo = repo;

			try
			{
				string excludeFile = repo.Config.getCore().getExcludesFile();
				if (!string.IsNullOrEmpty(excludeFile))
				{
					ReadPatternsFromFile(Path.Combine(repo.WorkingDirectory.FullName, excludeFile), _excludePatterns);
				}
			}
			catch (Exception)
			{
				//optional
			}

			try
			{
				ReadPatternsFromFile(Path.Combine(repo.Directory.FullName, "info/exclude"), _excludePatterns);
			}
			catch (Exception)
			{
				// optional
			}
		}
开发者ID:dev218,项目名称:GitSharp,代码行数:31,代码来源:IgnoreHandler.cs


示例3: close

        public static void close(Repository db)
        {
			if (db == null)
				throw new System.ArgumentNullException ("db");
			
            Cache.unregisterRepository(FileKey.exact(db.Directory));
        }
开发者ID:dev218,项目名称:GitSharp,代码行数:7,代码来源:RepositoryCache.cs


示例4: Checked_cloned_local_dotGit_suffixed_repo

        public void Checked_cloned_local_dotGit_suffixed_repo()
        {
            //setup of .git directory
            var resource =
                new DirectoryInfo(PathUtil.Combine(Path.Combine(Environment.CurrentDirectory, "Resources"),
                                               "OneFileRepository"));
            var tempRepository =
                new DirectoryInfo(Path.Combine(trash.FullName, "OneFileRepository" + Path.GetRandomFileName() + Constants.DOT_GIT_EXT));
            CopyDirectory(resource.FullName, tempRepository.FullName);

            var repositoryPath = new DirectoryInfo(Path.Combine(tempRepository.FullName, Constants.DOT_GIT));
            Directory.Move(repositoryPath.FullName + "ted", repositoryPath.FullName);

            using (var repo = new Repository(repositoryPath.FullName))
            {
                Assert.IsTrue(Repository.IsValid(repo.Directory));
                Commit headCommit = repo.Head.CurrentCommit;
                Assert.AreEqual("f3ca78a01f1baa4eaddcc349c97dcab95a379981", headCommit.Hash);
            }

            string toPath = Path.Combine(trash.FullName, "to.git");

            using (var repo = Git.Clone(repositoryPath.FullName, toPath))
            {
                Assert.IsTrue(Repository.IsValid(repo.Directory));
                Commit headCommit = repo.Head.CurrentCommit;
                Assert.AreEqual("f3ca78a01f1baa4eaddcc349c97dcab95a379981", headCommit.Hash);
            }
        }
开发者ID:Flatlineato,项目名称:GitSharp,代码行数:29,代码来源:CloneTests.cs


示例5: ReflogReader

 ///	<summary>
 /// Parsed reflog entry.
 /// </summary>
 public ReflogReader(Repository db, string refName)
 {
     _logName = new FileInfo(
         Path.Combine(
             db.Directory.FullName,
                 Path.Combine("logs", refName)).Replace('/', Path.DirectorySeparatorChar));
 }
开发者ID:georgeck,项目名称:GitSharp,代码行数:10,代码来源:ReflogReader.cs


示例6: GitRepository

 public GitRepository(TextWriter stdout, string gitDir, IContainer container)
     : base(stdout)
 {
     _container = container;
     GitDir = gitDir;
     _repository = new Repository(new DirectoryInfo(gitDir));
 }
开发者ID:jsmale,项目名称:git-tfs,代码行数:7,代码来源:GitRepository.cs


示例7: RepositoryConfig

        public RepositoryConfig(Repository repo)
            : this(SystemReader.getInstance().openUserConfig(), new FileInfo(Path.Combine(repo.Directory.FullName, "config")))
        {
			if (repo == null)
				throw new System.ArgumentNullException ("repo");
            
        }
开发者ID:dev218,项目名称:GitSharp,代码行数:7,代码来源:RepositoryConfig.cs


示例8: PersonIdent

        private readonly int tzOffset; // offset in minutes to UTC

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Creates new PersonIdent from config info in repository, with current time.
        /// This new PersonIdent gets the info from the default committer as available
        /// from the configuration.
        /// </summary>
        /// <param name="repo"></param>
        public PersonIdent(Repository repo)
        {
            RepositoryConfig config = repo.Config;
            Name = config.getCommitterName();
            EmailAddress = config.getCommitterEmail();
            When = SystemReader.getInstance().getCurrentTime();
            tzOffset = SystemReader.getInstance().getTimezone(When);
        }
开发者ID:spraints,项目名称:GitSharp,代码行数:20,代码来源:PersonIdent.cs


示例9: WorkDirCheckout

 internal WorkDirCheckout(Repository repo, DirectoryInfo workDir, GitIndex oldIndex, GitIndex newIndex)
     : this()
 {
     _repo = repo;
     _root = workDir;
     _index = oldIndex;
     _merge = repo.MapTree(newIndex.writeTree());
 }
开发者ID:dev218,项目名称:GitSharp,代码行数:8,代码来源:WorkDirCheckout.cs


示例10: RefDatabase

 public RefDatabase(Repository repo)
 {
     Repository = repo;
     _gitDir = repo.Directory;
     _refsDir = PathUtil.CombineDirectoryPath(_gitDir, "refs");
     _packedRefsFile = PathUtil.CombineFilePath(_gitDir, "packed-refs");
     ClearCache();
 }
开发者ID:stschake,项目名称:GitSharp,代码行数:8,代码来源:RefDatabase.cs


示例11: AlternativeCallbackApiTest

 public void AlternativeCallbackApiTest()
 {
     using (var repo = new Repository(trash.FullName))
     {
         repo.Head.Reset(ResetBehavior.Mixed);
         writeTrashFile("untracked", "");
         writeTrashFile("added", "");
         repo.Index.Add("added");
         writeTrashFile("a/a1", "modified");
         repo.Index.AddContent("a/a1.txt", "staged");
         repo.Index.Remove("b/b2.txt");
         var status = repo.Status;
         Assert.AreEqual(1, status.Added.Count);
         Assert.AreEqual(1, status.Staged.Count);
         Assert.AreEqual(6, status.Missing.Count);
         Assert.AreEqual(1, status.Modified.Count);
         Assert.AreEqual(1, status.Removed.Count);
         Assert.AreEqual(1, status.Untracked.Count);
         var stati = new List<PathStatus>();
         var s = new RepositoryStatus(repo, new RepositoryStatusOptions
         {
             PerPathNotificationCallback = path_status =>
             {
                 stati.Add(path_status);
                 switch (path_status.WorkingPathStatus)
                 {
                     case WorkingPathStatus.Missing:
                         Assert.IsTrue(status.Missing.Contains(path_status.Path));
                         break;
                     case WorkingPathStatus.Modified:
                         Assert.IsTrue(status.Modified.Contains(path_status.Path));
                         break;
                     case WorkingPathStatus.Untracked:
                         Assert.IsTrue(status.Untracked.Contains(path_status.Path));
                         break;
                 }
                 switch (path_status.IndexPathStatus)
                 {
                     case IndexPathStatus.Added:
                         Assert.IsTrue(status.Added.Contains(path_status.Path));
                         break;
                     case IndexPathStatus.Removed:
                         Assert.IsTrue(status.Removed.Contains(path_status.Path));
                         break;
                     case IndexPathStatus.Staged:
                         Assert.IsTrue(status.Staged.Contains(path_status.Path));
                         break;
                 }
             }
         });
         var dict = stati.ToDictionary(p => p.Path);
         Assert.IsTrue(dict.ContainsKey("untracked"));
         Assert.IsTrue(dict.ContainsKey("added"));
         Assert.IsTrue(dict.ContainsKey("a/a1"));
         Assert.IsTrue(dict.ContainsKey("a/a1.txt"));
         Assert.IsTrue(dict.ContainsKey("b/b2.txt"));
     }
 }
开发者ID:spraints,项目名称:GitSharp,代码行数:58,代码来源:RepositoryStatusTests.cs


示例12: ReflogReader

 ///	<summary>
 /// Parsed reflog entry.
 /// </summary>
 public ReflogReader(Repository db, string refName)
 {
     if (db == null)
         throw new ArgumentNullException ("db");
     _logName = new FileInfo(
         Path.Combine(
             db.Directory.FullName,
                 Path.Combine("logs", refName)).Replace('/', Path.DirectorySeparatorChar));
 }
开发者ID:cocytus,项目名称:Git-Source-Control-Provider,代码行数:12,代码来源:ReflogReader.cs


示例13: BlobBasedConfig

 ///	<summary> * The constructor from object identifier
 ///	</summary>
 ///	<param name="base">the base configuration file </param>
 ///	<param name="r">the repository</param>
 /// <param name="objectid">the object identifier</param>
 /// <exception cref="IOException">
 /// the blob cannot be read from the repository. </exception>
 /// <exception cref="ConfigInvalidException">
 /// the blob is not a valid configuration format.
 /// </exception> 
 public BlobBasedConfig(Config @base, Repository r, ObjectId objectid)
     : base(@base)
 {
     ObjectLoader loader = r.OpenBlob(objectid);
     if (loader == null)
     {
         throw new IOException("Blob not found: " + objectid);
     }
     fromText(RawParseUtils.decode(loader.Bytes));
 }
开发者ID:jagregory,项目名称:GitSharp,代码行数:20,代码来源:BlobBasedConfig.cs


示例14: TracksAddedFiles

		public void TracksAddedFiles()
		{
			//setup of .git directory
			var resource =
				 new DirectoryInfo(Path.Combine(Path.Combine(Environment.CurrentDirectory, "Resources"),
														  "CorruptIndex"));
			var tempRepository =
				 new DirectoryInfo(Path.Combine(trash.FullName, "CorruptIndex" + Path.GetRandomFileName()));
			CopyDirectory(resource.FullName, tempRepository.FullName);

			var repositoryPath = new DirectoryInfo(Path.Combine(tempRepository.FullName, Constants.DOT_GIT));
			Directory.Move(repositoryPath.FullName + "ted", repositoryPath.FullName);

			using (var repository = new Repository(repositoryPath.FullName))
			{
				var status = repository.Status;

				Assert.IsTrue(status.AnyDifferences);
				Assert.AreEqual(1, status.Added.Count);
				Assert.IsTrue(status.Added.Contains("b.txt")); // the file already exists in the index (eg. has been previously git added)
				Assert.AreEqual(0, status.Staged.Count);
				Assert.AreEqual(0, status.Missing.Count);
				Assert.AreEqual(0, status.Modified.Count);
				Assert.AreEqual(0, status.Removed.Count);
				Assert.AreEqual(0, status.Untracked.Count);

				string filepath = Path.Combine(repository.WorkingDirectory, "c.txt");
				writeTrashFile(filepath, "c");
				repository.Index.Add(filepath);

				status.Update();

				Assert.IsTrue(status.AnyDifferences);
				Assert.AreEqual(2, status.Added.Count);
				Assert.IsTrue(status.Added.Contains("b.txt"));
				Assert.IsTrue(status.Added.Contains("c.txt"));
				Assert.AreEqual(0, status.Staged.Count);
				Assert.AreEqual(0, status.Missing.Count);
				Assert.AreEqual(0, status.Modified.Count);
				Assert.AreEqual(0, status.Removed.Count);
				Assert.AreEqual(0, status.Untracked.Count);

				repository.Commit("after that no added files should remain", Author.Anonymous);
				status.Update();

				Assert.AreEqual(0, status.Added.Count);
				Assert.AreEqual(0, status.Staged.Count);
				Assert.AreEqual(0, status.Missing.Count);
				Assert.AreEqual(0, status.Modified.Count);
				Assert.AreEqual(0, status.Removed.Count);
				Assert.AreEqual(0, status.Untracked.Count);
				Assert.AreEqual(0, status.Untracked.Count);
			}
		}
开发者ID:dev218,项目名称:GitSharp,代码行数:54,代码来源:RepositoryStatusTests.cs


示例15: GitRepository

        public GitRepository(TextWriter stdout, string gitDir, IContainer container, Globals globals)
            : base(stdout, container)
        {
            _container = container;
            _globals = globals;

            DirectoryInfo GitDirectoryInfo = GitHelpers.ResolveRepositoryLocation();

            GitDir = GitDirectoryInfo.ToString();
            _repository = new Repository(GitDirectoryInfo);
        }
开发者ID:dipeshc,项目名称:git-tfs,代码行数:11,代码来源:GitRepository.cs


示例16: RepositoryWalker

        public RepositoryWalker(CoreRepository repo)
        {
            if (repo == null)
            {
                throw new ArgumentNullException(nameof(repo));
            }

            _walker = new RevWalk(repo);
            _assistantWalker = new RevWalk(repo);
            _initCommit = new RevCommit(repo.Head.ObjectId);

        }
开发者ID:dotnet,项目名称:docfx,代码行数:12,代码来源:RepositoryWalker.cs


示例17: BlobBasedConfig

		///	<summary> * The constructor from object identifier
		///	</summary>
		///	<param name="base">the base configuration file </param>
		///	<param name="repo">the repository</param>
		/// <param name="objectid">the object identifier</param>
		/// <exception cref="IOException">
		/// the blob cannot be read from the repository. </exception>
		/// <exception cref="ConfigInvalidException">
		/// the blob is not a valid configuration format.
		/// </exception> 
		public BlobBasedConfig(Config @base, Repository repo, ObjectId objectid)
			: base(@base)
		{
			if (repo == null)
			{
				throw new System.ArgumentNullException("repo");
			}
			
			ObjectLoader loader = repo.OpenBlob(objectid);
			if (loader == null)
			{
				throw new IOException("Blob not found: " + objectid);
			}
			fromText(RawParseUtils.decode(loader.Bytes));
		}
开发者ID:dev218,项目名称:GitSharp,代码行数:25,代码来源:BlobBasedConfig.cs


示例18: Tag

 /**
  * Construct a Tag representing an existing with a known name referencing an known object.
  * This could be either a simple or annotated tag.
  *
  * @param db {@link Repository}
  * @param id target id.
  * @param refName tag name or null
  * @param raw data of an annotated tag.
  */
 public Tag(Repository db, ObjectId id, string refName, byte[] raw)
 {
     Repository = db;
     if (raw != null)
     {
         TagId = id;
         Id = ObjectId.FromString(raw, 7);
     }
     else
         Id = id;
     if (refName != null && refName.StartsWith("refs/tags/"))
         refName = refName.Substring(10);
     TagName = refName;
     this.raw = raw;
 }
开发者ID:spraints,项目名称:GitSharp,代码行数:24,代码来源:Tag.cs


示例19: CanReadFromMsysGitJapaneseRepository

        public void CanReadFromMsysGitJapaneseRepository()
        {
            //setup of .git directory
            var resource =
                 new DirectoryInfo(Path.Combine(Path.Combine(Environment.CurrentDirectory, "Resources"),
                                                          "JapaneseRepo"));
            var tempRepository =
                 new DirectoryInfo(Path.Combine(trash.FullName, "JapaneseRepo" + Path.GetRandomFileName()));
            CopyDirectory(resource.FullName, tempRepository.FullName);

            var repositoryPath = new DirectoryInfo(Path.Combine(tempRepository.FullName, Constants.DOT_GIT));
            Directory.Move(repositoryPath.FullName + "ted", repositoryPath.FullName);
            using (Repository repo = new Repository(tempRepository.FullName))
            {
                string commitHash = "24ed0e20ceff5e2cdf768345b6853213f840ff8f";

                var commit = new Commit(repo, commitHash);
                Assert.AreEqual("コミットのメッセージも日本語でやてみました。\n", commit.Message);
            }
        }
开发者ID:spraints,项目名称:GitSharp,代码行数:20,代码来源:EncodingTests.cs


示例20: CanAddAFileToAMSysGitIndexWhereAFileIsAlreadyWaitingToBeCommitted

        public void CanAddAFileToAMSysGitIndexWhereAFileIsAlreadyWaitingToBeCommitted()
        {
            //setup of .git directory
            var resource =
                new DirectoryInfo(Path.Combine(Path.Combine(Environment.CurrentDirectory, "Resources"),
                                               "CorruptIndex"));
            var tempRepository =
                new DirectoryInfo(Path.Combine(trash.FullName, "CorruptIndex" + Path.GetRandomFileName()));
            CopyDirectory(resource.FullName, tempRepository.FullName);

            var repositoryPath = new DirectoryInfo(Path.Combine(tempRepository.FullName, ".git"));
            Directory.Move(repositoryPath.FullName + "ted", repositoryPath.FullName);

            var repository = new Repository(repositoryPath);
            GitIndex index = repository.Index;

            Assert.IsNotNull(index);

            writeTrashFile(Path.Combine(repository.WorkingDirectory.FullName, "c.txt"), "c");

            var tree = new Tree(repository);

            index.add(repository.WorkingDirectory, new FileInfo(Path.Combine(repository.WorkingDirectory.FullName, "c.txt")));

            var diff = new IndexDiff(tree, index);
            diff.Diff();

            index.write();

            Assert.AreEqual(3, diff.Added.Count);
            Assert.IsTrue(diff.Added.Contains("a.txt"));
            Assert.IsTrue(diff.Added.Contains("b.txt"));
            Assert.IsTrue(diff.Added.Contains("c.txt"));
            Assert.AreEqual(0, diff.Changed.Count);
            Assert.AreEqual(0, diff.Modified.Count);
            Assert.AreEqual(0, diff.Removed.Count);
        }
开发者ID:mdekrey,项目名称:GitSharp,代码行数:37,代码来源:CanReadMsysgitIndexFixture.cs



注:本文中的GitSharp.Core.Repository类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Core.Tree类代码示例发布时间:2022-05-26
下一篇:
C# Core.ObjectWriter类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap