libgit2sharp

LibGit2Sharp get repository changes after pull

夙愿已清 提交于 2019-12-11 10:25:01
问题 How can i get the following information after a git-pull with libgit2sharp: Which files has been moved Which files has been created Which files has been deleted The git-pull request it self works perfectly: var result = repo.Network.Pull(new LibGit2Sharp.Signature("admin", "mail@......net", new DateTimeOffset(DateTime.Now)), options); I already looked at the result of the Pull -Method, but this seems not to contain the needed information. Thank you very much! 回答1: The MergeResult type exposes

using libgit2sharp to pull latest from a branch

别说谁变了你拦得住时间么 提交于 2019-12-11 04:24:57
问题 I am using libgit2sharp in a c# solution to switch to a branch and pull in the latest changes. Here is the code I am using: public void FetchAll() { using (var repo = new Repository(_LocalGitPath)) { foreach (Remote remote in repo.Network.Remotes) { FetchOptions options = new FetchOptions(); options.CredentialsProvider = new CredentialsHandler((url, usernameFromUrl, types) => new UsernamePasswordCredentials() { Username = _UserName, Password = _Password }); repo.Network.Fetch(remote, options)

libgit2sharp what is correct sha to supply to GitHub API merge pull-request?

青春壹個敷衍的年華 提交于 2019-12-11 03:46:31
问题 GitHub API requires merge pull-request to be submitted as PUT /repos/:owner/:repo/pulls/:number/merge with request body json { "commit_message": "blah", "sha": "{SHA that pull request head must match to allow merge}", } Following a commit, push, create PR, what libgit2sharp property supplies the correct sha ? For the current branch, it appears Branch.Tip.Sha is the correct value, but I'm receiving response error : { "message": "Head branch was modified. Review and try the merge again.",

How to connect to a GitHub repo using libgit2?

巧了我就是萌 提交于 2019-12-11 02:26:58
问题 I'm trying to connect to a repo: using(var Git = new Repository( Repository.Clone("https://github.com/wikimedia/mediawiki-core", "tmp") )){ foreach(var Commit in Git.Commits) { MessageBox.Show(Commit.Author.Name); } } It connects ok (as in, if I change the URL I get the expected exception), but no MessageBox es are shown - why? This should be simple. 回答1: Few things to consider regarding your question: One cannot "connect" to a remote repository and dynamically retrieve one file through the

LibGit2Sharp log remote

喜夏-厌秋 提交于 2019-12-11 00:31:24
问题 Is there any way to list commits that have been fetched, but not merged using LibGit2Sharp? For example I can run the following git command: C:\Users\Tom\SourceLog>git log origin commit f3beb4960b2f4bf5641d5b512b5b8c3081512a56 Author: Tom Hunter Date: Wed Jan 9 22:58:51 2013 +0000 Rollback change to icon Seemed to crash on windows xp for some reason.. commit d95f29a6cbfea9cb6009c3095a67d71f86d9e8bd Author: Tom Hunter Date: Mon Jan 7 21:34:36 2013 +0000 Updating Icon commit

LibGit2Sharp CheckoutPaths()

给你一囗甜甜゛ 提交于 2019-12-10 18:03:02
问题 I did a commit (49916.....) now i want to checkout one file of the commit into the working dir. The file is named NEW.txt. If i type Git checkout 49916 NEW.txt into Git Bash it creates the NEW.txt file with the content in my working dir. But my LibGit2Sharp command does not want to work. What am I doing wrong? var repo = new Repository(repopath); var checkoutPaths = new[] { "NEW.txt"}; repo.CheckoutPaths("49916", checkoutPaths); I read every article which i could find about the checkoutpaths

How do I get a previous version of a file with libgit2sharp

眉间皱痕 提交于 2019-12-10 14:49:08
问题 I'm trying to use libgit2sharp to get a previous version of a file. I would prefer the working directory to remain as is, at the very least restored to previous condition. My initial approach was to try to stash, checkout path on the file I want, save that to a string variable, then stash pop. Is there a way to stash pop? I can't find it easily. Here's the code I have so far: using (var repo = new Repository(DirectoryPath, null)) { var currentCommit = repo.Head.Tip.Sha; var commit = repo

How can I get the last commit for a folder using LibGit2Sharp?

夙愿已清 提交于 2019-12-10 14:33:26
问题 I've got a large number of projects all in a single repository. I want to determine the volatility of all of these projects, i.e., when there was last a commit that affected each project. I've got a list of all of the project paths, and I'm trying to find the last commit for each one. My code looks like this: public CommitInfo GetLastCommit(string path) { // resolve any \..\ and pathing weirdness path = Path.GetDirectoryName(Path.GetFullPath(path)); var relativePath = path.Substring

How to get file's contents on Git using LibGit2Sharp?

那年仲夏 提交于 2019-12-09 03:11:17
问题 I checked code in BlobFixture.cs and found some tests about reading file's contents like below. using (var repo = new Repository(BareTestRepoPath)) { var blob = repo.Lookup<Blob>("a8233120f6ad708f843d861ce2b7228ec4e3dec6"); var contentStream = blob.GetContentStream(); Assert.Equal(blob.Size, contentStream.Length); using (var tr = new StreamReader(contentStream, Encoding.UTF8)) { string content = tr.ReadToEnd(); Assert.Equal("hey there\n", content); } } But I cannot find a test that getting

Setting upstream on a repo

戏子无情 提交于 2019-12-08 03:56:38
问题 I am trying to pull the master branch from a remote using libgit2sharp . Sometimes I have to change the remote to a different url and pull from that remote . When I change the remote and try to pull I get this error: There is no tracking information for the current branch I know I have to do git branch --set-upstream-to=origin/master master to fix this issue using git, but I wonder how can I do the same with libgit2sharp ? 回答1: Given mybranch, a Branch instance, which is already configured to