-
Notifications
You must be signed in to change notification settings - Fork 503
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
✨ implement ListIssues
and GetCreatedAt
for Azure DevOps
#4419
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Jamie Magee <[email protected]>
With these changes the Details
|
// If there are fewer commits than requested, the first commit is the createdAt date | ||
if len(*commits) < handler.commitDepth { | ||
handler.firstCommitCreatedAt = (*commits)[len(*commits)-1].Committer.Date.Time |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can azure have a repository with no commits? These edge cases have been issues for Scorecard on other forges and would cause a panic
// Check if Git.CreateRepo event exists for the repository | ||
for i := range *auditLog.DecoratedAuditLogEntries { | ||
entry := &(*auditLog.DecoratedAuditLogEntries)[i] | ||
if *entry.ActionId == "Git.CreateRepo" && | ||
*entry.ProjectName == a.repourl.project && | ||
(*entry.Data)["RepoName"] == a.repourl.name { | ||
a.createdAt = entry.Timestamp.Time | ||
break | ||
} | ||
} | ||
|
||
if *auditLog.HasMore { | ||
continuationToken = *auditLog.ContinuationToken | ||
} else { | ||
break | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these breaks could be returns I think. At least the first one, otherwise it will only break out of the inner loop and keep searching the audit log (if there's more)
// Fetch URI, CreatedAt, Author, and Issue comments | ||
wiql := ` | ||
SELECT [System.Id] | ||
FROM WorkItems | ||
WHERE [System.TeamProject] = @project | ||
ORDER BY [System.Id] DESC |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it possible to grab the things we need from this query? or are those details only accessible via GetWorkItems
?
issue := clients.Issue{ | ||
URI: wi.Url, | ||
CreatedAt: &parsedTime, | ||
Author: &clients.User{Login: createdBy["uniqueName"].(string)}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you check all your other type assertions, did you mean to here?
What kind of change does this PR introduce?
(Is it a bug fix, feature, docs update, something else?)
What is the current behavior?
ListIssues
andGetCreatedAt
throw an unsupported errorWhat is the new behavior (if this is a feature change)?**
ListIssues
andGetCreatedAt
have implementationsWhich issue(s) this PR fixes
Next step of #4177
Special notes for your reviewer
Azure DevOps doesn't have an official API to retrieve user permissions for a project or a repository. As a stopgap solution, I've defaulted all issue and comment authors to
RepoAssociationMember
. This is probably a good minimum bar.The audit log is the best way to retrieve the repository creation date, but this may not be enabled. So I am using the first repository commit as a fallback value.
Does this PR introduce a user-facing change?
For user-facing changes, please add a concise, human-readable release note to
the
release-note
(In particular, describe what changes users might need to make in their
application as a result of this pull request.)