public List<GitBranchInfo> GetBranchInfo(bool includeRemote = true, bool includeLocal = true, bool forceReload = false)
{
using (var repository = GetRepository())
{
if (forceReload || _branchInfoList == null || _branchInfoList.Count <= 0)
{
_branchInfoList = new List<GitBranchInfo>();
if (includeRemote && includeLocal)
{
_branchInfoList.AddRange(
repository.Branches.Select(CreateBranchInfoFromBranch));
}
else if (includeRemote)
{
_branchInfoList.AddRange(
repository.Branches.Where(b => b.IsRemote)
.Select(CreateBranchInfoFromBranch));
}
else
{
_branchInfoList.AddRange(
repository.Branches.Where(b => !b.IsRemote)
.Select(CreateBranchInfoFromBranch));
}
//we did not find and branch.. must just have a master and never pushed to the server
if (_branchInfoList.Count == 0)
{
_branchInfoList.Add(CurrentBranchInfo);
}
}
return _branchInfoList;
}
}