Skip to content

Commit

Permalink
Added support for Track remote feature branch. The feature view now s…
Browse files Browse the repository at this point in the history
…hows all local feature branches + the remote feature branches that do not have a local tracking branch. An icon indicates which branches that are remote #25
  • Loading branch information
jakobehn committed Jan 19, 2016
1 parent 122588f commit 0253eb0
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 23 deletions.
1 change: 1 addition & 0 deletions GitFlow.VS.Extension/GitFlow.VS.Extension.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<IncludeInVSIX>true</IncludeInVSIX>
</Content>
<Resource Include="Resources\upstreambranch.png" />
<None Include="packages.config" />
<None Include="source.extension.2013.vsixmanifest">
<SubType>Designer</SubType>
Expand Down
Binary file added GitFlow.VS.Extension/Resources/upstreambranch.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 12 additions & 8 deletions GitFlow.VS.Extension/UI/FeaturesUI.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,8 @@
<DataGrid Grid.Row="1" Name="FeaturesGrid" Margin="6,6,6,6" Padding="0,5,0,0" ItemsSource="{Binding AllFeatures}" AutoGenerateColumns="False" GridLinesVisibility="None" HeadersVisibility="None" BorderThickness="0" SelectedItem="{Binding SelectedFeature}" CanUserAddRows="False" Background="{StaticResource ItemBrushKey}" clr:Commands.DataGridDoubleClickCommand="{Binding CheckoutFeatureBranchCommand}">
<DataGrid.RowStyle>
<Style TargetType="{x:Type DataGridRow}">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=IsRemote}" Value="True">
<Setter Property="FontStyle" Value="Italic"/>
</DataTrigger>
<DataTrigger Binding="{Binding Path=IsCurrentBranch}" Value="True">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=IsCurrentBranch}" Value="True">
<Setter Property="FontWeight" Value="Bold"/>
</DataTrigger>
<Trigger Property="UIElement.IsMouseOver" Value="true">
Expand All @@ -45,7 +42,14 @@
</Style>
</DataGrid.RowStyle>
<DataGrid.Columns>
<DataGridTemplateColumn Header="Name" Width="SizeToCells" IsReadOnly="True">
<DataGridTemplateColumn Header="" IsReadOnly="True" Width="30">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Image Source="/GitFlowVS.Extension;component/Resources/upstreambranch.png" Width="21px" Height="14px" ToolTip="Remote branch. Select Track to create a local branch that tracks this remote branch" Visibility="{Binding IsRemoteBranchVisibility}"></Image>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="Name" IsReadOnly="True" Width="*">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" >
Expand All @@ -56,8 +60,8 @@
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="Changed" Width="SizeToCells" IsReadOnly="True">

<DataGridTemplateColumn Header="Changed" IsReadOnly="True" Width="80">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding LastCommitAsString}" HorizontalAlignment="Right" />
Expand Down
11 changes: 0 additions & 11 deletions GitFlow.VS.Extension/UI/FeaturesUI.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,6 @@ public FeaturesUI(FeaturesViewModel model)
{
InitializeComponent();
DataContext = model;

FeaturesGrid.Loaded += FeaturesGridOnLoaded;
}

private void FeaturesGridOnLoaded(object sender, RoutedEventArgs routedEventArgs)
{
foreach (var column in FeaturesGrid.Columns)
{
column.MinWidth = column.ActualWidth;
column.Width = new DataGridLength(1, DataGridLengthUnitType.Star);
}
}

private void FeaturesGrid_OnMouseDoubleClick(object sender, MouseButtonEventArgs e)
Expand Down
2 changes: 1 addition & 1 deletion GitFlow.VS.Extension/ViewModels/FeaturesViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public bool CanCheckoutFeatureBranch
{
get
{
return SelectedFeature != null && !SelectedFeature.IsCurrentBranch;
return SelectedFeature != null && !SelectedFeature.IsCurrentBranch && !SelectedFeature.IsRemote;
}
}

Expand Down
11 changes: 11 additions & 0 deletions GitFlow.VS/BranchItem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Windows;

namespace GitFlow.VS
{
Expand All @@ -25,6 +26,16 @@ public string LastCommitAsString
}
}

public Visibility IsRemoteBranchVisibility
{
get
{
if (IsRemote)
return Visibility.Visible;
return Visibility.Hidden;
}
}

public string ToolTip
{
get { return "Commit: " + CommitId + "\nAuthor: " + Author + "\nDate: " + LastCommit.Date.ToShortDateString() + "\n\n" + Message; }
Expand Down
1 change: 1 addition & 0 deletions GitFlow.VS/GitFlow.VS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
<Reference Include="LibGit2Sharp">
<HintPath>..\packages\LibGit2Sharp.0.20.1.0\lib\net40\LibGit2Sharp.dll</HintPath>
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Windows.Forms" />
Expand Down
28 changes: 25 additions & 3 deletions GitFlow.VS/GitFlowWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,19 +122,37 @@ public IEnumerable<BranchItem> AllFeatureBranches
using (var repo = new Repository(repoDirectory))
{
var prefix = repo.Config.Get<string>("gitflow.prefix.feature").Value;
return
repo.Branches.Where(b => (!b.IsRemote && b.Name.StartsWith(prefix)) /*|| (b.IsRemote && b.Name.Contains(prefix))*/)
var featureBranches =
repo.Branches.Where(b => !b.IsRemote && b.Name.StartsWith(prefix) )
.Select(c => new BranchItem
{
Author = c.Tip.Author.Name,
Name = c.IsRemote ? c.Name : c.Name.Replace(prefix,""),
Name = c.Name.Replace(prefix,""),
LastCommit = c.Tip.Author.When,
IsTracking = c.IsTracking,
IsCurrentBranch = c.IsCurrentRepositoryHead,
IsRemote = c.IsRemote,
CommitId = c.Tip.Id.ToString(),
Message = c.Tip.MessageShort
}).ToList();

var remoteFeatureBranches =
repo.Branches.Where(b => b.IsRemote && b.Name.Contains(prefix)
&& !repo.Branches.Any(br => !br.IsRemote && br.IsTracking && br.TrackedBranch.CanonicalName== b.CanonicalName))
.Select(c => new BranchItem
{
Author = c.Tip.Author.Name,
Name = c.Name,
LastCommit = c.Tip.Author.When,
IsTracking = c.IsTracking,
IsCurrentBranch = c.IsCurrentRepositoryHead,
IsRemote = c.IsRemote,
CommitId = c.Tip.Id.ToString(),
Message = c.Tip.MessageShort
}).ToList();

featureBranches.AddRange(remoteFeatureBranches);
return featureBranches;
}

}
Expand All @@ -148,6 +166,10 @@ public GitFlowCommandResult PublishFeature(string featureName)

private string TrimBranchName(string branchName)
{
if( branchName.LastIndexOf('/') >= 0)
{
branchName = branchName.Substring(branchName.LastIndexOf('/')+1);
}
return branchName.Trim().Replace(" ", "_");
}

Expand Down

0 comments on commit 0253eb0

Please sign in to comment.