} // End Function Commit public virtual string Commit(string path, string message) { string commitId = null; // No empty commit if (!HasChanges(path)) { return(commitId); } NGit.Api.Git repository = NGit.Api.Git.Open(path); NGit.PersonIdent author = new NGit.PersonIdent("FooBar2000", "*****@*****.**"); // Commit our changes after adding files to the stage NGit.Revwalk.RevCommit commit = repository.Commit() .SetMessage(message) .SetAuthor(author) .SetAll(true) // This automatically stages modified and deleted files .Call(); // Our new commit's hash NGit.ObjectId hash = commit.Id; commitId = hash.Name; CloseRepository(repository); return(commitId); } // End Function Commit
} // End Function Commit public virtual void CommitAndPush(string path) { // No empty commit if (!HasChanges(path)) { return; } NGit.Api.Git repository = NGit.Api.Git.Open(path); NGit.PersonIdent author = new NGit.PersonIdent("Lance Mcnearney", "*****@*****.**"); string message = "My commit message"; // Commit our changes after adding files to the stage NGit.Revwalk.RevCommit commit = repository.Commit() .SetMessage(message) .SetAuthor(author) .SetAll(true) // This automatically stages modified and deleted files .Call(); // Our new commit's hash NGit.ObjectId hash = commit.Id; // Push our changes back to the origin Sharpen.Iterable <NGit.Transport.PushResult> push = repository.Push().Call(); CloseRepository(repository); } // End Sub CommitAndPush
public override string Commit(string filePath, string changedContent, string commitComment) { using (var file = File.OpenWrite(Path.Combine(ClonedRepoFolder, filePath))) { var changes = new UTF8Encoding(true).GetBytes(changedContent); file.Write(changes, 0, changes.Length); } _git.Add().AddFilepattern(filePath).Call(); var commit = _git.Commit().SetMessage(commitComment).SetAuthor(Login, "*****@*****.**").Call(); _git.Push().Call(); BatchingProgressMonitor.ShutdownNow(); return(commit.Id.Name); }
public string Commit() { if (m_git == null) { throw new ArgumentException(); } try { var rev = m_git.Commit().SetMessage("Ganji autocommit").Call(); return(rev.Id.Name); } catch (Exception ex) { Trace.WriteLine(ex.Message); } return(""); }