Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Eclipse Foundation
IT
APIs
git-eca-rest-api
Commits
24d788a2
Commit
24d788a2
authored
Jun 08, 2021
by
Martin Lowe
🇨🇦
Committed by
Martin Lowe
Jun 08, 2021
Browse files
Update to account for bots w/ Eclipse accounts
parent
96b12504
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/eclipsefoundation/git/eca/resource/ValidationResource.java
View file @
24d788a2
...
...
@@ -183,54 +183,46 @@ public class ValidationResource {
// retrieve the eclipse account for the author
EclipseUser
eclipseAuthor
=
getIdentifiedUser
(
author
);
if
(
eclipseAuthor
==
null
)
{
// if the user is a bot, generate a stubbed user
if
(
isAllowedUser
(
author
.
getMail
()))
{
addMessage
(
response
,
String
.
format
(
"Automated user '%1$s' detected for author of commit %2$s"
,
author
.
getMail
(),
c
.
getHash
()),
c
.
getHash
());
eclipseAuthor
=
EclipseUser
.
createBotStub
(
author
);
}
else
if
(!
userIsABot
(
author
.
getMail
(),
filteredProjects
))
{
addMessage
(
response
,
String
.
format
(
"Could not find an Eclipse user with mail '%1$s' for author of commit %2$s"
,
committer
.
getMail
(),
c
.
getHash
()),
c
.
getHash
());
addError
(
response
,
"Author must have an Eclipse Account"
,
c
.
getHash
());
return
true
;
}
// set the Eclipse author as the basic committer w\ bot flag to pass information forward
// if the user is a bot, generate a stubbed user
if
(
isAllowedUser
(
author
.
getMail
())
||
userIsABot
(
author
.
getMail
(),
filteredProjects
))
{
addMessage
(
response
,
String
.
format
(
"Automated user '%1$s' detected for author of commit %2$s"
,
author
.
getMail
(),
c
.
getHash
()),
c
.
getHash
());
eclipseAuthor
=
EclipseUser
.
createBotStub
(
author
);
}
else
if
(
eclipseAuthor
==
null
)
{
addMessage
(
response
,
String
.
format
(
"Could not find an Eclipse user with mail '%1$s' for author of commit %2$s"
,
author
.
getMail
(),
c
.
getHash
()),
c
.
getHash
());
addError
(
response
,
"Author must have an Eclipse Account"
,
c
.
getHash
());
return
true
;
}
// retrieve the eclipse account for the committer
EclipseUser
eclipseCommitter
=
getIdentifiedUser
(
committer
);
if
(
eclipseCommitter
==
null
)
{
// check if whitelisted or bot
if
(
isAllowedUser
(
committer
.
getMail
()))
{
addMessage
(
response
,
String
.
format
(
"Automated user '%1$s' detected for committer of commit %2$s"
,
committer
.
getMail
(),
c
.
getHash
()),
c
.
getHash
());
eclipseCommitter
=
EclipseUser
.
createBotStub
(
committer
);
}
else
if
(!
userIsABot
(
committer
.
getMail
(),
filteredProjects
))
{
addMessage
(
response
,
String
.
format
(
"Could not find an Eclipse user with mail '%1$s' for committer of commit %2$s"
,
committer
.
getMail
(),
c
.
getHash
()),
c
.
getHash
());
addError
(
response
,
"Committing user must have an Eclipse Account"
,
c
.
getHash
());
return
true
;
}
// set the Eclipse committer as the basic committer w\ bot flag to pass information forward
// check if whitelisted or bot
if
(
isAllowedUser
(
committer
.
getMail
())
||
userIsABot
(
committer
.
getMail
(),
filteredProjects
))
{
addMessage
(
response
,
String
.
format
(
"Automated user '%1$s' detected for committer of commit %2$s"
,
committer
.
getMail
(),
c
.
getHash
()),
c
.
getHash
());
eclipseCommitter
=
EclipseUser
.
createBotStub
(
committer
);
}
else
if
(
eclipseCommitter
==
null
)
{
addMessage
(
response
,
String
.
format
(
"Could not find an Eclipse user with mail '%1$s' for committer of commit %2$s"
,
committer
.
getMail
(),
c
.
getHash
()),
c
.
getHash
());
addError
(
response
,
"Committing user must have an Eclipse Account"
,
c
.
getHash
());
return
true
;
}
// validate author access to the current repo
validateAuthorAccess
(
response
,
c
,
eclipseAuthor
,
filteredProjects
,
provider
);
...
...
@@ -372,6 +364,7 @@ public class ValidationResource {
// check the root email for the bot for match
JsonNode
botmail
=
bot
.
get
(
"email"
);
if
(
mail
!=
null
&&
botmail
!=
null
&&
mail
.
equalsIgnoreCase
(
botmail
.
asText
(
""
)))
{
LOGGER
.
debug
(
"Found matching bot at root level for '{}'"
,
mail
);
return
true
;
}
Iterator
<
Entry
<
String
,
JsonNode
>>
i
=
bot
.
fields
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment