Skip to content

Commit

Permalink
#27, #29
Browse files Browse the repository at this point in the history
  • Loading branch information
sboulema committed Aug 30, 2016
1 parent a4cf575 commit 4ae8c7a
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 25 deletions.
30 changes: 15 additions & 15 deletions TGit/Commands/GitFlowMenuCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ private void InitCommand(object sender, EventArgs e)
* 2. Checkout develop branch (create if it doesn't exist, reset if it does)
* 3. Push develop branch
*/
ProcessHelper.StartProcessGui(
var process = ProcessHelper.StartProcessGui(
"cmd.exe",
$"/c cd \"{EnvHelper.SolutionDir}\" && " +
GitHelper.GetSshSetup() +
Expand All @@ -86,6 +86,8 @@ private void InitCommand(object sender, EventArgs e)
FormatCliCommand($"checkout -b {flowDialog.FlowOptions.DevelopBranch}", false)),
"Initializing GitFlow"
);
process.WaitForExit();

EnvHelper.GetFlowOptions();
EnvHelper.GetBranchName();
}
Expand Down Expand Up @@ -154,10 +156,9 @@ private void FinishFeatureCommand(object sender, EventArgs e)
GitHelper.GetSshSetup() +
FormatCliCommand($"checkout {EnvHelper.FlowOptions.DevelopBranch}") +
FormatCliCommand("pull") +
FormatCliCommand($"merge --no-ff {featureBranch}") +
FormatCliCommand($"push origin {EnvHelper.FlowOptions.DevelopBranch}", false),
FormatCliCommand($"merge --no-ff {featureBranch}", false),
$"Finishing feature {featureName}",
featureBranch, null, _options
featureBranch, null, _options, FormatCliCommand($"push origin {EnvHelper.FlowOptions.DevelopBranch}")
);
}

Expand Down Expand Up @@ -185,10 +186,9 @@ private void FinishFeatureGitHubCommand(object sender, EventArgs e)
GitHelper.GetSshSetup() +
FormatCliCommand("checkout master") +
FormatCliCommand("pull") +
FormatCliCommand($"merge --no-ff {featureBranch}") +
FormatCliCommand("push origin master", false),
FormatCliCommand($"merge --no-ff {featureBranch}", false),
$"Finishing feature {featureName}",
featureBranch, null, _options);
featureBranch, null, _options, FormatCliCommand("push origin master"));
}

private void StartReleaseCommand(object sender, EventArgs e)
Expand Down Expand Up @@ -244,12 +244,12 @@ private void FinishReleaseCommand(object sender, EventArgs e)
FormatCliCommand($"tag {releaseName}") +
FormatCliCommand($"checkout {EnvHelper.FlowOptions.DevelopBranch}") +
FormatCliCommand("pull") +
FormatCliCommand($"merge --no-ff {releaseBranch}") +
FormatCliCommand($"merge --no-ff {releaseBranch}", false),
$"Finishing release {releaseName}",
releaseBranch, null, _options,
FormatCliCommand($"push origin {EnvHelper.FlowOptions.DevelopBranch}") +
FormatCliCommand($"push origin {EnvHelper.FlowOptions.MasterBranch}") +
FormatCliCommand($"push origin {releaseName}", false),
$"Finishing release {releaseName}",
releaseBranch, null, _options
FormatCliCommand($"push origin {releaseName}")
);
}

Expand Down Expand Up @@ -306,12 +306,12 @@ private void FinishHotfixCommand(object sender, EventArgs e)
FormatCliCommand($"tag {hotfixName}") +
FormatCliCommand($"checkout {EnvHelper.FlowOptions.DevelopBranch}") +
FormatCliCommand("pull") +
FormatCliCommand($"merge --no-ff {hotfixBranch}") +
FormatCliCommand($"merge --no-ff {hotfixBranch}", false),
$"Finishing hotfix {hotfixName}",
hotfixBranch, null, _options,
FormatCliCommand($"push origin {EnvHelper.FlowOptions.DevelopBranch}") +
FormatCliCommand($"push origin {EnvHelper.FlowOptions.MasterBranch}") +
FormatCliCommand($"push origin {hotfixName}", false),
$"Finishing hotfix {hotfixName}",
hotfixBranch, null, _options
FormatCliCommand($"push origin {hotfixName}")
);
}
}
Expand Down
4 changes: 2 additions & 2 deletions TGit/Helpers/ProcessHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public static void Start(string application, string arguments)
}

