当前位置: 首页>>代码示例>>C#>>正文


C# Repository.Open方法代码示例

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


在下文中一共展示了Repository.Open方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetFileContent

        public static string GetFileContent(this RevCommit commit, string path, Repository repository)
        {
            var treeWalk = new TreeWalk(repository) {Recursive = true, Filter = PathFilter.Create(path)};
            treeWalk.AddTree(commit.Tree);

            if (!treeWalk.Next())
            {
                return string.Empty;
            }

            var objectId = treeWalk.GetObjectId(0);
            var loader = repository.Open(objectId);

            using (var stream = loader.OpenStream())
            {
                using (var reader = new StreamReader(stream))
                {
                    return reader.ReadToEnd();
                }
            }
        }
开发者ID:FarReachJason,项目名称:Target-Process-Plugins,代码行数:21,代码来源:RevCommitExtensions.cs

示例2: GetRawText

		/// <exception cref="System.IO.IOException"></exception>
		private static RawText GetRawText(ObjectId id, Repository db)
		{
			if (id.Equals(ObjectId.ZeroId))
			{
				return new RawText(new byte[] {  });
			}
			return new RawText(db.Open(id, Constants.OBJ_BLOB).GetCachedBytes());
		}
开发者ID:stewartwhaley,项目名称:monodevelop,代码行数:9,代码来源:ResolveMerger.cs

示例3: Refresh

        public void Refresh()
        {
            this.index = null;
            this.commitTree = null;

            this.cache.Clear();
            this.changedFiles = null;
            this.repositoryGraph = null;
            this.dirCache = null;
            this.head = null;
            this.ignoreRules = null;
            this.remotes = null;
            this.configs = null;
            if (!string.IsNullOrEmpty(initFolder))
            {
                try
                {
                    this.repository = Open(new DirectoryInfo(initFolder));
                    if (this.repository != null)
                    {
                        dirCache = repository.ReadDirCache();
                        head = repository.Resolve(Constants.HEAD);

                        if (head == null)
                        {
                            this.commitTree = new Tree(repository);
                        }
                        else
                        {
                            var treeId = ObjectId.FromString(repository.Open(head).GetBytes(), 5);
                            this.commitTree = new Tree(repository, treeId, repository.Open(treeId).GetBytes());
                        }

                        if (repository.IsBare)
                            throw new NoWorkTreeException();

                        this.index = new GitIndex(repository);
                        this.index.Read();
                        this.index.RereadIfNecessary();

                        try
                        {
                            //load local .gitignore file
                            var ignoreFile = Path.Combine(this.initFolder,
                                Constants.GITIGNORE_FILENAME);
                            if (File.Exists(ignoreFile))
                            {
                                ignoreRules = File.ReadAllLines(ignoreFile)
                                                  .Where(line => !line.StartsWith("#") && line.Trim().Length > 0)
                                                  .Select(line => new IgnoreRule(line)).ToList();
                            }
                        }
                        catch (Exception ex)
                        {
                            Log.WriteLine("ReadIgnoreFile: {0}\r\n{1}", this.initFolder, ex.ToString());
                        }
                    }
                }
                catch (Exception ex)
                {
                    this.repository = null;
                    Log.WriteLine("Refresh: {0}\r\n{1}", this.initFolder, ex.ToString());
                }
            }
        }
开发者ID:b4shailen,项目名称:Git-Source-Control-Provider,代码行数:65,代码来源:GitFileStatusTracker.cs

