private void PushClick(object sender, EventArgs e)
{
if (PullFromUrl.Checked && string.IsNullOrEmpty(PushDestination.Text))
{
MessageBox.Show(_selectDestinationDirectory.Text);
return;
}
if (PullFromRemote.Checked && string.IsNullOrEmpty(Remotes.Text))
{
MessageBox.Show(_selectRemote.Text);
return;
}
if (TabControlTagBranch.SelectedTab == TagTab && string.IsNullOrEmpty(TagComboBox.Text) &&
!PushAllTags.Checked)
{
MessageBox.Show(_selectTag.Text);
return;
}
//Extra check if the branch is already known to the remote, give a warning when not.
//This is not possible when the remote is an URL, but this is ok since most users push to
//known remotes anyway.
if (TabControlTagBranch.SelectedTab == BranchTab && PullFromRemote.Checked)
{
//The current branch is not known by the remote (as far as we now since we are disconnected....)
if (!GitCommands.GitCommands.GetHeads(true, true).Exists(x => x.Remote == Remotes.Text && x.LocalName == RemoteBranch.Text))
//Ask if this is what the user wants
if (MessageBox.Show(_branchNewForRemote.Text, _pushCaption.Text, MessageBoxButtons.YesNo) ==
DialogResult.No)
return;
}
Repositories.RepositoryHistory.AddMostRecentRepository(PushDestination.Text);
var remote = "";
string destination;
if (PullFromUrl.Checked)
{
destination = PushDestination.Text;
}
else
{
if (GitCommands.GitCommands.Plink())
{
if (!File.Exists(Settings.Pageant))
MessageBox.Show(_cannotLoadPutty.Text, PuttyText);
else
GitCommands.GitCommands.StartPageantForRemote(Remotes.Text);
}
destination = Remotes.Text;
remote = Remotes.Text.Trim();
}
string pushCmd;
if (TabControlTagBranch.SelectedTab == BranchTab)
pushCmd = GitCommands.GitCommands.PushCmd(destination, Branch.Text, RemoteBranch.Text,
PushAllBranches.Checked, ForcePushBranches.Checked);
else
pushCmd = GitCommands.GitCommands.PushTagCmd(destination, TagComboBox.Text, PushAllTags.Checked,
ForcePushBranches.Checked);
var form = new FormProcess(pushCmd)
{
Remote = remote,
Text = string.Format(_pushToCaption.Text, destination)
};
form.ShowDialog();
if (!GitCommands.GitCommands.InTheMiddleOfConflictedMerge() &&
!GitCommands.GitCommands.InTheMiddleOfRebase() && !form.ErrorOccured())
Close();
}