public static Process StartProcessGui(string application, string args, string title, string branchName = "",
OutputBox outputBox = null, OptionPageGrid options = null)
OutputBox outputBox = null, OptionPageGrid options = null, string pushCommand = "")
{
var dialogResult = DialogResult.OK;
if (!StartProcessGit("config user.name") || !StartProcessGit("config user.email"))
Expand Down Expand Up @@ -175,7 +175,7 @@ public static Process StartProcessGui(string application, string args, string ti

if (outputBox == null)
{
_outputBox = new OutputBox(branchName, options);
_outputBox = new OutputBox(branchName, options, pushCommand);
_outputBox.Show();
}
else
Expand Down
5 changes: 5 additions & 0 deletions TGit/OptionsGeneral.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,10 @@ public string CommitMessage
[DisplayName(@"Delete remote branch")]
[Description("When finishing a feature delete the remote branch by default")]
public bool DeleteRemoteBranch { get; set; }

[Category("TGit")]
[DisplayName(@"Push changes")]
[Description("When finishing a feature push the changes to the remote by default")]
public bool PushChanges { get; set; }
}
}
21 changes: 17 additions & 4 deletions TGit/OutputBox.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 11 additions & 3 deletions TGit/OutputBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,23 @@ namespace SamirBoulema.TGit
public sealed partial class OutputBox : Form
{
private readonly string _branchName;
private readonly string _pushCommand;

public OutputBox(string branchName, OptionPageGrid options)
public OutputBox(string branchName, OptionPageGrid options, string pushCommand)
{
InitializeComponent();

_branchName = branchName;
_pushCommand = pushCommand;

richTextBox.TextChanged += textBox_TextChanged;

if (string.IsNullOrEmpty(branchName))
{
localBranchCheckBox.Visible = false;
remoteBranchCheckBox.Visible = false;
pushCheckBox.Visible = false;
richTextBox.Height += 30;
}
else
{
Expand All @@ -32,20 +37,23 @@ public OutputBox(string branchName, OptionPageGrid options)
{
localBranchCheckBox.Checked = options.DeleteLocalBranch;
remoteBranchCheckBox.Checked = options.DeleteRemoteBranch;
pushCheckBox.Checked = options.PushChanges;
}
}

private void okButton_Click(object sender, EventArgs e)
{
if (localBranchCheckBox.Checked || remoteBranchCheckBox.Checked)
if (localBranchCheckBox.Checked || remoteBranchCheckBox.Checked || pushCheckBox.Checked)
{
var process = ProcessHelper.StartProcessGui(
"cmd.exe",
$"/c cd \"{EnvHelper.SolutionDir}\" && " +
GitHelper.GetSshSetup() +
"echo. && " +
(pushCheckBox.Checked ? _pushCommand : "echo.") +
FormatCliCommand($"branch -d {_branchName}") +
(remoteBranchCheckBox.Checked ? FormatCliCommand($"push origin --delete {_branchName}", false) : "echo."),
"Deleting branches...", string.Empty, this
"Finishing...", string.Empty, this
);
process.WaitForExit();
okButton.Click += OkButton_Click_Close;
Expand Down
2 changes: 1 addition & 1 deletion TGit/source.extension.vsixmanifest
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
<Metadata>
<Identity Id="2eb0e74d-a27d-4c41-bca4-7e9e9befaa18" Version="3.8" Language="en-US" Publisher="Samir L. Boulema" />
<Identity Id="2eb0e74d-a27d-4c41-bca4-7e9e9befaa18" Version="3.9" Language="en-US" Publisher="Samir L. Boulema" />
<DisplayName>TGit</DisplayName>
<Description xml:space="preserve">Control TortoiseGit from within Visual Studio</Description>
<MoreInfo>https://github.com/sboulema/TGit</MoreInfo>
Expand Down

0 comments on commit 4ae8c7a

Please sign in to comment.