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

Team changes #41

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open
Changes from 2 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
aa22aac
1) foresee TeamChangesetProvider : get all not yet merged changesets.
RubenWillems Apr 20, 2018
3a65834
Initial split team and solo
DieterVantilt Apr 20, 2018
6adb43c
reworked teamChangesetProvider : removed hard coded test settings
RubenWillems Apr 20, 2018
8893a44
Merge conflict changes
DieterVantilt Apr 20, 2018
02f04db
Merge branch 'TeamChanges' of https://github.com/RubenWillems/AutoMer…
DieterVantilt Apr 20, 2018
30da8ab
Branch change set
DieterVantilt Apr 20, 2018
5f672fe
Choosing the source and target branch
DieterVantilt Apr 20, 2018
ab56d59
Implementation for the merging and adding all associated work items.
dieter-vantilt May 1, 2018
64b855c
nameof operator iso strings for raise event
RubenWillems May 3, 2018
9a9a740
Merge branch 'TeamChanges' of https://github.com/RubenWillems/AutoMer…
RubenWillems May 3, 2018
749bbf1
move providers into separate folder
RubenWillems May 3, 2018
bbdebe1
list tfs projects, list branches of project
RubenWillems May 3, 2018
cf4bd95
show all branches, --> recursionType Full
RubenWillems May 3, 2018
e431011
Adding button to fetch all changesets
DieterVantilt May 8, 2018
10138ac
Merge branch 'TeamChanges' of https://github.com/RubenWillems/AutoMer…
DieterVantilt May 8, 2018
d15fc40
dummy values for testing (remove later on)
RubenWillems May 17, 2018
610465c
fix merge
RubenWillems May 17, 2018
5fc01da
Project source en target branches
dieter-vantilt May 17, 2018
016a3f2
resolve conflicts
RubenWillems May 18, 2018
5bdf8c0
Change to target branch
DieterVantilt May 18, 2018
6b225fb
clean up code
RubenWillems May 18, 2018
c09eaa2
clean up code
RubenWillems May 18, 2018
b4fa7a7
set .Net target framework back to 4.6.2
RubenWillems Jun 15, 2018
38e9251
fix build ? removed newer C# syntax features
RubenWillems Jun 19, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/AutoMerge/AutoMerge.csproj
Original file line number Diff line number Diff line change
@@ -290,6 +290,7 @@
<Compile Include="Guids.cs" />
<Compile Include="Helpers\BranchHelper.cs" />
<Compile Include="Helpers\EnumerableExtensions.cs" />
<Compile Include="Helpers\CollectionExtensions.cs" />
<Compile Include="Helpers\ProjectNameHelper.cs" />
<Compile Include="Helpers\VersionControlNavigationHelper.cs" />
<Compile Include="Helpers\WorkspaceHelper.cs" />
16 changes: 16 additions & 0 deletions src/AutoMerge/Helpers/CollectionExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;

