Skip to content
This repository has been archived by the owner on Aug 16, 2023. It is now read-only.

Updating the tool to support updating specific components given a com… #24

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 9 additions & 3 deletions NugetUpdate/Repositories/AzureDevOps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public AzureDevOps(string token, string organization, string project, string rep
_workItemService = new WorkItemService(organization, project, token);
}

public async Task<ICollection<string>> FindProjectFiles()
public async Task<ICollection<string>> FindProjectFiles(string componentDirectory = null)
{
var response = await _client.GetAsync($"{_apiBase}/items?api-version=2.0-preview&versionType=branch&Version={_defaultBranch}&recursionLevel=Full");

Expand All @@ -43,9 +43,15 @@ public async Task<ICollection<string>> FindProjectFiles()

foreach (dynamic item in content.value)
{
if (((string)item.path).EndsWith("csproj"))
string path = (string)item.path ;

Func<string, bool> isValidCsProj = p =>!string.IsNullOrEmpty(p)
&& (string.IsNullOrWhiteSpace(componentDirectory) || !string.IsNullOrWhiteSpace(componentDirectory) && p.ToLower().Contains(componentDirectory.ToLower()))
&& p.EndsWith("csproj");

if (isValidCsProj(path))
{
results.Add((string)item.path);
results.Add(path);
}
}

Expand Down
2 changes: 1 addition & 1 deletion NugetUpdate/Repositories/Github.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public async Task<TextFile> GetTextFile(string path)
return new TextFile(path, fromBase64String, true);
}

public async Task<ICollection<string>> FindProjectFiles()
public async Task<ICollection<string>> FindProjectFiles(string componentDirectory = null)
{
var results = new List<string>();

Expand Down
2 changes: 1 addition & 1 deletion NugetUpdate/Repositories/IRepositorySource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ public interface IRepositorySource

Task<TextFile> GetTextFile(string path);

Task<ICollection<string>> FindProjectFiles();
Task<ICollection<string>> FindProjectFiles(string componentDirectory = null);
}
}
4 changes: 2 additions & 2 deletions NugetUpdate/RepositorySourceExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ namespace NugetPackageUpdates
{
public static class RepositorySourceExtensions
{
public static async Task<ICollection<ProjectFile>> GetProjectFiles(this IRepositorySource repository)
public static async Task<ICollection<ProjectFile>> GetProjectFiles(this IRepositorySource repository, string componentDirectory = null)
{
var files = new List<ProjectFile>();

foreach (var path in await repository.FindProjectFiles())
foreach (var path in await repository.FindProjectFiles(componentDirectory))
{
files.Add(await repository.GetProjectFile(path));
}
Expand Down
9 changes: 5 additions & 4 deletions NugetUpdate/UpdateManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,10 @@ public async Task CreatePullRequestsAsync(
IRepositorySource ops,
string[] reviewers,
int? prLimit = null,
bool associatWithWorkItem = false)
bool associatWithWorkItem = false,
string componentDirectory = null)
{
var changeSets = await GetChangeSets(ops);
var changeSets = await GetChangeSets(ops, componentDirectory: componentDirectory);

_log.WriteLine("Opening PRs");

Expand All @@ -65,10 +66,10 @@ public async Task CreatePullRequestsAsync(
}
}

public async Task<IReadOnlyCollection<ChangeSet>> GetChangeSets(IRepositorySource ops)
public async Task<IReadOnlyCollection<ChangeSet>> GetChangeSets(IRepositorySource ops, string componentDirectory = null)
{
_log.WriteLine("Fetching project files");
var projectFiles = await ops.GetProjectFiles();
var projectFiles = await ops.GetProjectFiles(componentDirectory);

if (projectFiles == null || !projectFiles.Any())
{
Expand Down