Skip to content

Commit 2c4db60

Browse files
authored
Merge pull request #1762 from Hosch250/Issue545
Allow pushing to an empty remote repo
2 parents f356cd6 + 31af1cd commit 2c4db60

File tree

10 files changed

+1365
-851
lines changed

10 files changed

+1365
-851
lines changed

RetailCoder.VBE/UI/RubberduckUI.Designer.cs

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

RetailCoder.VBE/UI/RubberduckUI.resx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="UTF-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<root>
33
<!--
44
Microsoft ResX Schema
@@ -59,7 +59,7 @@
5959
: using a System.ComponentModel.TypeConverter
6060
: and then encoded with base64 encoding.
6161
-->
62-
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="root">
62+
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
6363
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
6464
<xsd:element name="root" msdata:IsDataSet="true">
6565
<xsd:complexType>
@@ -1620,4 +1620,13 @@ All our stargazers, likers &amp; followers, for the warm fuzzies
16201620
<data name="GeneralSettings_ShowLogFolder" xml:space="preserve">
16211621
<value>Show Log Folder</value>
16221622
</data>
1623-
</root>
1623+
<data name="SourceControl_CreateNewRemoteRepoButtonToolTip" xml:space="preserve">
1624+
<value>Upload repository to GitHub</value>
1625+
</data>
1626+
<data name="SourceControl_CreateNewRemoteRepo_FailureTitle" xml:space="preserve">
1627+
<value>Create new remote repository.</value>
1628+
</data>
1629+
<data name="SourceControl_CreateNewRemoteRepo_NoOpenRepo" xml:space="preserve">
1630+
<value>No open repository to push to specified remote location.</value>
1631+
</data>
1632+
</root>

RetailCoder.VBE/UI/SourceControl/BranchesViewViewModel.cs

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -189,39 +189,41 @@ public string NewBranchName
189189

190190
public bool IsNotValidBranchName
191191
{
192-
get
193-
{
194-
// Rules taken from https://www.kernel.org/pub/software/scm/git/docs/git-check-ref-format.html
195-
var isValidName = !string.IsNullOrEmpty(NewBranchName) &&
196-
!LocalBranches.Contains(NewBranchName) &&
197-
!NewBranchName.Any(char.IsWhiteSpace) &&
198-
!NewBranchName.Contains("..") &&
199-
!NewBranchName.Contains("~") &&
200-
!NewBranchName.Contains("^") &&
201-
!NewBranchName.Contains(":") &&
202-
!NewBranchName.Contains("?") &&
203-
!NewBranchName.Contains("*") &&
204-
!NewBranchName.Contains("[") &&
205-
!NewBranchName.Contains("//") &&
206-
NewBranchName.FirstOrDefault() != '/' &&
207-
NewBranchName.LastOrDefault() != '/' &&
208-
NewBranchName.LastOrDefault() != '.' &&
209-
NewBranchName != "@" &&
210-
!NewBranchName.Contains("@{") &&
211-
!NewBranchName.Contains("\\");
212-
213-
if (!isValidName)
214-
{
215-
return true;
216-
}
217-
foreach (var section in NewBranchName.Split('/'))
218-
{
219-
isValidName = section.FirstOrDefault() != '.' &&
220-
!section.EndsWith(".lock");
221-
}
192+
get { return !IsValidBranchName(NewBranchName); }
193+
}
222194

223-
return !isValidName;
195+
public bool IsValidBranchName(string name)
196+
{
197+
// Rules taken from https://www.kernel.org/pub/software/scm/git/docs/git-check-ref-format.html
198+
var isValidName = !string.IsNullOrEmpty(name) &&
199+
!LocalBranches.Contains(name) &&
200+
!name.Any(char.IsWhiteSpace) &&
201+
!name.Contains("..") &&
202+
!name.Contains("~") &&
203+
!name.Contains("^") &&
204+
!name.Contains(":") &&
205+
!name.Contains("?") &&
206+
!name.Contains("*") &&
207+
!name.Contains("[") &&
208+
!name.Contains("//") &&
209+
name.FirstOrDefault() != '/' &&
210+
name.LastOrDefault() != '/' &&
211+
name.LastOrDefault() != '.' &&
212+
name != "@" &&
213+
!name.Contains("@{") &&
214+
!name.Contains("\\");
215+
216+
if (!isValidName)
217+
{
218+
return false;
224219
}
220+
foreach (var section in name.Split('/'))
221+
{
222+
isValidName = section.FirstOrDefault() != '.' &&
223+
!section.EndsWith(".lock");
224+
}
225+
226+
return isValidName;
225227
}
226228

227229
private bool _displayMergeBranchesGrid;

RetailCoder.VBE/UI/SourceControl/ChangesViewViewModel.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -168,24 +168,24 @@ private void Commit()
168168
}
169169

