Skip to content

Commit

Permalink
Add support for creating issues as epics and search for epics by titl…
Browse files Browse the repository at this point in the history
…e in a repo (#34)

* Create ability to create Epic in bulk.

* Add support for getting an epic from a title.

* Null check before trying to Trim.

* No need to expose the Title -- already exposed.

* Update the msbuild action to the latest version available
  • Loading branch information
AlexGhiondea authored Feb 9, 2021
1 parent a296fde commit 01bea59
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 57 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
nuget-version: latest

- name: Setup MSBuild
uses: microsoft/[email protected].0
uses: microsoft/[email protected].2

- name: Restore
run: nuget restore ./src/IssueCreator.sln
Expand Down
110 changes: 60 additions & 50 deletions src/IssueCreator/Dialogs/BulkCreateIssues.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 7 additions & 6 deletions src/IssueCreator/Dialogs/BulkCreateIssues.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,13 @@ private async Task<List<IssueToCreate>> LoadDataFromFileAsync(string fileName)

IssueToCreate issue = new IssueToCreate
{
Organization = csv.GetField<string>("Organization").Trim(),
Repository = csv.GetField<string>("Repository").Trim(),
Title = csv.GetField<string>("Title").Trim(),
Description = csv.GetField<string>("Description").Trim(),
AssignedTo = csv.GetField<string>("AssignedTo").Trim(),
Estimate = csv.GetField<string>("Estimate").Trim(),
Organization = csv.GetField<string>("Organization")?.Trim(),
Repository = csv.GetField<string>("Repository")?.Trim(),
Title = csv.GetField<string>("Title")?.Trim(),
Description = csv.GetField<string>("Description")?.Trim(),
AssignedTo = csv.GetField<string>("AssignedTo")?.Trim(),
Estimate = csv.GetField<string>("Estimate")?.Trim(),
CreateAsEpic = csv.GetField<bool>("IsEpic")
};

string milestone = csv.GetField<string>("Milestone");
Expand Down
3 changes: 3 additions & 0 deletions src/IssueCreator/Dialogs/BulkCreateIssues.resx
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@
<metadata name="LabelsCollection.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="CreateAsEpic.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="issueToCreateBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
Expand Down
24 changes: 24 additions & 0 deletions src/IssueCreator/IssueManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,30 @@ public async Task<List<IssueDescription>> GetEpicsAsync(List<string> repositorie
return (parts[0], parts[1]);
}

public async Task<List<IssueDescription>> GetEpicsWithTitleAsync(string title, string ownerAndRepoName)
{
(string owner, string repo) = GetOwnerAndRepoFromString(ownerAndRepoName);
RepositoryInfo gitHubRepoObj = await GetRepositoryAsync(owner, repo);
EpicList epicList = await GetValueFromCache(StringTemplate.Epic(owner, repo), async () => (await _zenHubClient.GetRepositoryClient(gitHubRepoObj.Id).GetEpicsAsync().ConfigureAwait(false)).Value, DateTimeOffset.Now.AddHours(1));

List<IssueDescription> findResults = new List<IssueDescription>();

foreach (EpicInfo epic in epicList.Epics)
{
long repoId = epic.RepositoryId;
int issueNumber = epic.IssueNumber;
// from the issue link, get the cached issue from the repo
IssueObject issue = await GetIssueAsync(repoId, issueNumber, IssueLoadScenario.LoadAllIssues);

if (StringComparer.OrdinalIgnoreCase.Equals(title, issue.Title))
{
findResults.Add(new IssueDescription() { Issue = issue, Repo = gitHubRepoObj });
}
}

return findResults;
}

/// <summary>
/// This is the code that calls into the cache.
/// </summary>
Expand Down

0 comments on commit 01bea59

Please sign in to comment.