namespace AutoMerge.Helpers
{
public static class CollectionExtensions
{
public static void AddRange<T>(this Collection<T> list, IEnumerable<T> itemsToAdd)
{
foreach(var itemToAdd in itemsToAdd)
{
list.Add(itemToAdd);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -36,19 +36,15 @@ public List<string> ListBranches(string projectName)
{
List<string> result = new List<string>();

result.Add("Test/Main");
result.Add("ROL-Omgeving/Main");


var changesetService = GetChangesetService();

if (changesetService != null)
{
changesetService.ListBranches("jos");
var branches = changesetService.ListBranches(projectName);

result.AddRange(branches.Select(x => x.Properties.RootItem.Item));
}


return result;

}
@@ -67,17 +63,11 @@ protected override List<ChangesetViewModel> GetChangesetsInternal()

if (changesetService != null)
{

///dummy calls for testing the functionality
var prj = changesetService.ListTfsProjects();
var s = changesetService.ListBranches("Test");

var tfsChangesets = changesetService.GetMergeCandidates(_sourceBranch, _targetBranch);

changesets = tfsChangesets
.Select(tfsChangeset => ToChangesetViewModel(tfsChangeset, changesetService))
.ToList();

}

return changesets;
6 changes: 3 additions & 3 deletions src/AutoMerge/RecentChangesets/RecentChangesetsViewModel.cs
Original file line number Diff line number Diff line change
@@ -96,12 +96,12 @@ protected override async Task InitializeAsync(object sender, SectionInitializeEv
}
}

protected override async Task RefreshAsync()
protected async Task GetChangesetAndUpdateTitleAsync()
{
Changesets.Clear();

Logger.Info("Getting changesets ...");
var changesets = await GetChangesets();
var changesets = await GetChangesetsAsync();
Logger.Info("Getting changesets end");

Changesets = new ObservableCollection<ChangesetViewModel>(changesets);
@@ -114,7 +114,7 @@ protected override async Task RefreshAsync()
}
}

public abstract Task<List<ChangesetViewModel>> GetChangesets();
public abstract Task<List<ChangesetViewModel>> GetChangesetsAsync();

protected void UpdateTitle()
{
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ public class RecentChangesetsTeamViewModelContext : RecentChangesetsViewModelCon

public string TargetBranch { get; set; }

public ObservableCollection<ChangesetViewModel> SelectedChangesets { get; set; }
public string SelectedProjectName { get; set; }
}

public class RecentChangesetsSoloViewModelContext : RecentChangesetsViewModelContext
Original file line number Diff line number Diff line change
@@ -49,7 +49,7 @@ public string ChangesetIdsText
}
private string _changesetIdsText;

public override async Task<List<ChangesetViewModel>> GetChangesets()
public override async Task<List<ChangesetViewModel>> GetChangesetsAsync()
{
var userLogin = VersionControlNavigationHelper.GetAuthorizedUser(ServiceProvider);
var changesetProvider = new MyChangesetChangesetProvider(ServiceProvider, Settings.Instance.ChangesetCount, userLogin);
@@ -98,6 +98,11 @@ private void ResetAddById()
ChangesetIdsText = string.Empty;
}

protected override async Task RefreshAsync()
{
await GetChangesetAndUpdateTitleAsync();
}

private async void AddChangesetByIdExecute()
{
ShowBusy();
Original file line number Diff line number Diff line change
@@ -26,6 +26,12 @@

<StackPanel Margin="6,6,6,6">

<TextBlock Text="Project name:" />
<ComboBox ItemsSource="{Binding ProjectNames}"
SelectedItem="{Binding SelectedProjectName, UpdateSourceTrigger=PropertyChanged}">

</ComboBox>

<TextBlock Text="Source branch:" />
<ComboBox ItemsSource="{Binding SourcesBranches}"
SelectedItem="{Binding SourceBranch, UpdateSourceTrigger=PropertyChanged}">
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using AutoMerge.Helpers;
using AutoMerge.Prism.Command;
using Microsoft.TeamFoundation.Controls;

@@ -11,13 +12,15 @@ namespace AutoMerge
public class RecentChangesetsTeamViewModel : RecentChangesetsViewModel
{
private BranchTeamService _branchTeamService;
private string _projectName;
private TeamChangesetChangesetProvider _teamChangesetChangesetProvider;
private List<string> _currentBranches;

public RecentChangesetsTeamViewModel(ILogger logger) : base(logger)
{
SelectedChangesets = new ObservableCollection<ChangesetViewModel>();
SourcesBranches = new ObservableCollection<string>();
TargetBranches = new ObservableCollection<string>();
ProjectNames = new ObservableCollection<string>();

MergeCommand = DelegateCommand.FromAsyncHandler(MergeAsync, CanMerge);
FetchChangesetsCommand = DelegateCommand.FromAsyncHandler(FetchChangesetsAsync, CanFetchChangesets);
@@ -26,9 +29,31 @@ public RecentChangesetsTeamViewModel(ILogger logger) : base(logger)
public DelegateCommand MergeCommand { get; }
public DelegateCommand FetchChangesetsCommand { get; }

public ObservableCollection<string> ProjectNames { get; set; }
public ObservableCollection<string> SourcesBranches { get; set; }
public ObservableCollection<string> TargetBranches { get; set; }

private string _selectedProjectName;

public string SelectedProjectName
{
get { return _selectedProjectName; }
set
{
_selectedProjectName = value;
RaisePropertyChanged(nameof(SelectedProjectName));

_currentBranches = _teamChangesetChangesetProvider.ListBranches(SelectedProjectName);

Changesets.Clear();
SourcesBranches.Clear();
TargetBranches.Clear();
SourcesBranches.AddRange(_currentBranches);

UpdateTitle();
}
}

private string _sourceBranch;

public string SourceBranch
@@ -65,11 +90,6 @@ public ObservableCollection<ChangesetViewModel> SelectedChangesets
get { return _selectedChangesets; }
set
{
if (_selectedChangesets != null)
{
_selectedChangesets.CollectionChanged -= SelectedChangesets_CollectionChanged;
}

_selectedChangesets = value;
RaisePropertyChanged(nameof(SelectedChangesets));

@@ -107,10 +127,7 @@ private bool CanMerge()

private async Task FetchChangesetsAsync()
{
await SetBusyWhileExecutingAsync(async () => await RefreshAsync());

//This is needed because HideBusy will set IsBusy on false much later. And the raise can execute checks on this boolean
IsBusy = false;
await SetBusyWhileExecutingAsync(async () => await GetChangesetAndUpdateTitleAsync());

MergeCommand.RaiseCanExecuteChanged();
}
@@ -122,33 +139,25 @@ private bool CanFetchChangesets()

protected override Task InitializeAsync(object sender, SectionInitializeEventArgs e)
{
_projectName = ProjectNameHelper.GetProjectName(ServiceProvider);
//Find all sources branches.
SourcesBranches.Add("$/Test/B01");
_branchTeamService = new BranchTeamService(Context.TeamProjectCollection, (ITeamExplorer)ServiceProvider.GetService(typeof(ITeamExplorer)));
_teamChangesetChangesetProvider = new TeamChangesetChangesetProvider(ServiceProvider);

_branchTeamService = new BranchTeamService(Context.TeamProjectCollection, (ITeamExplorer) ServiceProvider.GetService(typeof(ITeamExplorer)));
var projectNames = _teamChangesetChangesetProvider.ListProjects();
projectNames.ForEach(x => ProjectNames.Add(x.Name));

return base.InitializeAsync(sender, e);
}

public void InitializeTargetBranches()
{
TargetBranches.Clear();

//Find all possible target branches
TargetBranches.Add("$/Test/MAIN");
TargetBranches.AddRange(_currentBranches.Except(new List<string> { SourceBranch }));
}

public override async Task<List<ChangesetViewModel>> GetChangesets()
public override async Task<List<ChangesetViewModel>> GetChangesetsAsync()
{
if (SourceBranch != null && TargetBranch != null)
{
var changesetProvider = new TeamChangesetChangesetProvider(ServiceProvider);
changesetProvider.SetSourceAndTargetBranch(SourceBranch, TargetBranch);
return await changesetProvider.GetChangesets();
}

return await Task.FromResult(new List<ChangesetViewModel>());
_teamChangesetChangesetProvider.SetSourceAndTargetBranch(SourceBranch, TargetBranch);
return await _teamChangesetChangesetProvider.GetChangesets();
}

public override void SaveContext(object sender, SectionSaveContextEventArgs e)
@@ -157,10 +166,9 @@ public override void SaveContext(object sender, SectionSaveContextEventArgs e)

var context = new RecentChangesetsTeamViewModelContext
{
SelectedProjectName = SelectedProjectName,
Changesets = Changesets,
Title = Title,
SelectedChangeset = SelectedChangeset,
SelectedChangesets = SelectedChangesets,
SourceBranch = SourceBranch,
TargetBranch = TargetBranch
};
@@ -171,17 +179,35 @@ public override void SaveContext(object sender, SectionSaveContextEventArgs e)
protected override void RestoreContext(SectionInitializeEventArgs e)
{
var context = (RecentChangesetsTeamViewModelContext) e.Context;


SelectedProjectName = context.SelectedProjectName;
Changesets = context.Changesets;
Title = context.Title;
SelectedChangesets = context.SelectedChangesets;
SelectedChangeset = context.SelectedChangeset;
SourceBranch = context.SourceBranch;
TargetBranch = context.TargetBranch;
}

public override void Loaded(object sender, SectionLoadedEventArgs e)
{
base.Loaded(sender, e);

//manuelly set to false beacause apparently Hidebusy will set isbuys on false much later...
IsBusy = false;

MergeCommand.RaiseCanExecuteChanged();
FetchChangesetsCommand.RaiseCanExecuteChanged();
}

public override void Dispose()
{
base.Dispose();

if (_selectedChangesets != null)
{
_selectedChangesets.CollectionChanged -= SelectedChangesets_CollectionChanged;
}
}

protected override string BaseTitle => "Project name: " + _projectName;
protected override string BaseTitle => "Project name: " + SelectedProjectName;
}
}
4 changes: 2 additions & 2 deletions src/AutoMerge/Services/ChangesetService.cs
Original file line number Diff line number Diff line change
@@ -76,8 +76,8 @@ public IEnumerable<BranchObject> ListBranches(string projectName)
{
var dummy = _versionControlServer.QueryRootBranchObjects(RecursionType.Full);

List<BranchObject> result = new List<BranchObject>();
foreach(BranchObject bo in dummy)
var result = new List<BranchObject>();
foreach(var bo in dummy)
{
var ro = bo.Properties.RootItem;