/// <summary> /// Git 初始化 init Add Commit Remote /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void InitGit_toolStripMenuItem1_Click(object sender, EventArgs e) { string blogDir = Program.GetBlogDir().Replace("\\", "/"); string gitpwd = Program.GetConfig().Deployment.deploy; if (string.IsNullOrWhiteSpace(gitpwd) || File.Exists(gitpwd)) { MessageBox.Show("Git Bush 路径错误!"); return; } Common.GitHelper git = new Common.GitHelper(blogDir); git.Init(blogDir); return; git.Add(blogDir); git.Commit(blogDir, "commit" + DateTime.Now.ToString()); if (string.IsNullOrWhiteSpace(Program.GetConfig().Deployment.repository)) { MessageBox.Show("Git远程地址错误!"); return; } if (string.IsNullOrWhiteSpace(Program.GetConfig().Deployment.username) || string.IsNullOrWhiteSpace(Program.GetConfig().Deployment.password)) { MessageBox.Show("Git远程用户错误!"); return; } git.Remote(blogDir, Program.GetConfig().Deployment.repository, Program.GetConfig().Deployment.username, Program.GetConfig().Deployment.password); }
private void Git_Commit_ToolStripMenuItem_Click(object sender, EventArgs e) { string blogDir = Program.GetBlogDir().Replace("\\", "/"); string gitpwd = Program.GetConfig().Deployment.deploy; if (string.IsNullOrWhiteSpace(gitpwd) || !File.Exists(gitpwd)) { MessageBox.Show("Git Bush 路径错误!"); return; } Common.GitHelper git = new Common.GitHelper(blogDir); if (git.Add(blogDir) && git.Commit(blogDir, "commit" + DateTime.Now.ToString())) { MessageBox.Show("提交成功!"); } else { MessageBox.Show("提交失败!"); } }