示例4: CheckoutEntry

		/// <summary>
		/// Updates the file in the working tree with content and mode from an entry
		/// in the index.
		/// </summary>
		/// <remarks>
		/// Updates the file in the working tree with content and mode from an entry
		/// in the index. The new content is first written to a new temporary file in
		/// the same directory as the real file. Then that new file is renamed to the
		/// final filename.
		/// TODO: this method works directly on File IO, we may need another
		/// abstraction (like WorkingTreeIterator). This way we could tell e.g.
		/// Eclipse that Files in the workspace got changed
		/// </remarks>
		/// <param name="repo"></param>
		/// <param name="f">
		/// the file to be modified. The parent directory for this file
		/// has to exist already
		/// </param>
		/// <param name="entry">the entry containing new mode and content</param>
		/// <exception cref="System.IO.IOException">System.IO.IOException</exception>
		public static void CheckoutEntry(Repository repo, FilePath f, DirCacheEntry entry
			)
		{
			ObjectLoader ol = repo.Open(entry.GetObjectId());
			FilePath parentDir = f.GetParentFile();
			FilePath tmpFile = FilePath.CreateTempFile("._" + f.GetName(), null, parentDir);
			FileOutputStream channel = new FileOutputStream(tmpFile);
			try
			{
				ol.CopyTo(channel);
			}
			finally
			{
				channel.Close();
			}
			FS fs = repo.FileSystem;
			WorkingTreeOptions opt = repo.GetConfig().Get(WorkingTreeOptions.KEY);
			if (opt.IsFileMode() && fs.SupportsExecute())
			{
				if (FileMode.EXECUTABLE_FILE.Equals(entry.RawMode))
				{
					if (!fs.CanExecute(tmpFile))
					{
						fs.SetExecute(tmpFile, true);
					}
				}
				else
				{
					if (fs.CanExecute(tmpFile))
					{
						fs.SetExecute(tmpFile, false);
					}
				}
			}
			if (!tmpFile.RenameTo(f))
			{
				// tried to rename which failed. Let' delete the target file and try
				// again
				FileUtils.Delete(f);
				if (!tmpFile.RenameTo(f))
				{
					throw new IOException(MessageFormat.Format(JGitText.Get().couldNotWriteFile, tmpFile
						.GetPath(), f.GetPath()));
				}
			}
			entry.LastModified = f.LastModified();
			entry.SetLength((int)ol.GetSize());
		}
开发者ID:nickname100,项目名称:monodevelop,代码行数:68,代码来源:DirCacheCheckout.cs

示例5: Refresh

        public void Refresh()
        {
            this.cache.Clear();
            this.changedFiles = null;
            this.repositoryGraph = null;

            if (!string.IsNullOrEmpty(initFolder))
            {
                try
                {
                    this.repository = Git.Open(initFolder).GetRepository();

                    if (this.repository != null)
                    {
                        var id = repository.Resolve(Constants.HEAD);
                        //var commit = repository.MapCommit(id);
                        //this.commitTree = (commit != null ? commit.TreeEntry : new Tree(repository));
                        if (id == null)
                        {
                            this.commitTree = new Tree(repository);
                        }
                        else
                        {
                            var treeId = ObjectId.FromString(repository.Open(id).GetBytes(), 5);
                            this.commitTree = new Tree(repository, treeId, repository.Open(treeId).GetBytes());
                        }
                        this.index = repository.GetIndex();
                        this.index.RereadIfNecessary();

                        ignoreRules = File.ReadAllLines(Path.Combine(this.initFolder, Constants.GITIGNORE_FILENAME))
                                          .Where(line => !line.StartsWith("#") && line.Trim().Length > 0)
                                          .Select(line => new IgnoreRule(line)).ToList();
                    }
                }
                catch (Exception ex)
                {
                }
            }
        }
开发者ID:rpalaniappan,项目名称:Git-Source-Control-Provider,代码行数:39,代码来源:GitFileStatusTracker.cs

示例6: Refresh

        public void Refresh()
        {
            this.cache.Clear();
            this.changedFiles = null;

            if (!string.IsNullOrEmpty(initFolder))
            {
                try
                {
                    this.repository = Git.Open(initFolder).GetRepository();

                    if (this.repository != null)
                    {
                        var id = repository.Resolve(Constants.HEAD);
                        //var commit = repository.MapCommit(id);
                        //this.commitTree = (commit != null ? commit.TreeEntry : new Tree(repository));
                        if (id == null)
                        {
                            this.commitTree = new Tree(repository);
                        }
                        else
                        {
                            var treeId = ObjectId.FromString(repository.Open(id).GetBytes(), 5);
                            this.commitTree = new Tree(repository, treeId, repository.Open(treeId).GetBytes());
                        }
                        this.index = repository.GetIndex();
                        this.index.RereadIfNecessary();
                    }
                }
                catch (Exception ex)
                {
                }
            }
        }
开发者ID:elovelan,项目名称:Git-Source-Control-Provider,代码行数:34,代码来源:GitFileStatusTracker.cs


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