170170
RefreshView();
171+
172+
switch (CommitAction)
173+
{
174+
case CommitAction.Commit:
175+
RaiseErrorEvent(RubberduckUI.SourceControl_CommitStatus, RubberduckUI.SourceControl_CommitStatus_CommitSuccess, NotificationType.Info);
176+
return;
177+
case CommitAction.CommitAndPush:
178+
RaiseErrorEvent(RubberduckUI.SourceControl_CommitStatus, RubberduckUI.SourceControl_CommitStatus_CommitAndPushSuccess, NotificationType.Info);
179+
return;
180+
case CommitAction.CommitAndSync:
181+
RaiseErrorEvent(RubberduckUI.SourceControl_CommitStatus, RubberduckUI.SourceControl_CommitStatus_CommitAndSyncSuccess, NotificationType.Info);
182+
return;
183+
}
171184
}
172185
catch (SourceControlException ex)
173186
{
174187
RaiseErrorEvent(ex.Message, ex.InnerException.Message, NotificationType.Error);
175188
}
176-
177-
switch (CommitAction)
178-
{
179-
case CommitAction.Commit:
180-
RaiseErrorEvent(RubberduckUI.SourceControl_CommitStatus, RubberduckUI.SourceControl_CommitStatus_CommitSuccess, NotificationType.Info);
181-
return;
182-
case CommitAction.CommitAndPush:
183-
RaiseErrorEvent(RubberduckUI.SourceControl_CommitStatus, RubberduckUI.SourceControl_CommitStatus_CommitAndPushSuccess, NotificationType.Info);
184-
return;
185-
case CommitAction.CommitAndSync:
186-
RaiseErrorEvent(RubberduckUI.SourceControl_CommitStatus, RubberduckUI.SourceControl_CommitStatus_CommitAndSyncSuccess, NotificationType.Info);
187-
return;
188-
}
189189
}
190190

191191
private void IncludeChanges(IFileStatusEntry fileStatusEntry)

RetailCoder.VBE/UI/SourceControl/SourceControlView.xaml

Lines changed: 59 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@
77
xmlns:sourceControl="clr-namespace:Rubberduck.UI.SourceControl"
88
xmlns:controls="clr-namespace:Rubberduck.UI.Controls"
99
mc:Ignorable="d"
10-
d:DesignHeight="300" d:DesignWidth="300"
10+
d:DesignHeight="600" d:DesignWidth="300"
1111
d:DataContext="{d:DesignInstance {x:Type sourceControl:SourceControlViewViewModel}, IsDesignTimeCreatable=False}">
1212
<UserControl.Resources>
1313
<BitmapImage x:Key="RefreshImage" UriSource="../../Resources/arrow-circle-double.png" />
1414
<BitmapImage x:Key="OpenRepoImage" UriSource="../../Resources/folder-horizontal-open.png" />
1515
<BitmapImage x:Key="CreateRepoImage" UriSource="../../Resources/init-repo.png" />
1616
<BitmapImage x:Key="CloneRepoImage" UriSource="../../Resources/drive-download.png" />
17+
<BitmapImage x:Key="CreateNewRemoteRepoImage" UriSource="../../Resources/drive-upload.png" />
1718
<BitmapImage x:Key="GitIcon" UriSource="../../Resources/icon-github.png" />
1819
<BitmapImage x:Key="ErrorImage" UriSource="../../Resources/cross-circle.png" />
1920
<BitmapImage x:Key="WarningIcon" UriSource="../../Resources/exclamation-white.png" />
@@ -246,6 +247,12 @@
246247
Background="Transparent">
247248
<Image Source="{StaticResource CloneRepoImage}" />
248249
</Button>
250+
<Button ToolTip="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=SourceControl_CreateNewRemoteRepoButtonToolTip}"
251+
Command="{Binding CreateNewRemoteRepoCommand, Mode=OneWay}"
252+
BorderThickness="0"
253+
Background="Transparent">
254+
<Image Source="{StaticResource CreateNewRemoteRepoImage}" />
255+
</Button>
249256
<Separator />
250257
<StackPanel Orientation="Horizontal">
251258
<Image Source="{StaticResource GitIcon}" Height="25" />
@@ -356,15 +363,15 @@
356363
<TextBlock Text="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=SourceControl_RemotePathLabel}"
357364
FontWeight="SemiBold"
358365
Margin="0,0,0,5" />
359-
<TextBox Text="{Binding RemotePath, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
366+
<TextBox Text="{Binding CloneRemotePath, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
360367
Margin="0,0,0,10"
361368
Height="18"
362369
VerticalContentAlignment="Center" />
363370
<Image Source="{StaticResource ErrorImage}"
364371
HorizontalAlignment="Right"
365372
Margin="0,-57,-7.8,0"
366373
Width="16"
367-
Visibility="{Binding IsNotValidRemotePath, Converter={StaticResource BoolToVisibility}}" />
374+
Visibility="{Binding IsNotValidCloneRemotePath, Converter={StaticResource BoolToVisibility}}" />
368375

