本文整理汇总了C#中GitSharp.Core.Repository类的典型用法代码示例。如果您正苦于以下问题:C# Repository类的具体用法?C# Repository怎么用?C# Repository使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Repository类属于GitSharp.Core命名空间,在下文中一共展示了Repository类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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());
}
示例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
}
}
示例3: close
public static void close(Repository db)
{
if (db == null)
throw new System.ArgumentNullException ("db");
Cache.unregisterRepository(FileKey.exact(db.Directory));
}
示例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);
}
}
示例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));
}
示例6: GitRepository
public GitRepository(TextWriter stdout, string gitDir, IContainer container)
: base(stdout)
{
_container = container;
GitDir = gitDir;
_repository = new Repository(new DirectoryInfo(gitDir));
}
示例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");
}
示例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);
}
示例9: WorkDirCheckout
internal WorkDirCheckout(Repository repo, DirectoryInfo workDir, GitIndex oldIndex, GitIndex newIndex)
: this()
{
_repo = repo;
_root = workDir;
_index = oldIndex;
_merge = repo.MapTree(newIndex.writeTree());
}
示例10: RefDatabase
public RefDatabase(Repository repo)
{
Repository = repo;
_gitDir = repo.Directory;
_refsDir = PathUtil.CombineDirectoryPath(_gitDir, "refs");
_packedRefsFile = PathUtil.CombineFilePath(_gitDir, "packed-refs");
ClearCache();
}
示例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"));
}
}
示例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));
}
示例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));
}
示例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);
}
}
示例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);
}