Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "Archive..." to context menu of File tree tab / Archive filter by path #1868

Merged
merged 5 commits into from
May 26, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
116 changes: 77 additions & 39 deletions GitUI/CommandsDialogs/FormArchive.Designer.cs

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

40 changes: 38 additions & 2 deletions GitUI/CommandsDialogs/FormArchive.cs
@@ -1,5 +1,6 @@
using System;
using System.IO;
using System.Linq;
using System.Windows.Forms;
using GitCommands;
using GitUI.HelperDialogs;
Expand Down Expand Up @@ -29,6 +30,20 @@ public GitRevision SelectedRevision
}
}

public void SetPathArgument(string path)
{
if (path.IsNullOrEmpty())
{
checkBoxPathFilter.Checked = false;
textBoxPaths.Text = "";
}
else
{
checkBoxPathFilter.Checked = true;
textBoxPaths.Text = path;
}
}

private enum OutputFormat
{
Zip,
Expand All @@ -53,6 +68,7 @@ public FormArchive(GitUICommands aCommands)
private void FormArchive_Load(object sender, EventArgs e)
{
buttonArchiveRevision.Focus();
checkBoxPathFilter_CheckedChanged(null, null);
}

private void Save_Click(object sender, EventArgs e)
Expand All @@ -78,13 +94,28 @@ private void Save_Click(object sender, EventArgs e)
string format = GetSelectedOutputFormat() == OutputFormat.Zip ? "zip" : "tar";

FormProcess.ShowDialog(this,
string.Format("archive --format={0} {1} --output \"{2}\"",
format, revision, saveFileDialog.FileName));
string.Format("archive --format={0} {1} --output \"{2}\" {3}",
format, revision, saveFileDialog.FileName, GetPathArgumentFromGui()));
Close();
}
}
}

private string GetPathArgumentFromGui()
{
if (!checkBoxPathFilter.Checked)
{
return "";
}
else
{
// 1. get all lines from text box which are not empty
// 2. wrap lines with ""
// 3. join together with space as separator
return string.Join(" ", textBoxPaths.Lines.Where(a => !a.IsNullOrEmpty()).Select(a => string.Format("\"{0}\"", a)));
}
}

private OutputFormat GetSelectedOutputFormat()
{
return _NO_TRANSLATE_radioButtonFormatZip.Checked ? OutputFormat.Zip : OutputFormat.Tar;
Expand All @@ -100,5 +131,10 @@ private void btnChooseRevision_Click(object sender, EventArgs e)
}
}
}

private void checkBoxPathFilter_CheckedChanged(object sender, EventArgs e)
{
textBoxPaths.Enabled = checkBoxPathFilter.Checked;
}
}
}