369376
<TextBlock Text="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=SourceControl_LocalDirectoryLabel}"
370377
FontWeight="SemiBold"
@@ -405,6 +412,55 @@
405412
</Grid>
406413
</StackPanel>
407414
</Grid>
415+
416+
<Grid Visibility="{Binding DisplayCreateNewRemoteRepoGrid, Converter={StaticResource BoolToVisibility}}"
417+
DockPanel.Dock="Top">
418+
<StackPanel VerticalAlignment="Top"
419+
Margin="10,5">
420+
<TextBlock Text="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=SourceControl_RemotePathLabel}"
421+
FontWeight="SemiBold"
422+
Margin="0,0,0,5" />
423+
<TextBox Text="{Binding CreateNewRemoteRemotePath, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
424+
Margin="0,0,0,10"
425+
Height="18"
426+
VerticalContentAlignment="Center" />
427+
<Image Source="{StaticResource ErrorImage}"
428+
HorizontalAlignment="Right"
429+
Margin="0,-57,-7.8,0"
430+
Width="16"
431+
Visibility="{Binding IsNotValidCreateNewRemoteRemotePath, Converter={StaticResource BoolToVisibility}}" />
432+
433+
<TextBlock Text="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=SourceControl_BranchName}"
434+
FontWeight="SemiBold"
435+
Margin="0,0,0,5" />
436+
<TextBox Text="{Binding RemoteBranchName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
437+
Margin="0,0,0,10"
438+
Height="18"
439+
VerticalContentAlignment="Center" />
440+
<Image Source="{StaticResource ErrorImage}"
441+
HorizontalAlignment="Right"
442+
Margin="0,-57,-7.8,0"
443+
Width="16"
444+
Visibility="{Binding IsNotValidBranchName, Converter={StaticResource BoolToVisibility}}" />
445+
<Grid Grid.IsSharedSizeScope="True"
446+
HorizontalAlignment="Right">
447+
<Grid.ColumnDefinitions>
448+
<ColumnDefinition SharedSizeGroup="CreateRemoteRepoButtons" />
449+
<ColumnDefinition SharedSizeGroup="CreateRemoteRepoButtons" />
450+
</Grid.ColumnDefinitions>
451+
<Button Content="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=OK}"
452+
Padding="5"
453+
Command="{Binding CreateNewRemoteRepoOkButtonCommand}">
454+
</Button>
455+
<Button Content="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=CancelButtonText}"
456+
Grid.Column="1"
457+
Margin="10,0,0,0"
458+
Padding="5"
459+
Command="{Binding CreateNewRemoteRepoCancelButtonCommand}">
460+
</Button>
461+
</Grid>
462+
</StackPanel>
463+
</Grid>
408464
<TabControl DockPanel.Dock="Bottom"
409465
ItemsSource="{Binding TabItems}"
410466
SelectedItem="{Binding SelectedItem, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />

0 commit comments

Comments
 (0)