本文整理汇总了C#中GitSharp.Repository类的典型用法代码示例。如果您正苦于以下问题:C# Repository类的具体用法?C# Repository怎么用?C# Repository使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Repository类属于GitSharp命名空间,在下文中一共展示了Repository类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Index
public ActionResult Index()
{
var dirs = Directory.GetDirectories(_settings.RepositoryRootPath);
var viewModel = new RepositoriesViewModel { List = new List<RepositoryViewModel>() };
foreach (string path in dirs)
{
var isValid = Repository.IsValid(path);
if (isValid)
{
using (var repo = new Repository(path))
{
viewModel.List.Add(new RepositoryViewModel
{
Name = repo.IsBare ? Path.GetFileName(repo.Directory.TrimGit())
: Path.GetFileName(path.TrimGit()),
Description = repo.Directory,
Path = repo.Directory,
CurrentCommit = repo.Branches["master"].CurrentCommit
});
}
}
}
return View(viewModel);
}
示例2: LoadBackupList
public void LoadBackupList(WorldSave save)
{
backupView.Items.Clear();
if (!Repository.IsValid(save.Path))
return;
using (Repository repo = new Repository(save.Path))
{
foreach (Commit commit in repo.CurrentBranch.CurrentCommit.Ancestors)
{
DateTime commitTime = commit.CommitDate.LocalDateTime;
ListViewItem item = new ListViewItem(commit.Message);
ListViewItem.ListViewSubItem dateItem = item.SubItems.Add(
commitTime.ToString());
dateItem.Name = "date";
ListViewItem.ListViewSubItem hashItem =
item.SubItems.Add(commit.ShortHash);
hashItem.Name = "shorthash";
ListViewItem.ListViewSubItem longHashItem =
item.SubItems.Add(commit.Hash);
longHashItem.Name = "hash";
backupView.Items.Add(item);
}
}
}
示例3: 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));
}
示例4: LoadRepository
private void LoadRepository()
{
if (!Directory.Exists(Path.Combine(ResourceLocation, ".git"))) {
Git.Init(ResourceLocation);
}
Repo = new Repository(ResourceLocation);
}
示例5: SetupContext
protected void SetupContext()
{
_nicolai = new Author("Nicolai Meltveit", "[email protected]");
_repositoryUrl = "git://github.com/flyrev/Smeedee_dummy.git";
_localDirectory = "C:\\ennå_nyare\\";
_repo = new Repository(_localDirectory);
}
示例6: 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());
}
示例7: ObjectWriter
public ObjectWriter(Repository repo)
{
this.r = repo;
buf = new byte[8192];
md = new MessageDigest(); // [henon] Sha1 hash digest generator
def = new Deflater(r.Config.Core.Compression);
}
示例8: Index
public Index(Repository repo)
{
_repo = repo;
//GitIndex.FilenameEncoding = repo.PreferredEncoding;
//if (_repo.PreferredEncoding != Encoding.UTF8 && _repo.PreferredEncoding != Encoding.Default)
// GitIndex.FilenameEncoding = Encoding.Default;
}
示例9: GetGitDetail
/// <summary>
/// TODO: only get GitDetail on Project level?
/// </summary>
/// <param name="path"></param>
/// <returns></returns>
public static GitDetail GetGitDetail(string path)
{
GitDetail detail = null;
if (string.IsNullOrEmpty(path)) return detail;
try
{
var repoPath = Repository.FindRepository(path);
if (string.IsNullOrEmpty(repoPath)) return detail;
var repo = new Repository(repoPath);
detail = new GitDetail();
// Convert to forward slash
detail.LocalWorkingDirectory = repo.WorkingDirectory.BackSlashToForwardSlash();
if (repo.Head == null) return detail;
var branch = repo.CurrentBranch;
detail.RemoteRepositoryUrl = repo.Config["remote.origin.url"];
detail.RemoteBranch = branch.Name;
// detail.Description = repo.Head.CurrentCommit.ShortHash;
detail.RelativePath = PathUtility.MakeRelativePath(Path.GetDirectoryName(repoPath), path);
}
catch (Exception)
{
// SWALLOW exception?
// Console.Error.WriteLine(e.Message);
}
return detail;
}
示例10: RefDatabase
public RefDatabase(Repository repo)
{
Repository = repo;
_gitDir = repo.Directory;
_refsDir = PathUtil.CombineDirectoryPath(_gitDir, "refs");
_packedRefsFile = PathUtil.CombineFilePath(_gitDir, "packed-refs");
ClearCache();
}
示例11: 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;
string username = config.getString("user", null, "name");
string email = config.getString("user", null, "email");
Name = username;
EmailAddress = email;
}
示例12: WorkDirCheckout
/// <summary>
/// Create a checkout class for checking out one tree, merging with the index
/// </summary>
/// <param name="repo"> </param>
/// <param name="root"> workdir </param>
/// <param name="index"> current index </param>
/// <param name="merge"> tree to check out </param>
public WorkDirCheckout(Repository repo, FileSystemInfo root, GitIndex index, Tree merge)
: this()
{
this._repo = repo;
this._root = root;
this._index = index;
this._merge = merge;
}
示例13: Versioning
public Versioning(Data data, GitSharp.Repository repo)
{
GitDetails = null;
InitializeComponent();
VersionControlData = data;
_repo = repo;
LoadFileStructure();
}
示例14: RepositoryNavigationViewModelBase
public RepositoryNavigationViewModelBase(Repository repository, RepositoryNavigationRequest request)
: this()
{
RepositoryName = request.RepositoryName;
Treeish = request.Treeish;
Path = request.Path;
RepositoryLocation = request.RepositoryLocation;
FillFromRepository(repository, request);
}
示例15: PersonIdent
public PersonIdent(Repository repo)
{
RepositoryConfig config = repo.Config;
string username = config.GetString("user", null, "name");
string email = config.GetString("user", null, "email");
this.Name = username;
this.EmailAddress = email;
this.when_time = DateTimeOffset.Now;
}