Skip to content

Commit

Permalink
Merge "Merge branch 'release-0.3'"
Browse files Browse the repository at this point in the history
  • Loading branch information
nllptr authored and Gerrit Code Review committed Jan 5, 2015
2 parents 7ae4591 + 01e8c72 commit a3d7924
Show file tree
Hide file tree
Showing 10 changed files with 283 additions and 135 deletions.
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
# Changelog
All notable changes to this project will be documented in this file.

## 0.3 - 2015-01-05
### Added
- Automatic adding of reviewer with merge rights.
- Load balancing reviewers based how many changes one is reviewing.
- Loading animation while waiting for review advice.
- Review advice now loads on demand.

### Fixed
- Incompatible cache files are recalculated.

## 0.2.1 - 2014-12-10
### Fixed
- Review advice output rounding bug. Should now round correctly and output right ammount of sessions.
Expand All @@ -11,4 +21,4 @@ All notable changes to this project will be documented in this file.

## 0.1 - 2014-11-22
### Added
- Basic review time suggestion functionality.
- Basic review time suggestion functionality.
3 changes: 2 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
The MIT License (MIT)

Copyright (c) 2014 Gustav Jansson Ekstrand (gustav.jp@live.se), Simon Wessel (simon.w.karlsson@gmail.com), William Phan (william.da.phan@gmail.com)
Copyright (c) 2014-2015 Gustav Jansson Ekstrand (gustav.jp@live.se), Simon Wessel (simon.w.karlsson@gmail.com),
William Phan (william.da.phan@gmail.com), Sony Mobile Communications

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,22 @@ performed to be as effective as possible. The review time suggestions are based
* No review should be shorter than 5 minutes.
* Five lines per minute is considered to be the optimum review speed.
* Reviewers should not spend more than 60 minutes reviewing. If the review is expected to take longer, it is recommended
to split the review into several sessions.
to split the review into several sessions.

ReviewAssistant is also capable of adding reviewers automatically, based on:

* Git blame
* Submit history - Users with merge rights.
* Open changes - Users with more open changes are less likely to be chosen as reviewer.

## Credits

The rules are based on Jenkins ReviewBuddy by switchgears.

* [ReviewBuddy presentation on slideshare](http://www.slideshare.net/AskeOlsson/jenkins-review-buddy)
* [switchgears on github](https://github.com/switchgears/gerrit-review-buddy)

Other notable sources of inspiration include

* [reviewers-by-blame plugin for Gerrit](https://gerrit.googlesource.com/plugins/reviewers-by-blame/)
* [reviewers plugin for Gerrit](https://gerrit.googlesource.com/plugins/reviewers/)
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<groupId>com.github.nexception.reviewassistant</groupId>
<artifactId>reviewassistant</artifactId>
<packaging>jar</packaging>
<version>0.2.1</version>
<version>0.3</version>
<name>reviewassistant</name>

<properties>
Expand Down Expand Up @@ -61,4 +61,4 @@
<scope>provided</scope>
</dependency>
</dependencies>
</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.google.gerrit.reviewdb.server.ReviewDb;
import com.google.gerrit.server.CurrentUser;
import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.PluginUser;
import com.google.gerrit.server.events.ChangeEvent;
import com.google.gerrit.server.events.PatchSetCreatedEvent;
import com.google.gerrit.server.git.GitRepositoryManager;
Expand Down Expand Up @@ -36,27 +37,27 @@ class ChangeEventListener implements ChangeListener {

private static final Logger log = LoggerFactory.getLogger(ChangeEventListener.class);
private final ReviewAssistant.Factory reviewAssistantFactory;
private Storage storage;
private WorkQueue workQueue;
private GitRepositoryManager repoManager;
private SchemaFactory<ReviewDb> schemaFactory;
private final ThreadLocalRequestContext tl;
private final IdentifiedUser.GenericFactory identifiedUserFactory;
private ReviewDb db;
private final PluginUser pluginUser;
private final IdentifiedUser.GenericFactory identifiedUserFactory;

@Inject
ChangeEventListener(final ReviewAssistant.Factory reviewAssistantFactory, final Storage storage,
ChangeEventListener(final ReviewAssistant.Factory reviewAssistantFactory,
final WorkQueue workQueue, final GitRepositoryManager repoManager,
final SchemaFactory<ReviewDb> schemaFactory,
final IdentifiedUser.GenericFactory identifiedUserFactory,
final ThreadLocalRequestContext tl) {
this.storage = storage;
final ThreadLocalRequestContext tl, final PluginUser pluginUser,
final IdentifiedUser.GenericFactory identifiedUserFactory) {
this.workQueue = workQueue;
this.reviewAssistantFactory = reviewAssistantFactory;
this.repoManager = repoManager;
this.schemaFactory = schemaFactory;
this.identifiedUserFactory = identifiedUserFactory;
this.tl = tl;
this.pluginUser = pluginUser;
this.identifiedUserFactory = identifiedUserFactory;
}

@Override
Expand All @@ -67,11 +68,7 @@ public void onChangeEvent(ChangeEvent changeEvent) {
PatchSetCreatedEvent event = (PatchSetCreatedEvent) changeEvent;
log.info("Received new commit: " + event.patchSet.revision);

//TODO: Move this to the servlet.
storage.storeCalculation(ReviewAssistant.calculate(event));

Project.NameKey projectName = new Project.NameKey(event.change.project);

Repository repo;
try {
repo = repoManager.openRepository(projectName);
Expand Down Expand Up @@ -115,7 +112,11 @@ public void run() {

@Override
public CurrentUser getCurrentUser() {
return identifiedUserFactory.create(change.getOwner());
if(!ReviewAssistant.realUser) {
return pluginUser;
} else {
return identifiedUserFactory.create(change.getOwner());
}
}

@Override
Expand Down
Loading

0 comments on commit a3d7924

Please sign in to comment.