/// <summary> /// push commits to remote repository /// </summary> public static string PushScript(RepoDetails rd, ServerDetails sd) { string[] lines = new string[] { "cd /D " + rd.GetLocal(), // jump to folder "git push " + rd.GetName() + " master", // upload to repository "exit" }; FileUtil.WriteToFileUTF8("push.bat", lines); return(DefaultLogin("push", sd)); }
/// <summary> /// In its default mode, "git pull" is shorthand for "git fetch" followed by "git merge FETCH_HEAD" /// </summary> public static string PullScript(RepoDetails rd, ServerDetails sd) { string[] lines = new string[] { "cd /D " + rd.GetLocal(), "git pull " + rd.GetName() + " master", "exit" }; FileUtil.WriteToFileUTF8("pull.bat", lines); return(DefaultLogin("pull", sd)); }
/// <summary> /// refreshes the repo listbox /// </summary> private void RefreshList() { ListBoxRepos.Items.Clear(); ReposConfig cnf = ReposConfig.GetInstance(); Iterator <RepoDetails> itsd = cnf.GetRepoDetails(); while (itsd.HasNext()) { RepoDetails sd = itsd.GetNext(); ListBoxRepos.Items.Add(sd.GetName()); } }
/// <summary> /// new a script to create a new local repository /// </summary> public static string NewScript(RepoDetails rd) { string[] lines = new string[] { "cd /D " + rd.GetLocal(), // jump to folder "git init", // initialize the folder as a git repository "git remote add " + rd.GetName() + " " + rd.GetRemote(), // add a reference to the remote repository "exit" }; FileUtil.WriteToFileUTF8("new.bat", lines); return(DefaultExecution("new")); }
/// <summary> /// commit all changes and push to remote repository /// </summary> public static string CommitAndPushScript(RepoDetails rd, ServerDetails sd, string message) { string[] lines = new string[] { "cd /D " + rd.GetLocal(), // jump to folder "git add -A", // add all untracked, might make this optional later on "git commit -am \"" + message + "\"", // commit all changes with a message "git push " + rd.GetName() + " master", // upload to repository "exit" }; FileUtil.WriteToFileUTF8("commitpush.bat", lines); return(DefaultLogin("commitpush", sd)); }
/// <summary> /// Restores missing files. Synchronizes with the remote repository. /// </summary> public static string FetchScript(RepoDetails rd, ServerDetails sd) { string[] lines = new string[] { "cd /D " + rd.GetLocal(), // jump to folder "git fetch --prune " + rd.GetName(), // or origin "git reset --hard master", "git clean -f -d", "exit" }; FileUtil.WriteToFileUTF8("fetch.bat", lines); return(DefaultLogin("fetch", sd)); }
// ================================================================= // Global Events - Threaded // ================================================================= public void OnEvent(EventData ed) { switch (ed.EventCode) { // refreshes the repository list case EventCode.REFRESH_REPOS: ComboBoxAvailableRepos.Invoke(new MethodInvoker(delegate { ComboBoxAvailableRepos.Items.Clear(); var cnf = ReposConfig.GetInstance(); Iterator <RepoDetails> itsd = cnf.GetRepoDetails(); while (itsd.HasNext()) { RepoDetails sd = itsd.GetNext(); ComboBoxAvailableRepos.Items.Add(sd.GetName()); } })); break; case EventCode.REFRESH_CHANGES: // clear the change details. they're possibly invalid RichTextBoxDeltaDetails.Invoke(new MethodInvoker(delegate { RichTextBoxDeltaDetails.Text = ""; })); var repdetails = ReposConfig.GetInstance().GetSelected(); // get the repository from the manager // if the repo doesnt Repository rep = new Repository(repdetails); List <string> deltas = rep.RepoDelta(); // update repository ListBoxRepoChanges.Invoke(new MethodInvoker(delegate { ListBoxRepoChanges.Items.Clear(); Iterator <string> it = new Iterator <string>(deltas); while (it.HasNext()) { ListBoxRepoChanges.Items.Add(it.GetNext()); } })); break; default: break; } }
public string GetName() { return(details.GetName()); }