public void Pull() { var pullOptions = new PullOptions(); pullOptions.FetchOptions = new FetchOptions(); pullOptions.FetchOptions.CredentialsProvider = new LibGit2Sharp.Handlers.CredentialsHandler( (_url, _user, _cred) => new UsernamePasswordCredentials() { Username = this.username, Password = this.password }); repo.Network.Pull(new Signature(this.username, this.email, DateTimeOffset.UtcNow), pullOptions); }
public void Pull() { string dir = new DirectoryInfo(Path.Combine(TrueCraftDir, ".git")).FullName; if (!Directory.Exists(dir)) Clone(); using (var repo = new Repository(dir)) { PullOptions options = new PullOptions(); options.FetchOptions = new FetchOptions(); options.FetchOptions.OnProgress = ProgressChanged; repo.Network.Pull(new Signature("truecraft", "*****@*****.**", new DateTimeOffset(DateTime.Now)), options); } }
/// <summary> /// Get's the latest and greatest from remote /// </summary> /// <param name="gitUser"> /// The Git User. /// </param> /// <param name="gitPass"> /// The Git Pass. /// </param> /// <returns> /// A boolean that signals success /// </returns> public bool Fetch(string gitUser, string gitPass) { log.Debug("Fetch on remote repo"); if (File.Exists(ExternalGitPath)) { string GitOutput = ExecuteGitCommand("pull"); bool result = Regex.IsMatch(GitOutput, "\\bfatal\\b", RegexOptions.IgnoreCase); if (result == true) { return false; } } else { try { var signature = new Signature( "pass4win", "*****@*****.**", new DateTimeOffset(2011, 06, 16, 10, 58, 27, TimeSpan.FromHours(2))); var fetchOptions = new FetchOptions { CredentialsProvider = (url, user, cred) => new UsernamePasswordCredentials { Username = gitUser, Password = gitPass } }; var mergeOptions = new MergeOptions(); var pullOptions = new PullOptions { FetchOptions = fetchOptions, MergeOptions = mergeOptions }; this.gitRepo.Network.Pull(signature, pullOptions); } catch (Exception message) { log.Debug(message); return false; } } return true; }
public IResult Pull() { var settings = LoadSettings(); var error = settings.Validate(); if (error != null) { return(this.Error("Pull", $"Failed to load settings: {error}")); } try { using (var repo = new Repository(settings.LocalPath)) { LibGit2Sharp.PullOptions options = new LibGit2Sharp.PullOptions(); options.FetchOptions = new FetchOptions(); options.FetchOptions.CredentialsProvider = (_url, _user, _cred) => new UsernamePasswordCredentials { Username = settings.GitUser, Password = settings.GithubToken }; var signature = new LibGit2Sharp.Signature(new Identity(settings.GitUser, settings.GitUser), DateTime.Now); Commands.Pull(repo, signature, options); } } catch (System.Exception exception) { return(this.Error("Pull", $"Exception: {exception}")); } return(Result.Success()); }
//[Conditional("RELEASE")] public static void PullChanges() { var targetDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Scripts"); if (!Directory.Exists(targetDirectory)) { Directory.CreateDirectory(targetDirectory); } if (!Directory.Exists(Path.Combine(targetDirectory, ".git"))) { Repository.Clone("https://github.com/PMDShift/Scripts.git", targetDirectory); } else { using (var repo = new Repository(targetDirectory)) { // Credential information to fetch var options = new LibGit2Sharp.PullOptions(); var signature = new LibGit2Sharp.Signature(new Identity("Server", "*****@*****.**"), DateTimeOffset.Now); // Pull Commands.Pull(repo, signature, options); } } }
/** * Download the latest repo from GitHub.com */ public static void GitPull(LibGit2Sharp.Repository repo) { LibGit2Sharp.Signature author = new LibGit2Sharp.Signature("GitSheller", "@cornerpirate", DateTime.Now); LibGit2Sharp.PullOptions options = new LibGit2Sharp.PullOptions(); LibGit2Sharp.Signature committer = author; LibGit2Sharp.Commands.Pull(repo, author, options); }
public override async Task <Message> HandleMessage(Message msg) { MessageContext context = new MessageContext(msg, this); return(await Task.Run <Message>(() => { string sfWorkDir = Smart.Format(WorkingDir, context); string sfUser = Smart.Format(User, context); string sfPass = Smart.Format(Pass, context); string sfMergeUser = Smart.Format(MergeUser, context); string sfMergeEmail = Smart.Format(MergeEmail, context); Repository repo = new Repository(sfWorkDir); PullOptions options = new LibGit2Sharp.PullOptions(); if (!String.IsNullOrWhiteSpace(sfUser)) { options.FetchOptions = new FetchOptions(); options.FetchOptions.CredentialsProvider = new CredentialsHandler( (url, usernameFromUrl, types) => new UsernamePasswordCredentials() { Username = sfUser, Password = sfPass }); } var signature = new LibGit2Sharp.Signature(new Identity(sfMergeUser, sfMergeEmail), DateTimeOffset.Now); Commands.Pull(repo, signature, options); return msg; })); }
public void Pull(string branchName, CredentialsHandler GitCredentialsHandler) { LibGit2Sharp.PullOptions pullOptions = new LibGit2Sharp.PullOptions(); pullOptions.FetchOptions = new FetchOptions(); pullOptions.FetchOptions.CredentialsProvider = GitCredentialsHandler; LibGit2Sharp.Commands.Pull(repository, new LibGit2Sharp.Signature(UserName, Email, new DateTimeOffset(DateTime.Now)), pullOptions); }
/// <summary> /// 拉取最新代码 /// </summary> /// <returns></returns> public (bool, string, string, string) Fetch() { var lastMessage = string.Empty; var LastEmail = string.Empty; var LastTime = string.Empty; try { // Credential information to fetch LibGit2Sharp.PullOptions options = new LibGit2Sharp.PullOptions(); options.FetchOptions = new FetchOptions(); options.FetchOptions.CredentialsProvider = new CredentialsHandler( (url, usernameFromUrl, types) => new UsernamePasswordCredentials() { Username = GitLocalConfig.UserName, Password = GitLocalConfig.Password }); // User information to create a merge commit var signature = new LibGit2Sharp.Signature( new Identity(GitLocalConfig.LocalName, GitLocalConfig.LocalEmail), DateTimeOffset.Now); // Pull var re = Commands.Pull(_repository, signature, options); _logger?.Invoke($"【Git】git pull success >>> " + re.Status.ToString(), LogLevel.Info); var commitLog2 = GetBrandLastCommintInfo(); if (!string.IsNullOrEmpty(commitLog2.Item1)) { lastMessage = commitLog2.Item1; _logger?.Invoke($"【Git】Commit Message:\r\n" + commitLog2.Item1, LogLevel.Info); } if (!string.IsNullOrEmpty(commitLog2.Item2)) { LastEmail = commitLog2.Item2; _logger?.Invoke($"【Git】Commit Author:\r\n" + commitLog2.Item2, LogLevel.Info); } if (!string.IsNullOrEmpty(commitLog2.Item3)) { LastTime = commitLog2.Item3; _logger?.Invoke($"【Git】Commit Time:\r\n" + commitLog2.Item3, LogLevel.Info); } } catch (Exception e) { _logger?.Invoke($"【Git】git pull fail:{e.Message}", LogLevel.Error); return(false, null, null, null); } return(true, lastMessage, LastEmail, LastTime); }
public static async Task <(bool result, string message)> GitPullold() { using (var repo = new Repository(SettingManager.FolderData)) { // Credential information to fetch LibGit2Sharp.PullOptions options = new LibGit2Sharp.PullOptions(); options.FetchOptions = new FetchOptions(); //options.FetchOptions.CredentialsProvider = new CredentialsHandler( // (url, usernameFromUrl, types) => // new UsernamePasswordCredentials() // { // Username = SettingManager.UserName, // Password = SettingManager.Password // }); https: //raw.githubusercontent.com/pcm-dpc/COVID-19/master/dati-json/dpc-covid19-ita-regioni.json // User information to create a merge commit var signature = new LibGit2Sharp.Signature( new Identity("john.doe", "*****@*****.**"), DateTimeOffset.Now); // Pull return(await Task.Run(() => { try { var result = Commands.Pull(repo, signature, options); switch (result.Status) { case MergeStatus.UpToDate: MessageBox.Show(Properties.Resources.GitUpToDate); break; case MergeStatus.Conflicts: MessageBox.Show(Properties.Resources.GitConflict); break; case MergeStatus.FastForward: MessageBox.Show(Properties.Resources.GitFastForward); break; } return (result.Status == MergeStatus.FastForward, ""); } catch (Exception e) { return (false, e.Message); } })); } }
/// <summary> /// 更新脚本 /// </summary> public static void CheckLuaUpdate() { var gitPath = $"{Path}lua/"; var git = "https://gitee.com/chenxuuu/receiver-meow-lua.git"; if (!Directory.Exists(gitPath)) { Log.Warn("初始化Lua脚本", "没有检测到Lua脚本文件夹,即将下载最新脚本"); try { Log.Info("初始化Lua脚本", "正在获取脚本,请稍后"); Repository.Clone(git, gitPath); Log.Info("初始化Lua脚本", "更新完成!可以开始用了"); } catch (Exception ee) { Log.Error("初始化Lua脚本", $"更新脚本文件失败,错误信息:{ee.Message}\r\n如果始终失败,请手动执行下面的命令,初始化脚本后,再尝试运行:\r\n" + $"git clone {git} lua"); } } else { Log.Info("更新Lua脚本", "正在检查Lua脚本是否有更新。。。"); try { if (Repository.IsValid($"{Path}lua/")) { Log.Info("更新Lua脚本", "正在尝试更新脚本,请稍后"); var options = new LibGit2Sharp.PullOptions(); options.FetchOptions = new FetchOptions(); var signature = new LibGit2Sharp.Signature( new Identity("MERGE_USER_NAME", "MERGE_USER_EMAIL"), DateTimeOffset.Now); using var repo = new Repository(gitPath); Commands.Pull(repo, signature, options); Log.Info("更新Lua脚本", "更新操作执行完毕"); } else { Log.Warn("更新Lua脚本", "检测不到Git目录结构,如果你是自己写的脚本,请忽略该信息。如果你想恢复到默认脚本,请删除lua文件夹后重启软件"); } } catch (Exception e) { Log.Warn("更新Lua脚本", $"拉取最新脚本代码失败,错误原因:\n{e.Message}"); } } }
/// <summary> /// 更新脚本 /// </summary> /// <returns></returns> public static string UpdateScript() { string gitPath = Common.AppDirectory; if (!Repository.IsValid(gitPath)) { return("未检测到git仓库!工程不存在!"); //return;//工程不存在 } using (var repo = new Repository(gitPath)) { string lastCommit = repo.Commits.First().Sha;//当前提交的特征值 // Credential information to fetch LibGit2Sharp.PullOptions options = new LibGit2Sharp.PullOptions { FetchOptions = new FetchOptions() }; // User information to create a merge commit var signature = new LibGit2Sharp.Signature( new Identity("MERGE_USER_NAME", "MERGE_USER_EMAIL"), DateTimeOffset.Now); // Pull try { Commands.Pull(repo, signature, options); } catch { return("代码拉取失败,请检查网络!"); } string newCommit = repo.Commits.First().Sha;//pull后的特征值 if (lastCommit != newCommit) { Directory.Delete(gitPath + "lua\\", true); Tools.CopyDirectory(gitPath + "appdata\\lua\\", gitPath + "lua\\"); Tools.CopyDirectory(gitPath + "appdata\\xml\\", gitPath + "xml\\", false); return("更新完成!"); } else { return("当前已是最新版本"); } } }
private void Pull() { using (var repo = new Repository(repoPath)) { LibGit2Sharp.PullOptions options = new LibGit2Sharp.PullOptions(); options.FetchOptions = new FetchOptions(); options.FetchOptions.CredentialsProvider = new CredentialsHandler( (url, usernameFromUrl, types) => new UsernamePasswordCredentials() { Username = username, Password = password }); Commands.Pull(repo, new Signature(username, email, new DateTimeOffset(DateTime.Now)), options); } }
/// <inheritdoc /> public IObservable<MergeResult> Pull( IObserver<Tuple<string, int>> observer) { var signature = _repository.Config.BuildSignature(DateTimeOffset.Now); var isCancelled = false; var options = new PullOptions { FetchOptions = new FetchOptions { TagFetchMode = TagFetchMode.None, CredentialsProvider = _credentialsHandler, OnTransferProgress = progress => { // TODO: how should we signal for the "indexing objects" events var p = (50 * progress.ReceivedObjects) / progress.TotalObjects; observer.OnNext(Tuple.Create("", p)); return !isCancelled; } }, MergeOptions = new MergeOptions { OnCheckoutProgress = ProgressFactory.CreateHandler(observer, start:50, count:50) } }; return Observable.Create<MergeResult>(subj => { var sub = Observable.Start(() => { var result = _repository.Network.Pull(signature, options); observer.OnNext(Tuple.Create("pull completed", 100)); observer.OnCompleted(); return result; }, Scheduler.Default).Subscribe(subj); return new CompositeDisposable( sub, Disposable.Create(() => { isCancelled = true; observer.OnCompleted(); })); }); }
bool PullCore(CommonRepository repository) { using (var repo = new Repository(repository.Path)) { LibGit2Sharp.PullOptions options = new LibGit2Sharp.PullOptions(); options.FetchOptions = new FetchOptions(); options.FetchOptions.CredentialsProvider = new CredentialsHandler( (url, usernameFromUrl, types) => new UsernamePasswordCredentials() { Username = "******", Password = "******" }); var signature = new LibGit2Sharp.Signature(new Identity("DXVisualTestsBot", "*****@*****.**"), DateTimeOffset.Now); return(Commands.Pull(repo, signature, options).Status != MergeStatus.Conflicts); } }
public void Pull(string mergeUserName, string mergeUserEmail, string userName = "", string password = "") { LibGit2Sharp.PullOptions options = new LibGit2Sharp.PullOptions(); options.FetchOptions = new FetchOptions(); options.FetchOptions.CredentialsProvider = new CredentialsHandler( (url, usernameFromUrl, types) => new UsernamePasswordCredentials() { Username = userName, Password = password }); var signature = new LibGit2Sharp.Signature( new Identity(mergeUserName, mergeUserEmail), DateTimeOffset.Now); Commands.Pull(repository, signature, options); }
public virtual bool Update(string path) { bool result = false; using (var repo = new Repository(path)) { LibGit2Sharp.PullOptions options = new LibGit2Sharp.PullOptions(); options.FetchOptions = new FetchOptions(); Signature author = new Signature("triggr", "*****@*****.**", DateTime.Now); var mergeResult = Commands.Pull(repo, author, options); //conflict check requires result = mergeResult.Status != MergeStatus.UpToDate; } return(result); }
private void GitPull() { Trace("Pulling current branch"); using (var repo = new Repository(RepositoryPath())) { // Credential information to fetch var options = new LibGit2Sharp.PullOptions { FetchOptions = DefaultFetchOptions, MergeOptions = DefaultMergeOptions, }; // User information to create a merge commit var signature = new LibGit2Sharp.Signature(new Identity("service", "*****@*****.**"), DateTimeOffset.Now); // Pull Commands.Pull(repo, signature, options); } RunSpecialCommand(RepositoryPath(), "lfs pull"); }
/// <summary> /// Fetch changes from the configured upstream remote and branch into the branch pointed at by HEAD. /// </summary> /// <param name="repository">The repository.</param> /// <param name="merger">The signature to use for the merge.</param> /// <param name="options">The options for fetch and merging.</param> public static MergeResult Pull(Repository repository, Signature merger, PullOptions options = null) { Ensure.ArgumentNotNull(repository, "repository"); Branch currentBranch = repository.Head; if (!currentBranch.IsTracking) { throw new LibGit2SharpException("There is no tracking information for the current branch."); } if (currentBranch.RemoteName == null) { throw new LibGit2SharpException("No upstream remote for the current branch."); } return(Pull(repository, currentBranch.RemoteName, merger, options)); }
/// <summary> /// Pull changes from the configured upstream remote and branch into the branch pointed at by HEAD. /// </summary> /// <param name="merger">If the merge is a non-fast forward merge that generates a merge commit, the <see cref="Signature"/> of who made the merge.</param> /// <param name="options">Specifies optional parameters controlling merge behavior of pull; if null, the defaults are used.</param> public virtual MergeResult Pull(Signature merger, PullOptions options) { Ensure.ArgumentNotNull(merger, "merger"); Ensure.ArgumentNotNull(options, "options"); Branch currentBranch = repository.Head; if (!currentBranch.IsTracking) { throw new LibGit2SharpException("There is no tracking information for the current branch."); } if (currentBranch.Remote == null) { throw new LibGit2SharpException("No upstream remote for the current branch."); } Fetch(currentBranch.Remote, options.FetchOptions); return(repository.MergeFetchHeads(merger, options.MergeOptions)); }
//利用libgit2sharp进行git pull命令 public Boolean Libgit2_GitPull(string localpath, string username, string password, string emailaddress) { try { using (var repo = new Repository(localpath)) { LibGit2Sharp.PullOptions options = new LibGit2Sharp.PullOptions(); options.FetchOptions = new FetchOptions(); options.FetchOptions.CredentialsProvider = new CredentialsHandler( (url, usernameFromUrl, types) => new UsernamePasswordCredentials() { Username = username, Password = password }); repo.Network.Pull(new LibGit2Sharp.Signature(username, emailaddress, new DateTimeOffset(DateTime.Now)), options); return(true); } } catch (Exception e) { return(false); } }
private void pull_work(object sender, DoWorkEventArgs e) { LibGit2Sharp.PullOptions options = new LibGit2Sharp.PullOptions(); options.FetchOptions = new FetchOptions(); options.FetchOptions.CredentialsProvider = credential; BackgroundWorker worker = sender as BackgroundWorker; worker.ReportProgress(1); try { Console.WriteLine("Pulling from remote"); var result = Commands.Pull(repo, signature, options); Console.WriteLine(result.Status); } catch (Exception exception) { Console.WriteLine("Pull failed: " + exception.Message); e.Result = false; } Console.WriteLine("Pull success"); e.Result = true; }
public CheckAndUpdate(GitHubAccount account) { _account = account; var cres = new UsernamePasswordCredentials() { Username = _account.UserName, Password = _account.Token }; LibGit2Sharp.PullOptions options = new LibGit2Sharp.PullOptions(); options.FetchOptions = new FetchOptions(); options.FetchOptions.CredentialsProvider = new CredentialsHandler( (url, usernameFromUrl, types) => cres); options.MergeOptions = new MergeOptions(); _identity = new Identity(_account.UserName, _account.Email); _pushOptions = new PushOptions() { CredentialsProvider = new CredentialsHandler((url, usernameFromUrl, types) => cres), }; }
/// <summary> /// Fetch changes from the configured upstream remote and branch into the branch pointed at by HEAD. /// </summary> /// <param name="repository">The repository.</param> /// <param name="merger">The signature to use for the merge.</param> /// <param name="options">The options for fetch and merging.</param> public static MergeResult Pull(Repository repository, Signature merger, PullOptions options) { Ensure.ArgumentNotNull(repository, "repository"); Ensure.ArgumentNotNull(merger, "merger"); options = options ?? new PullOptions(); Branch currentBranch = repository.Head; if (!currentBranch.IsTracking) { throw new LibGit2SharpException("There is no tracking information for the current branch."); } if (currentBranch.RemoteName == null) { throw new LibGit2SharpException("No upstream remote for the current branch."); } Commands.Fetch(repository, currentBranch.RemoteName, new string[0], options.FetchOptions, null); return(repository.MergeFetchedRefs(merger, options.MergeOptions)); }
/// <summary> /// Fetch changes from the configured upstream remote and branch into the branch pointed at by HEAD. /// </summary> /// <param name="repository">The repository.</param> /// <param name="merger">The signature to use for the merge.</param> /// <param name="options">The options for fetch and merging.</param> public static MergeResult Pull(Repository repository, Signature merger, PullOptions options) { Ensure.ArgumentNotNull(repository, "repository"); Ensure.ArgumentNotNull(merger, "merger"); Ensure.ArgumentNotNull(options, "options"); options = options ?? new PullOptions(); Branch currentBranch = repository.Head; if (!currentBranch.IsTracking) { throw new LibGit2SharpException("There is no tracking information for the current branch."); } if (currentBranch.RemoteName == null) { throw new LibGit2SharpException("No upstream remote for the current branch."); } Commands.Fetch(repository, currentBranch.RemoteName, new string[0], options.FetchOptions, null); return repository.MergeFetchedRefs(merger, options.MergeOptions); }
private Repository GetRepository(RepositorySettings repoSettings) { CloneRepositoryIfNotExist(repoSettings); var repo = new Repository(repoSettings.Path); var branch = repo.Branches[repoSettings.Branch]; if (branch == null) { throw new Exception("Branch is not found " + repoSettings.Branch); } branch = Commands.Checkout(repo, branch); if (branch.TrackingDetails.BehindBy.HasValue && branch.TrackingDetails.BehindBy >= 0) { LibGit2Sharp.PullOptions options = new LibGit2Sharp.PullOptions() { FetchOptions = new FetchOptions() { CredentialsProvider = (url, usernameFromUrl, types) => GetCredentials(repoSettings.CredentialId) }, MergeOptions = new MergeOptions() { FailOnConflict = true } }; // User information to create a merge commit var signature = new LibGit2Sharp.Signature( new Identity("Mock", "Mock"), DateTimeOffset.Now); // Pull Commands.Pull(repo, signature, options); } return(repo); }
public static bool PullRepo(Settings.Objects.Details details, string repoFolder) { using (var repo = new Repository(repoFolder)) { // Credential information to fetch LibGit2Sharp.PullOptions options = new LibGit2Sharp.PullOptions(); options.FetchOptions = new FetchOptions(); options.FetchOptions.CredentialsProvider = getCredentialsHandler(details); // User information to create a merge commit var signature = new LibGit2Sharp.Signature( new Identity("MERGE_USER_NAME", "MERGE_USER_EMAIL"), DateTimeOffset.Now); // Pull MergeResult mergeResult = Commands.Pull(repo, signature, options); if (mergeResult.Status == MergeStatus.Conflicts || mergeResult.Status == MergeStatus.NonFastForward) { return(false); } } return(true); }
/// <summary> /// Git pull command /// </summary> /// <param name="repositoryPath"></param> /// <returns>CommandStatus</returns> private ECommandStatus Pull(string repositoryPath) { try { using (var repo = new Repository(repositoryPath)) { PullOptions options = new PullOptions(); options.FetchOptions = new FetchOptions(); options.FetchOptions.CredentialsProvider = new CredentialsHandler( (url, usernameFromUrl, types) => new UsernamePasswordCredentials() { Username = Config.Username, Password = Config.Password }); MergeResult result = repo.Network.Pull(new Signature(Config.Username, Config.Email, new DateTimeOffset(DateTime.Now)), options); return (ECommandStatus)result.Status; } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); return ECommandStatus.FAIL; } }
/// <summary> /// Get's the latest and greatest from remote /// </summary> /// <returns></returns> public bool GitFetch() { if (cfg["UseGitRemote"] == true && GITRepoOffline == false) { toolStripOffline.Visible = false; using (var repo = new LibGit2Sharp.Repository(cfg["PassDirectory"])) { LibGit2Sharp.Signature Signature = new LibGit2Sharp.Signature("pass4win", "*****@*****.**", new DateTimeOffset(2011, 06, 16, 10, 58, 27, TimeSpan.FromHours(2))); FetchOptions fetchOptions = new FetchOptions(); fetchOptions.CredentialsProvider = (_url, _user, _cred) => new UsernamePasswordCredentials { Username = cfg["GitUser"], Password = DecryptConfig(cfg["GitPass"], "pass4win") }; MergeOptions mergeOptions = new MergeOptions(); PullOptions pullOptions = new PullOptions(); pullOptions.FetchOptions = fetchOptions; pullOptions.MergeOptions = mergeOptions; try { MergeResult mergeResult = repo.Network.Pull(Signature, pullOptions); } catch { return false; } } } return true; }
/// <summary> /// Get's the latest and greatest from remote /// </summary> /// <returns></returns> public bool GitFetch() { if (Cfg["UseGitRemote"] == true && this.gitRepoOffline == false) { toolStripOffline.Visible = false; using (var repo = new Repository(Cfg["PassDirectory"])) { var signature = new Signature("pass4win", "*****@*****.**", new DateTimeOffset(2011, 06, 16, 10, 58, 27, TimeSpan.FromHours(2))); var fetchOptions = new FetchOptions { CredentialsProvider = (url, user, cred) => new UsernamePasswordCredentials { Username = Cfg["GitUser"], Password = DecryptConfig(Cfg["GitPass"], "pass4win") } }; var mergeOptions = new MergeOptions(); var pullOptions = new PullOptions { FetchOptions = fetchOptions, MergeOptions = mergeOptions }; try { repo.Network.Pull(signature, pullOptions); } catch (Exception) { return false; } } } return true; }
public virtual MergeResult Pull(Signature merger, PullOptions options) { return Commands.Pull(repository, merger, options); }
/// <summary> /// Pull changes from the configured upstream remote and branch into the branch pointed at by HEAD. /// </summary> /// <param name="merger">If the merge is a non-fast forward merge that generates a merge commit, the <see cref="Signature"/> of who made the merge.</param> /// <param name="options">Specifies optional parameters controlling merge behavior of pull; if null, the defaults are used.</param> public virtual MergeResult Pull(Signature merger, PullOptions options) { Ensure.ArgumentNotNull(merger, "merger"); Ensure.ArgumentNotNull(options, "options"); Branch currentBranch = repository.Head; if(!currentBranch.IsTracking) { throw new LibGit2SharpException("There is no tracking information for the current branch."); } if (currentBranch.Remote == null) { throw new LibGit2SharpException("No upstream remote for the current branch."); } Fetch(currentBranch.Remote, options.FetchOptions); return repository.MergeFetchHeads(merger, options.MergeOptions); }
public override void Pull() { try { var options = new PullOptions() { MergeOptions = new MergeOptions() { FastForwardStrategy = FastForwardStrategy.Default } }; var signature = GetSignature(); _repo.Network.Pull(signature, options); base.Pull(); RequeryUnsyncedCommits(); } catch (LibGit2SharpException ex) { throw new SourceControlException(SourceControlText.GitPullFailed, ex); } }
public Task Execute(ILogger logger, Event @event) { var key = GetKey(); if (_running.ContainsKey(key)) { logger?.LogWarning($"{key} 正在处理中,跳过本次任务"); return(Task.CompletedTask); } _running.TryAdd(key, this); try { var repoAddress = @event.project.http_url; if (string.IsNullOrEmpty(repoAddress)) { return(Task.CompletedTask); } ; CredentialsHandler credentialsProvider = null; if (!string.IsNullOrEmpty(Username)) { credentialsProvider = new CredentialsHandler( (url, usernameFromUrl, types) => new UsernamePasswordCredentials() { Username = Username, Password = Password }); } const int totalTicks = 0; var pbar = new ProgressBar(totalTicks, "", new ProgressBarOptions { ProgressCharacter = '─', ProgressBarOnBottom = true }); if (!Directory.Exists(LocalDirectory)) { logger?.LogDebug($"正在clone {repoAddress}到 {LocalDirectory}"); LibGit2Sharp.Repository.Clone(repoAddress, LocalDirectory, new CloneOptions() { BranchName = Branch, CredentialsProvider = credentialsProvider, OnTransferProgress = (t) => { pbar.MaxTicks = t.TotalObjects; pbar.Tick(t.ReceivedObjects, $"Key={key} LocalDirectory={LocalDirectory} RepoAddress={repoAddress}"); return(true); } }); } if (!LibGit2Sharp.Repository.IsValid(LocalDirectory)) { ResetGitRepo(logger); logger?.LogError($"{key} 的仓库目录 {LocalDirectory} 不是有效git仓库"); return(Task.CompletedTask); } using var repo = new LibGit2Sharp.Repository(LocalDirectory); var branch = repo.Branches[Branch]; if (branch == null) { ResetGitRepo(logger); logger?.LogError($"{key} 的仓库分支 {Branch} 不存在"); return(Task.CompletedTask); } logger?.LogDebug($"正在checkout {Branch}"); Commands.Checkout(repo, branch); logger?.LogDebug($"正在pull {Branch}"); pbar.Dispose(); pbar = new ProgressBar(totalTicks, $"pull {Branch}", new ProgressBarOptions { ProgressCharacter = '─', ProgressBarOnBottom = true }); var options = new LibGit2Sharp.PullOptions { FetchOptions = new FetchOptions() { OnTransferProgress = (t) => { pbar.MaxTicks = t.TotalObjects; pbar.Tick(t.ReceivedObjects, $"Key={key} LocalDirectory={LocalDirectory} RepoAddress={repoAddress}"); return(true); } } }; if (!string.IsNullOrEmpty(Username)) { options.FetchOptions.CredentialsProvider = credentialsProvider; } var signature = new LibGit2Sharp.Signature(new Identity(Username, Email), DateTimeOffset.Now); var mergeResult = Commands.Pull(repo, signature, options); if (mergeResult.Status != MergeStatus.UpToDate) { logger?.LogError($"仓库拉取失败,状态:{mergeResult.Status}"); return(Task.CompletedTask); } var script = Script; if (string.IsNullOrEmpty(script)) { script = $"dotnet publish -c Release -o {PublishDirectory}"; } var result = ExecuteCmd(script, LocalDirectory, logger); logger?.LogDebug($"发布命令执行{(result ? "成功" : "失败")}"); GC.KeepAlive(pbar); pbar.Dispose(); } finally { _running.Remove(key, out _); } return(Task.CompletedTask); }
/// <summary> /// Fetch changes from the configured upstream remote and branch into the branch pointed at by HEAD. /// </summary> /// <param name="repository">The repository.</param> /// <param name="remoteNameOrPath">The remote name or repository path.</param> /// <param name="merger">The signature to use for the merge.</param> /// <param name="options">The options for fetch and merging.</param> public static MergeResult Pull(Repository repository, string remoteNameOrPath, Signature merger, PullOptions options = null) { Ensure.ArgumentNotNull(repository, "repository"); Ensure.ArgumentNotNull(merger, "merger"); options = options ?? new PullOptions(); Commands.Fetch(repository, remoteNameOrPath, new string[0], options.FetchOptions, null); return(repository.MergeFetchedRefs(merger, options.MergeOptions)); }
public static void Timer1_Elapsed(object sender, System.Timers.ElapsedEventArgs e) //1s定时程序 { // 得到 hour minute second 如果等于某个值就开始执行某个程序。 int intHour = e.SignalTime.Hour; int intMinute = e.SignalTime.Minute; int intSecond = e.SignalTime.Second; count++; if (count >= luaWait)//每分钟执行脚本 { count = 0; LuaEnv.RunLua("", "envent/TimerMinute.lua"); } //检查升级 if (intSecond == 0 && intMinute == 0 && intHour == 3) { //检查是否开启了检查更新 if (XmlApi.xml_get("settings", "autoUpdate").ToUpper() != "TRUE") { return; } Common.CqApi.AddLoger(Sdk.Cqp.Enum.LogerLevel.Info, "lua脚本更新检查", "正在检查脚本更新"); string gitPath = Common.AppDirectory + "git/"; if (!Repository.IsValid(gitPath)) { Common.CqApi.AddLoger(Sdk.Cqp.Enum.LogerLevel.Error, "lua脚本更新检查", "未检测到git仓库!"); return;//工程不存在 } using (var repo = new Repository(gitPath)) { string lastCommit = repo.Commits.First().Sha;//当前提交的特征值 // Credential information to fetch LibGit2Sharp.PullOptions options = new LibGit2Sharp.PullOptions(); options.FetchOptions = new FetchOptions(); // User information to create a merge commit var signature = new LibGit2Sharp.Signature( new Identity("MERGE_USER_NAME", "MERGE_USER_EMAIL"), DateTimeOffset.Now); // Pull try { Commands.Pull(repo, signature, options); } catch { Common.CqApi.AddLoger(Sdk.Cqp.Enum.LogerLevel.Warning, "lua脚本更新检查", "代码拉取失败,请检查网络!"); return; } string newCommit = repo.Commits.First().Sha;//pull后的特征值 if (lastCommit != newCommit) { Common.CqApi.AddLoger(Sdk.Cqp.Enum.LogerLevel.Info, "lua脚本更新检查", "检测到更新内容,正在替换脚本\r\n" + "注意可能会出现消息报错,无视就好"); Directory.Delete(Common.AppDirectory + "lua", true); Tools.CopyDirectory(gitPath + "appdata/lua", Common.AppDirectory + "lua"); Common.CqApi.AddLoger(Sdk.Cqp.Enum.LogerLevel.Info, "lua脚本更新检查", "脚本更新完成!"); } else { Common.CqApi.AddLoger(Sdk.Cqp.Enum.LogerLevel.Info, "lua脚本更新检查", "没有检测到脚本更新"); } } } }
public async Task Connect(string name = "") { if (string.IsNullOrEmpty(name)) { name = Option.CurrentRemote; } Logger.LogInformation($"Connect to remote {name}."); if (Option.Remotes.TryGetValue(name, out var remote)) { Logger.LogInformation($"Detect remote {remote.Name} ({Enum.GetName(typeof(RemoteType), remote.Type)})."); switch (remote.Type) { case RemoteType.LocalFS: Remote = new FileSystemBlogService( new PhysicalFileProvider(remote.Uri).AsFileProvider()); break; case RemoteType.RemoteFS: { var client = HttpClientFactory.CreateClient(); client.BaseAddress = new Uri(remote.Uri); Remote = new FileSystemBlogService( new HttpFileProvider(client)); } break; case RemoteType.Api: { var client = HttpClientFactory.CreateClient(); client.BaseAddress = new Uri(remote.Uri); Remote = new ApiBlogService(client); } break; case RemoteType.Git: { FSBuilder builder = new FSBuilder(Environment.CurrentDirectory); Logger.LogInformation("Pull git repository."); try { using var repo = new Repository(GitTempFolder); // Credential information to fetch LibGit2Sharp.PullOptions options = new LibGit2Sharp.PullOptions(); // User information to create a merge commit var signature = new LibGit2Sharp.Signature( new Identity("AcBlog.Tools.Sdk", "tools.sdk@acblog"), DateTimeOffset.Now); // Pull LibGit2Sharp.Commands.Pull(repo, signature, options); } catch { builder.EnsureDirectoryEmpty(GitTempFolder); Repository.Clone(remote.Uri, GitTempFolder); } Remote = new FileSystemBlogService( new PhysicalFileProvider(Path.Join(Environment.CurrentDirectory, GitTempFolder)).AsFileProvider()); } break; } Remote.PostService.Context.Token = remote.Token; Option.CurrentRemote = name; await SaveOption(); } else { throw new Exception("No remote"); } }
private string PullLatest(string repository, string branch, string localGitPath) { using (var repo = new Repository(localGitPath)) { var targetBranch = repo.Branches[branch]; if (targetBranch != null) { if (!targetBranch.IsCurrentRepositoryHead) { repo.Checkout(branch); } try { var pullOptions = new PullOptions(); pullOptions.FetchOptions = new FetchOptions(); pullOptions.FetchOptions.CredentialsProvider = (_url, _user, _cred) => new DefaultCredentials(); repo.Network.Pull(GetSignature(), pullOptions); } catch (Exception) { var pullOptions = new PullOptions(); pullOptions.FetchOptions = new FetchOptions(); pullOptions.FetchOptions.CredentialsProvider = (_url, _user, _cred) => new UsernamePasswordCredentials() { Username = SourceUserName, Password = SourcePassword }; repo.Network.Pull(GetSignature(), pullOptions); } } } return localGitPath; }
/// <summary> /// Pull changes from remote to local, cross fingers no merge pls. /// </summary> /// <param name="credentials">User:Pass credentials</param> public void Pull(UsernamePasswordCredentials credentials) { using (var repo = new Repository(_LocalRepo)) { var pullOptions = new PullOptions { FetchOptions = new FetchOptions { CredentialsProvider = (url, username, types) => credentials } }; repo.Network.Pull(new Signature("Chuck Interface","--", new DateTimeOffset(DateTime.Now)), pullOptions); } }
private void setupOptions(string Username, SecureString SecurePassword, string RepoPath, string RepoUrl) { credentials = new SecureUsernamePasswordCredentials() { Username = Username, Password = SecurePassword }; var credentialsProvider = new CredentialsHandler((_url, _user, _cred) => new SecureUsernamePasswordCredentials { Username = Username, Password = SecurePassword }); fetchOptions = new FetchOptions() { CredentialsProvider = credentialsProvider }; pullOptions = new PullOptions() { FetchOptions = fetchOptions }; pushOptions = new PushOptions() { CredentialsProvider = credentialsProvider }; cloneOptions = new CloneOptions() { CredentialsProvider = credentialsProvider }; statusOptions = new StatusOptions() { ExcludeSubmodules = true, IncludeUnaltered = false }; }
protected virtual void HandleFixedVersioning_Branch(Dependency dependency, Repository otherRepository) { Log($"Dependency {dependency}: fixed versioning: checking current HEAD branch..."); var headBranch = otherRepository.Head.FriendlyName; if (headBranch != dependency.Branch) { Log($"Dependency {dependency}: fixed versioning: the current HEAD branch '{headBranch}' is different than the dependency branch '{dependency.Branch}' => checkout"); otherRepository.Checkout(dependency.Branch, new CheckoutOptions() { CheckoutModifiers = CheckoutModifiers.Force }); } // TODO: perform the pull only when necessary Log($"Dependency {dependency}: fixed versioning: pulling {dependency.Remote}"); var options = new PullOptions(); options.FetchOptions = new FetchOptions() { CredentialsProvider = new CredentialsHandler((url, usernameFromUrl, types) => dependency.GetCredentials(Authentication)) }; otherRepository.Network.Pull(new Signature(dependency.Username, dependency.Email, new DateTimeOffset(DateTime.Now)), options); }
public List <TaskTimeItem> GetRepositoryLog(Settings settings, string currentRepository, DateTime?date = null, CancellationToken cancellationToken = default) { if (string.IsNullOrEmpty(currentRepository) || !Directory.Exists(currentRepository)) { _log.Error("Папка с репо не сушествует."); return(new List <TaskTimeItem>()); } date = date.GetValueOrDefault(DateTime.Now.Date); var workTasks = new List <TaskTimeItem>(); foreach (var repoDirectory in Directory.GetDirectories(currentRepository, ".git", SearchOption.AllDirectories)) { if (cancellationToken.IsCancellationRequested) { return(new List <TaskTimeItem>()); } //var project = new DirectoryInfo(repoDirectory).Name; var repoRootDirectory = repoDirectory.Replace(".git", ""); var directoryInfo = new DirectoryInfo(repoRootDirectory); if (!directoryInfo.Exists) { continue; } var repo = new LibGit2Sharp.Repository(repoRootDirectory); if (settings.PullBeforeProcess) { try { // Credential information to fetch LibGit2Sharp.PullOptions options = new LibGit2Sharp.PullOptions(); options.FetchOptions = new FetchOptions(); // User information to create a merge commit var signature = new LibGit2Sharp.Signature(new Identity("MERGE_USER_NAME", "MERGE_USER_EMAIL"), DateTimeOffset.Now); // Pull Commands.Pull(repo, signature, options); } catch (Exception ex) { _log?.Trace($" - Не получается сделать pull для репозитория: {directoryInfo.Name} - {ex.Message}"); } } var allCommits = new List <Commit>(); var reflog = repo.Refs.Log(repo.Refs.Head); foreach (var reflogItem in reflog) { var dateMatch = date.Value.Date == reflogItem.Committer.When.Date; var committerEmail = reflogItem.Committer.Email; var userMatch = committerEmail.Equals(settings.MercurialAuthorEmail, StringComparison.CurrentCultureIgnoreCase) || committerEmail.Equals(settings.AlternativeEmail, StringComparison.CurrentCultureIgnoreCase); if (!dateMatch || !userMatch) { continue; } var commit = repo.Lookup <LibGit2Sharp.Commit>(reflogItem.To.Sha); if (commit != null && allCommits.All(f => f.Sha != commit.Sha)) { allCommits.Add(commit); } } foreach (Commit commit in allCommits) { if (cancellationToken.IsCancellationRequested) { return(new List <TaskTimeItem>()); } var userMatch = commit.Author.Email.Equals(settings.MercurialAuthorEmail, StringComparison.CurrentCultureIgnoreCase) || commit.Author.Email.Equals(settings.AlternativeEmail, StringComparison.CurrentCultureIgnoreCase); if (commit.Author.When.DateTime.Date != date.Value.Date || !userMatch) { continue; } var regex = new Regex("[a-zA-Z0-9]{1,5}-[0-9]{1,6}"); var branch = ListBranchesContainsCommit(repo, commit.Sha) .Select(f => f.FriendlyName) .FirstOrDefault(f => regex.IsMatch(f)); //.Where(f => f.Contains("-") && !f.Contains("/")).Distinct().FirstOrDefault(); if (branch == null) { continue; } branch = regex.Match(branch).Value; var commitMessage = commit.MessageShort; commitMessage = _technicalInfoSkipper.StripBranchPrefix(branch, commitMessage); if (_commitSkipper.IsNeedToSkip(branch, commitMessage)) { continue; } commitMessage = _technicalInfoSkipper.StripTechnicalInfo(commitMessage); var files = FilesToMerge(commit, repo); var task = new TaskTimeItem(branch, commitMessage, directoryInfo.Name, commit.Committer.When.DateTime, TimeSpan.Zero, 1, files.Length, //changeset.PathActions.Count, "", GetCommitType(branch)); workTasks.Add(task); _log?.Trace($" - Найден commit: {commit.Committer.When.DateTime} - {branch} - {commit.Author.Email} - {commitMessage}"); } } if (!workTasks.Any()) { return(new List <TaskTimeItem>()); } return(workTasks); }
public MergeResult UpdateCurrentBranch() { using (var repo = new Repository(_settings.Workspace)) { var pullOptions = new PullOptions() { FetchOptions = new FetchOptions() { CredentialsProvider = BuildCredentials } }; return repo.Network.Pull(new Signature(_settings.Username, _settings.Email, DateTimeOffset.Now), pullOptions); } }
//利用libgit2sharp进行git pull命令 public Boolean Libgit2_GitPull(string localpath,string username,string password,string emailaddress) { try { using (var repo = new Repository(localpath)) { LibGit2Sharp.PullOptions options = new LibGit2Sharp.PullOptions(); options.FetchOptions = new FetchOptions(); options.FetchOptions.CredentialsProvider = new CredentialsHandler( (url, usernameFromUrl, types) => new UsernamePasswordCredentials() { Username = username, Password = password }); repo.Network.Pull(new LibGit2Sharp.Signature(username, emailaddress, new DateTimeOffset(DateTime.Now)), options); return true; } } catch (Exception e) { return false; } }
public virtual MergeResult Pull(Signature merger, PullOptions options) { return(Commands.Pull(repository, merger, options)); }
public frmMain() { InitializeComponent(); // Checking for appsettings // Do we have a valid password store if (Properties.Settings.Default.PassDirectory == "firstrun") { if (folderBrowserDialog1.ShowDialog() == DialogResult.OK) { Properties.Settings.Default.PassDirectory = folderBrowserDialog1.SelectedPath; } else { MessageBox.Show("We need a place to store stuff. Restart the program and try again.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); System.Environment.Exit(1); } } // GPG exe location if (Properties.Settings.Default.GPGEXE == "firstrun") { if (openFileDialog1.ShowDialog() == DialogResult.OK) { Properties.Settings.Default.GPGEXE = openFileDialog1.FileName; } else { MessageBox.Show("We really need GPG2.exe. Restart the program and try again.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); System.Environment.Exit(1); } } //checking git status if (!Repository.IsValid(Properties.Settings.Default.PassDirectory)) { string value = ""; // Do we have a remote if (InputBox.Show("Enter the remote git repo or blank for no remote", "Remote Git (HTTPS):", ref value) == DialogResult.OK) { Properties.Settings.Default.GitRemote = value; if (Properties.Settings.Default.GitRemote != "") { // Get username and password value = ""; if (InputBox.Show("Username", "Remote Username:"******""; if (InputBox.Show("Password", "Remote Password:"******"Couldn't connect to remote git repository. Restart the program and try again.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); System.Environment.Exit(1); } // save encrypted version of user and pass for git Properties.Settings.Default.GitUser = EncryptConfig(GitUsername, "pass4win"); Properties.Settings.Default.GitPass = EncryptConfig(GitPassword, "pass4win"); } } } } // Checking if the remote is cloned succesfull if (!Repository.IsValid(Properties.Settings.Default.PassDirectory)) { // creating new Git Repository.Init(Properties.Settings.Default.PassDirectory); Properties.Settings.Default.GitUser = EncryptConfig("RandomGarbage", "pass4win"); Properties.Settings.Default.GitPass = EncryptConfig("RandomGarbage", "pass4win"); } } else { // so we have a repository let's load the user/pass if (Properties.Settings.Default.GitUser != "") { GitUsername = DecryptConfig(Properties.Settings.Default.GitUser, "pass4win"); GitPassword = DecryptConfig(Properties.Settings.Default.GitPass, "pass4win"); } else { string value = ""; if (InputBox.Show("Username", "Remote Username:"******""; if (InputBox.Show("Password", "Remote Password:"******"We really need a username. Restart the program and try again.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); System.Environment.Exit(1); } if (GitPassword == null) { MessageBox.Show("We really need a password. Restart the program and try again.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); System.Environment.Exit(1); } Properties.Settings.Default.GitUser = EncryptConfig(GitUsername, "pass4win"); Properties.Settings.Default.GitPass = EncryptConfig(GitPassword, "pass4win"); } // Check if we have the latest using (var repo = new Repository(Properties.Settings.Default.PassDirectory)) { Signature Signature = new Signature("pass4win","*****@*****.**", new DateTimeOffset(2011, 06, 16, 10, 58, 27, TimeSpan.FromHours(2))); FetchOptions fetchOptions = new FetchOptions(); fetchOptions.CredentialsProvider = (_url, _user, _cred) => new UsernamePasswordCredentials { Username = GitUsername, Password = GitPassword }; MergeOptions mergeOptions = new MergeOptions(); PullOptions pullOptions = new PullOptions(); pullOptions.FetchOptions = fetchOptions; pullOptions.MergeOptions = mergeOptions; MergeResult mergeResult = repo.Network.Pull(Signature, pullOptions); } } // Init GPG if needed string gpgfile = Properties.Settings.Default.PassDirectory; gpgfile += "\\.gpg-id"; // Check if we need to init the directory if (!File.Exists(gpgfile)) { Directory.CreateDirectory(Path.GetDirectoryName(gpgfile)); KeySelect newKeySelect = new KeySelect(); if (newKeySelect.ShowDialog() == DialogResult.OK) { using (StreamWriter w = new StreamWriter(gpgfile)) { w.Write(newKeySelect.gpgkey); } using (var repo = new Repository(Properties.Settings.Default.PassDirectory)) { repo.Stage(gpgfile); repo.Commit("gpgid added", new Signature("pass4win", "pass4win", System.DateTimeOffset.Now), new Signature("pass4win", "pass4win", System.DateTimeOffset.Now)); } } else { MessageBox.Show("Need key...... Restart the program and try again.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); System.Environment.Exit(1); } } // Setting the exe location for the GPG Dll GpgInterface.ExePath = Properties.Settings.Default.GPGEXE; // saving settings Properties.Settings.Default.Save(); // Setting up datagrid dt.Columns.Add("colPath", typeof(string)); dt.Columns.Add("colText", typeof(string)); ListDirectory(new DirectoryInfo(Properties.Settings.Default.PassDirectory), ""); dataPass.DataSource = dt.DefaultView; dataPass.Columns[0].Visible=false; }
public void Create() { //Pull du repo LibGit2Sharp.PullOptions options = new LibGit2Sharp.PullOptions(); options.FetchOptions = new FetchOptions(); options.FetchOptions.CredentialsProvider = new CredentialsHandler( (url, usernameFromUrl, types) => new UsernamePasswordCredentials() { Username = this.gitSettings.Username, Password = this.gitSettings.Password }); //Emplacement absolu du repo local var repo = new LibGit2Sharp.Repository(this.gitSettings.repoPath); //Realisation de l'action de Pull avec le repo designé avant, l'Username du programme, et l'adresse mail associée MergeResult mergeResult = Commands.Pull( repo, new Signature(gitSettings.Username, this.gitSettings.emailSignature, DateTimeOffset.Now), options ); //Traitement du resultat du Pull if (mergeResult.Status == MergeStatus.UpToDate) { //Si nous sommes à jour, on ne fait rien, et on le dit dans la console Console.WriteLine("On est deja a jour donc Commit a null"); } else { //Sinon, on récupère le commit que l'on vient de Pull //On le compare au commit précédent (son parent) //Et on print les noms des fichiers modifiés Console.WriteLine("Mise a jour"); Console.WriteLine("Commit : " + mergeResult.Commit.Id.ToString()); Tree commitTree = mergeResult.Commit.Tree; Tree parentCommitTree = mergeResult.Commit.Parents.Single().Tree; TreeChanges changes = repo.Diff.Compare <TreeChanges>(parentCommitTree, commitTree); //Console.WriteLine("{0} files changed :", changes.Count()); List <FileData> fDatas = new List <FileData>(); // var patch = repo.Diff.Compare <Patch>(parentCommitTree, commitTree); // createFileDatas(changes, fDatas, patch); /* Affichage des noms des fichiers modifiés * Console.WriteLine("Files :"); * foreach (String file in fileNames) * { * Console.WriteLine("{0}", file); * } */ var maTable = fDatas.ToMarkdownTable(); Console.WriteLine(maTable); // processMyTableToMdTable(maTable); } Console.ReadLine(); }