Skip to content

Commit 65e1b0d

Browse files
author
Calin Lupas
authored
Merge pull request #44 from DevExcelerate/hotfix/fixes
Hotfix/fixes
2 parents 864e9a5 + 8cdd92b commit 65e1b0d

5 files changed

Lines changed: 32 additions & 56 deletions

File tree

src/DevExcelerateApi/Resources/Services.LocalizationService.fr.resx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@
187187
<value>Cette équipe existe déjà au sein de l'organisation.</value>
188188
</data>
189189
<data name="ERROR_TEAM_MEMBER_DOES_NOT_EXISTS" xml:space="preserve">
190-
<value>Le membre d'équipe {0} n'existe pas.</value>
190+
<value>Le membre d'équipe {0} n'existe pas au sein de l'organisation.</value>
191191
</data>
192192
<data name="ERROR_INVAILD_REPO_NAME" xml:space="preserve">
193193
<value>Le nom du dépôt '{0}' est invalide.</value>

src/DevExcelerateApi/Resources/Services.LocalizationService.resx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@
187187
<value>This team name already exists within the organization.</value>
188188
</data>
189189
<data name="ERROR_TEAM_MEMBER_DOES_NOT_EXISTS" xml:space="preserve">
190-
<value>The team member {0} does not exist.</value>
190+
<value>The team member {0} does not exist within the organization.</value>
191191
</data>
192192
<data name="ERROR_INVAILD_REPO_NAME" xml:space="preserve">
193193
<value>The repository name '{0}' is invalid.</value>

