-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #156 from A4Vision/master
Refactor SlackNotificationPayloadContent - extract delegate class
- Loading branch information
Showing
2 changed files
with
251 additions
and
231 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
...core/src/main/java/slacknotifications/teamcity/payload/content/PayloadContentCommits.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package slacknotifications.teamcity.payload.content; | ||
|
||
import jetbrains.buildServer.serverSide.SRunningBuild; | ||
import jetbrains.buildServer.users.SUser; | ||
import jetbrains.buildServer.vcs.SVcsModification; | ||
import slacknotifications.teamcity.Loggers; | ||
import slacknotifications.teamcity.SlackNotificator; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.List; | ||
|
||
public class PayloadContentCommits { | ||
private List<Commit> commits; | ||
|
||
public PayloadContentCommits() { | ||
commits = new ArrayList<Commit>(); | ||
} | ||
|
||
public void populateCommits(SRunningBuild sRunningBuild) { | ||
List<SVcsModification> changes = sRunningBuild.getContainingChanges(); | ||
if (changes == null) { | ||
return; | ||
} | ||
|
||
for (SVcsModification change : changes) { | ||
Collection<SUser> committers = change.getCommitters(); | ||
String slackUserName = null; | ||
if (committers != null && !committers.isEmpty()) { | ||
SUser committer = committers.iterator().next(); | ||
slackUserName = committer.getPropertyValue(SlackNotificator.USERNAME_KEY); | ||
Loggers.ACTIVITIES.debug("Resolved committer " + change.getUserName() + " to Slack User " + slackUserName); | ||
} | ||
commits.add(new Commit(change.getVersion(), change.getDescription(), change.getUserName(), slackUserName)); | ||
} | ||
} | ||
|
||
public List<Commit> getCommits() { | ||
return commits; | ||
} | ||
|
||
public void setCommits(List<Commit> commits) { | ||
this.commits = commits; | ||
} | ||
} |
Oops, something went wrong.