src/DevExcelerateApi/Services/DevExIssuesEventProcessorService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public async Task SaveAndProcessIssueCommentEventAsync(WebhookHeaders headers, I
5757
// Validate if the issue comment is from a user vs bot
5858
if (issueCommentEvent?.Sender?.Type == UserType.Bot)
5959
{
60-
_logger.LogInformation("Bypassing GitHub Webhook event for Issue# {number} with action - {action}...", issueCommentEvent?.Issue.Number, issueCommentEvent?.Action);
60+
_logger.LogInformation("Bypassing GitHub Webhook Issue Comment event (Bot) for Issue# {number} with action - {action}...", issueCommentEvent?.Issue.Number, issueCommentEvent?.Action);
6161
return;
6262
}
6363

src/DevExcelerateApi/Services/RepositoryService.cs

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ public async Task ValidateRepository(IssuesEvent issuesEvent, bool createPullReq
5656
{
5757
await gitHubClient.Repository.Get(repoRequest.RepositoryOwner, repoRequest.RepositoryName);
5858
validationReasons.Add(_localizationService.GetLocalizedString(Constants.ERROR_REPO_EXISTS));
59+
isValid = false;
5960
}
6061
catch (NotFoundException)
6162
{
@@ -217,42 +218,30 @@ public async Task SaveRepository(PullRequestEvent pullRequestEvent)
217218
try
218219
{
219220
var fileContents = await gitHubClient.GetCommitFilesWithContentAsync(owner!, repo!, mergeCommitSha!);
220-
var isComplete = true;
221-
var completeMessage = string.Empty;
221+
var completeMessage = $"{_localizationService.GetLocalizedString(Constants.ERROR_PR_NO_CHANGES)}";
222222

223-
if (fileContents.Count == 0)
224-
{
225-
isComplete = false;
226-
completeMessage = $"{_localizationService.GetLocalizedString(Constants.ERROR_PR_NO_CHANGES)}";
227-
}
228-
else
223+
foreach (var file in fileContents)
229224
{
230-
foreach (var file in fileContents)
225+
if (file.Key.EndsWith(DevExPolicies.Repository_Metadata.GetPolicyYamlFileName(), StringComparison.OrdinalIgnoreCase))
231226
{
232-
if (file.Key.EndsWith(DevExPolicies.Repository_Metadata.GetPolicyYamlFileName(), StringComparison.OrdinalIgnoreCase))
233-
{
234-
var repoCreationMetadata = RepositoryRequestModel.DeserializeFromYaml(file.Value);
227+
var repoCreationMetadata = RepositoryRequestModel.DeserializeFromYaml(file.Value);
235228

236-
if (repoCreationMetadata.RequestType == RequestType.CREATE_REPOSITORY)
237-
{
238-
// Save the repo
239-
Repository? savedRepo = await SaveRepositoryInternal(pullRequestEvent?.Installation?.Id, repoCreationMetadata);
229+
if (repoCreationMetadata.RequestType == RequestType.CREATE_REPOSITORY)
230+
{
231+
// Save the repo
232+
Repository? savedRepo = await SaveRepositoryInternal(pullRequestEvent?.Installation?.Id, repoCreationMetadata);
240233

241-
completeMessage = $"{_localizationService.GetLocalizedString(Constants.ISSUE_COMPLETED)}\n- Repository: {savedRepo?.HtmlUrl}";
242-
}
234+
completeMessage = $"{_localizationService.GetLocalizedString(Constants.ISSUE_COMPLETED)}\n- Repository: {savedRepo?.HtmlUrl}";
243235
}
244236
}
245237
}
246238

247-
if (isComplete)
248-
{
249-
// Last step: Add a comment to the issue and close the issue
250-
await _issueService.ChangeIssueLabel(_gitHubOptions.RepoOnboarding, issueNumber, [LocalizationExtensions.GetLocalizedString(TicketStatus.COMPLETED.ToString())], pullRequestEvent!);
239+
// Last step: Add a comment to the issue and close the issue
240+
await _issueService.ChangeIssueLabel(_gitHubOptions.RepoOnboarding, issueNumber, [LocalizationExtensions.GetLocalizedString(TicketStatus.COMPLETED.ToString())], pullRequestEvent!);
251241

252-
await AddCommentToIssueAndPullRequest(issueNumber, completeMessage, pullRequestEvent!);
242+
await AddCommentToIssueAndPullRequest(issueNumber, completeMessage, pullRequestEvent!);
253243

254-
await gitHubClient.Issue.Update(owner, _gitHubOptions.RepoOnboarding, issueNumber, new IssueUpdate { State = ItemState.Closed });
255-
}
244+
await gitHubClient.Issue.Update(owner, _gitHubOptions.RepoOnboarding, issueNumber, new IssueUpdate { State = ItemState.Closed });
256245
}
257246
catch (Exception ex)
258247
{

src/DevExcelerateApi/Services/TeamService.cs

Lines changed: 15 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,8 @@ public async Task ValidateTeam(IssuesEvent issuesEvent, bool createPullRequest)
143143
{
144144
try
145145
{
146-
// Check if the member exists
147-
await gitHubClient.User.Get(member);
148-
//await gitHubClient.Organization.Member.GetOrganizationMembership(teamRequest.TeamOwner, member);
146+
// Check if the member exists within the organization
147+
await gitHubClient.Organization.Member.GetOrganizationMembership(teamRequest.TeamOwner, member);
149148
}
150149
catch (NotFoundException)
151150
{
@@ -257,42 +256,30 @@ public async Task SaveTeam(PullRequestEvent pullRequestEvent)
257256
try
258257
{
259258
var fileContents = await gitHubClient.GetCommitFilesWithContentAsync(owner!, repo!, mergeCommitSha!);
260-
var isComplete = true;
261-
var completeMessage = string.Empty;
259+
var completeMessage = $"{_localizationService.GetLocalizedString(Constants.ERROR_PR_NO_CHANGES)}";
262260

263-
if (fileContents.Count == 0)
261+
foreach (var file in fileContents)
264262
{
265-
isComplete = false;
266-
completeMessage = $"{_localizationService.GetLocalizedString(Constants.ERROR_PR_NO_CHANGES)}";
267-
}
268-
else
269-
{
270-
foreach (var file in fileContents)
263+
if (file.Key.EndsWith(DevExPolicies.Team_Metadata.GetPolicyYamlFileName(), StringComparison.OrdinalIgnoreCase))
271264
{
272-
if (file.Key.EndsWith(DevExPolicies.Team_Metadata.GetPolicyYamlFileName(), StringComparison.OrdinalIgnoreCase))
273-
{
274-
var teamMetadata = TeamRequestModel.DeserializeFromYaml(file.Value);
265+
var teamMetadata = TeamRequestModel.DeserializeFromYaml(file.Value);
275266

276-
if (teamMetadata.RequestType == RequestType.CREATE_TEAM || teamMetadata.RequestType == RequestType.UPDATE_TEAM)
277-
{
278-
// Save the team
279-
Team? savedTeam = await SaveTeamInternal(pullRequestEvent?.Installation?.Id, teamMetadata);
267+
if (teamMetadata.RequestType == RequestType.CREATE_TEAM || teamMetadata.RequestType == RequestType.UPDATE_TEAM)
268+
{
269+
// Save the team
270+
Team? savedTeam = await SaveTeamInternal(pullRequestEvent?.Installation?.Id, teamMetadata);
280271

281-
completeMessage = $"{_localizationService.GetLocalizedString(Constants.ISSUE_COMPLETED)}\n- Team: {savedTeam?.HtmlUrl}";
282-
}
272+
completeMessage = $"{_localizationService.GetLocalizedString(Constants.ISSUE_COMPLETED)}\n- Team: {savedTeam?.HtmlUrl}";
283273
}
284274
}
285275
}
286276

287-
if (isComplete)
288-
{
289-
// Last step: Add a comment to the issue and close the issue
290-
await _issueService.ChangeIssueLabel(_gitHubOptions.RepoOnboarding, issueNumber, [LocalizationExtensions.GetLocalizedString(TicketStatus.COMPLETED.ToString())], pullRequestEvent!);
277+
// Last step: Add a comment to the issue and close the issue
278+
await _issueService.ChangeIssueLabel(_gitHubOptions.RepoOnboarding, issueNumber, [LocalizationExtensions.GetLocalizedString(TicketStatus.COMPLETED.ToString())], pullRequestEvent!);
291279

292-
await AddCommentToIssueAndPullRequest(issueNumber, completeMessage, pullRequestEvent!);
280+
await AddCommentToIssueAndPullRequest(issueNumber, completeMessage, pullRequestEvent!);
293281

294-
await gitHubClient.Issue.Update(owner, _gitHubOptions.RepoOnboarding, issueNumber, new IssueUpdate { State = ItemState.Closed });
295-
}
282+
await gitHubClient.Issue.Update(owner, _gitHubOptions.RepoOnboarding, issueNumber, new IssueUpdate { State = ItemState.Closed });
296283
}
297284
catch (Exception ex)
298285
{

0 commit comments

Comments
 (0)