Skip to content

The Unified and Autonomous Development Platform

Branches page draft.

robin shinec598a764ba8f
diff --git a/commons.git/src/main/java/com/pmease/commons/git/Git.java b/commons.git/src/main/java/com/pmease/commons/git/Git.java
index a1537bd0f7..fe5220512d 100644
--- a/commons.git/src/main/java/com/pmease/commons/git/Git.java
+++ b/commons.git/src/main/java/com/pmease/commons/git/Git.java
@@ -98,26 +98,6 @@ public class Git implements Serializable {
return this;
}
- /**
- * Rename specified branch. Default branch will be updated if necessary.
- *
- * @param oldName
- * old name of the branch
- * @param newName
- * new name of the branch
- * @return
- * this git object
- */
- public Git renameBranch(String oldName, String newName) {
- String commitHash = parseRevision(oldName, true);
- createBranch(newName, commitHash);
- if (resolveDefaultBranch().equals(oldName))
- updateDefaultBranch(newName);
- deleteBranch(oldName);
-
- return this;
- }
-
/**
* delete branch even in a bare repository.
*
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/hookcallback/GitPostReceiveCallback.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/hookcallback/GitPostReceiveCallback.java
index 7ccb080580..1b967572e5 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/hookcallback/GitPostReceiveCallback.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/hookcallback/GitPostReceiveCallback.java
@@ -22,7 +22,6 @@ import com.pmease.commons.git.GitUtils;
import com.pmease.commons.hibernate.dao.Dao;
import com.pmease.commons.util.StringUtils;
import com.pmease.gitplex.core.manager.BranchManager;
-import com.pmease.gitplex.core.manager.UserManager;
import com.pmease.gitplex.core.model.Branch;
import com.pmease.gitplex.core.model.Repository;
import com.pmease.gitplex.core.model.User;
@@ -39,13 +38,10 @@ public class GitPostReceiveCallback extends HttpServlet {
private final BranchManager branchManager;
- private final UserManager userManager;
-
@Inject
- public GitPostReceiveCallback(Dao dao, BranchManager branchManager, UserManager userManager) {
+ public GitPostReceiveCallback(Dao dao, BranchManager branchManager) {
this.dao = dao;
this.branchManager = branchManager;
- this.userManager = userManager;
}
@Override
@@ -106,7 +102,6 @@ public class GitPostReceiveCallback extends HttpServlet {
branch.setRepository(repository);
branch.setName(branchName);
branch.setHeadCommitHash(newCommitHash);
- branch.setUpdater(userManager.getCurrent());
repository.getBranches().add(branch);
dao.persist(branch);
if (repository.getBranches().size() == 1)
@@ -115,9 +110,8 @@ public class GitPostReceiveCallback extends HttpServlet {
Branch branch = branchManager.findBy(repository, branchName);
Preconditions.checkNotNull(branch);
- User currentUser = userManager.getCurrent();
repository.getBranches().remove(branch);
- branchManager.delete(branch, currentUser);
+ branchManager.delete(branch);
if (repository.git().resolveDefaultBranch().equals(branchName) && !repository.getBranches().isEmpty())
repository.git().updateDefaultBranch(repository.getBranches().iterator().next().getName());
} else {
@@ -127,7 +121,6 @@ public class GitPostReceiveCallback extends HttpServlet {
Preconditions.checkNotNull(branch);
branch.setHeadCommitHash(newCommitHash);
- branch.setUpdater(userManager.getCurrent());
branchManager.save(branch);
}
}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/BranchManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/BranchManager.java
index 56f8efde1f..00c4a48416 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/BranchManager.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/BranchManager.java
@@ -8,7 +8,6 @@ import com.google.inject.ImplementedBy;
import com.pmease.gitplex.core.manager.impl.DefaultBranchManager;
import com.pmease.gitplex.core.model.Branch;
import com.pmease.gitplex.core.model.Repository;
-import com.pmease.gitplex.core.model.User;
@ImplementedBy(DefaultBranchManager.class)
public interface BranchManager {
@@ -52,10 +51,8 @@ public interface BranchManager {
*
* @param branch
* branch to be deleted
- * @param user
- * user deleting the branch
*/
- public void delete(Branch branch, @Nullable User user);
+ public void delete(Branch branch);
/**
* Create specified branch record in database, and update corresponding git repository to
@@ -68,17 +65,6 @@ public interface BranchManager {
*/
public void create(Branch branch, String commitHash);
- /**
- * Rename specified branch record in database, and update corresponding git repository to
- * reflect the renaming.
- *
- * @param branch
- * branch to be renamed
- * @param newName
- * new name of the branch
- */
- public void rename(Branch branch, String newName);
-
public void save(Branch branch);
public void trim(Collection<Long> branchIds);
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/PullRequestManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/PullRequestManager.java
index 481b9ecbc5..56beb4f9d1 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/PullRequestManager.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/PullRequestManager.java
@@ -31,7 +31,7 @@ public interface PullRequestManager {
*/
void integrate(PullRequest request, @Nullable User user, @Nullable String comment);
- void discard(PullRequest request, User user, @Nullable String comment);
+ void discard(PullRequest request, @Nullable User user, @Nullable String comment);
void onTargetBranchUpdate(PullRequest request);
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultBranchManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultBranchManager.java
index 120904d697..0a9a8bb87e 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultBranchManager.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultBranchManager.java
@@ -18,7 +18,6 @@ import com.pmease.gitplex.core.manager.PullRequestManager;
import com.pmease.gitplex.core.model.Branch;
import com.pmease.gitplex.core.model.PullRequest;
import com.pmease.gitplex.core.model.Repository;
-import com.pmease.gitplex.core.model.User;
@Singleton
public class DefaultBranchManager implements BranchManager {
@@ -52,7 +51,7 @@ public class DefaultBranchManager implements BranchManager {
@Transactional
@Override
- public void delete(Branch branch, User user) {
+ public void delete(Branch branch) {
deleteRefs(branch);
for (PullRequest request: branch.getIncomingRequests()) {
@@ -60,7 +59,7 @@ public class DefaultBranchManager implements BranchManager {
}
for (PullRequest request: branch.getOutgoingRequests()) {
- pullRequestManager.discard(request, user, "Source branch is deleted.");
+ pullRequestManager.discard(request, null, "Source branch is deleted.");
request.setSource(null);
dao.persist(request);
}
@@ -80,16 +79,6 @@ public class DefaultBranchManager implements BranchManager {
branch.getRepository().git().createBranch(branch.getName(), commitHash);
}
- @Transactional
- @Override
- public void rename(final Branch branch, String newName) {
- String oldName = branch.getName();
- branch.setName(newName);
-
- dao.persist(branch);
- branch.getRepository().git().renameBranch(oldName, branch.getName());
- }
-
@Override
public void trim(Collection<Long> branchIds) {
for (Iterator<Long> it = branchIds.iterator(); it.hasNext();) {
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestManager.java
index 890637c6b7..69255f402c 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestManager.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestManager.java
@@ -190,7 +190,6 @@ public class DefaultPullRequestManager implements PullRequestManager {
integrated, preview.getRequestHead(),
"Pull request #" + request.getId())) {
request.getSource().setHeadCommitHash(integrated);
- request.getSource().setUpdater(user);
branchManager.save(request.getSource());
} else {
throw new RuntimeException(String.format(
@@ -200,7 +199,6 @@ public class DefaultPullRequestManager implements PullRequestManager {
if (git.updateRef(request.getTarget().getHeadRef(), integrated,
preview.getTargetHead(), "Pull request #" + request.getId())) {
request.getTarget().setHeadCommitHash(integrated);
- request.getTarget().setUpdater(user);
branchManager.save(request.getTarget());
PullRequestAudit audit = new PullRequestAudit();
@@ -314,7 +312,6 @@ public class DefaultPullRequestManager implements PullRequestManager {
audit.setRequest(request);
audit.setOperation(PullRequestOperation.INTEGRATE);
audit.setDate(new Date());
- audit.setUser(request.getTarget().getUpdater());
dao.persist(audit);
request.setIntegrationPreview(null);
@@ -346,9 +343,11 @@ public class DefaultPullRequestManager implements PullRequestManager {
@Transactional
@Override
public void onSourceBranchUpdate(PullRequest request) {
+ if (request.getLatestUpdate().getHeadCommitHash().equals(request.getSource().getHeadCommitHash()))
+ return;
+
PullRequestUpdate update = new PullRequestUpdate();
update.setRequest(request);
- update.setUser(request.getSource().getUpdater());
update.setDate(new Date());
update.setHeadCommitHash(request.getSource().getHeadCommitHash());
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultRepositoryManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultRepositoryManager.java
index 27f2b021e2..11b6e8869a 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultRepositoryManager.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultRepositoryManager.java
@@ -208,7 +208,7 @@ public class DefaultRepositoryManager implements RepositoryManager {
if (branchesInGit.containsKey(branch.getName())) {
branchesInDB.put(branch.getName(), branch);
} else {
- branchManager.delete(branch, null);
+ branchManager.delete(branch);
it.remove();
}
}
@@ -220,17 +220,31 @@ public class DefaultRepositoryManager implements RepositoryManager {
branch.setName(entry.getKey());
branch.setHeadCommitHash(entry.getValue());
branch.setRepository(repository);
- dao.persist(branch);
+ repository.getBranches().add(branch);
+ branchManager.save(branch);
} else if (!branch.getHeadCommitHash().equals(entry.getValue())) {
branch.setHeadCommitHash(entry.getValue());
- branch.setUpdater(null);
- dao.persist(branch);
+ branchManager.save(branch);
}
}
String defaultBranchName = repository.git().resolveDefaultBranch();
- if (!branchesInGit.isEmpty() && !branchesInGit.containsKey(defaultBranchName))
- repository.git().updateDefaultBranch(branchesInGit.keySet().iterator().next());
+ if (!branchesInGit.isEmpty() && !branchesInGit.containsKey(defaultBranchName)) {
+ defaultBranchName = branchesInGit.keySet().iterator().next();
+ repository.git().updateDefaultBranch(defaultBranchName);
+ }
+
+ for (Branch branch: repository.getBranches()) {
+ if (branch.getName().equals(defaultBranchName)) {
+ if (!branch.isDefault()) {
+ branch.setDefault(true);
+ branchManager.save(branch);
+ }
+ } else if (branch.isDefault()) {
+ branch.setDefault(false);
+ branchManager.save(branch);
+ }
+ }
}
}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultUserManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultUserManager.java
index a067881169..098e08d1f2 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultUserManager.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultUserManager.java
@@ -12,7 +12,6 @@ import javax.transaction.Status;
import javax.transaction.Synchronization;
import org.hibernate.ReplicationMode;
-import org.hibernate.criterion.Restrictions;
import com.google.common.base.Preconditions;
import com.google.common.collect.BiMap;
@@ -21,12 +20,9 @@ import com.google.common.collect.Lists;
import com.pmease.commons.hibernate.Sessional;
import com.pmease.commons.hibernate.Transactional;
import com.pmease.commons.hibernate.dao.Dao;
-import com.pmease.commons.hibernate.dao.EntityCriteria;
import com.pmease.gitplex.core.manager.UserManager;
-import com.pmease.gitplex.core.model.Branch;
import com.pmease.gitplex.core.model.Membership;
import com.pmease.gitplex.core.model.PullRequest;
-import com.pmease.gitplex.core.model.PullRequestUpdate;
import com.pmease.gitplex.core.model.Team;
import com.pmease.gitplex.core.model.User;
import com.pmease.gitplex.core.permission.operation.GeneralOperation;
@@ -119,16 +115,6 @@ public class DefaultUserManager implements UserManager {
dao.persist(request);
}
- for (PullRequestUpdate update: user.getUpdates()) {
- update.setUser(null);
- dao.persist(update);
- }
-
- for (Branch branch: dao.query(EntityCriteria.of(Branch.class).add(Restrictions.eq("updater", user)))) {
- branch.setUpdater(null);
- dao.persist(branch);
- }
-
dao.remove(user);
dao.getSession().getTransaction().registerSynchronization(new Synchronization() {
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/model/Branch.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/model/Branch.java
index 9ee1f38ff2..087c4d44e7 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/model/Branch.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/model/Branch.java
@@ -31,15 +31,23 @@ public class Branch extends AbstractEntity {
@Column(nullable=false)
private String name;
+ private boolean isDefault;
+
@ManyToOne
private User updater;
@OneToMany(mappedBy="target", cascade=CascadeType.REMOVE)
- private Collection<PullRequest> incomingRequests = new ArrayList<PullRequest>();
+ private Collection<PullRequest> incomingRequests = new ArrayList<>();
@OneToMany(mappedBy="source")
- private Collection<PullRequest> outgoingRequests = new ArrayList<PullRequest>();
+ private Collection<PullRequest> outgoingRequests = new ArrayList<>();
+ @OneToMany(mappedBy="branch", cascade=CascadeType.REMOVE)
+ private Collection<CommitWatch> commitWatches = new ArrayList<>();
+
+ @OneToMany(mappedBy="branch", cascade=CascadeType.REMOVE)
+ private Collection<PullRequestWatch> requestWatches = new ArrayList<>();
+
private String headCommitHash;
public Repository getRepository() {
@@ -58,21 +66,6 @@ public class Branch extends AbstractEntity {
this.name = name;
}
- /**
- * Get user who updates this branch ref last time.
- *
- * @return
- * <tt>null</tt> if updater is unknown
- */
- @Nullable
- public User getUpdater() {
- return updater;
- }
-
- public void setUpdater(User updater) {
- this.updater = updater;
- }
-
public Collection<PullRequest> getIncomingRequests() {
return incomingRequests;
}
@@ -89,7 +82,23 @@ public class Branch extends AbstractEntity {
this.outgoingRequests = outgoingRequests;
}
- /**
+ public Collection<CommitWatch> getCommitWatches() {
+ return commitWatches;
+ }
+
+ public void setCommitWatches(Collection<CommitWatch> commitWatches) {
+ this.commitWatches = commitWatches;
+ }
+
+ public Collection<PullRequestWatch> getRequestWatches() {
+ return requestWatches;
+ }
+
+ public void setRequestWatches(Collection<PullRequestWatch> requestWatches) {
+ this.requestWatches = requestWatches;
+ }
+
+ /**
* Get head commit this branch pointing to.
*
* @return
@@ -115,7 +124,15 @@ public class Branch extends AbstractEntity {
return getRepository().getFullName() + ":" + getName();
}
- /**
+ public boolean isDefault() {
+ return isDefault;
+ }
+
+ public void setDefault(boolean isDefault) {
+ this.isDefault = isDefault;
+ }
+
+ /**
* Convert a git reference name to branch name.
*
* @param refName
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/model/ChangeSubscription.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/model/ChangeSubscription.java
deleted file mode 100644
index b34a859548..0000000000
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/model/ChangeSubscription.java
+++ /dev/null
@@ -1,77 +0,0 @@
-package com.pmease.gitplex.core.model;
-
-import java.io.Serializable;
-
-import javax.validation.Valid;
-import javax.validation.constraints.NotNull;
-
-import com.pmease.commons.editable.annotation.Editable;
-import com.pmease.commons.editable.annotation.Horizontal;
-import com.pmease.gitplex.core.branchmatcher.GlobalBranchMatcher;
-
-@SuppressWarnings("serial")
-@Editable
-@Horizontal
-public class ChangeSubscription implements Serializable {
-
- public enum Source {
- COMMIT("Notify about commits made to specified branch and path"),
- PULL_REQUEST("Notify about pull requests submitted to specified branch and path"),
- BOTH("Notify about both commits and pull requests");
-
- private final String description;
-
- private Source(String description) {
- this.description = description;
- }
-
- @Override
- public String toString() {
- return description;
- }
-
- };
-
- private GlobalBranchMatcher branches;
-
- private String paths;
-
- private Source source;
-
- @Editable(name="Branches", order=100, description="Specify branches to get change notifications about, "
- + "including pull requests, commits, and relevant action/comments.")
- @NotNull
- @Valid
- public GlobalBranchMatcher getBranches() {
- return branches;
- }
-
- public void setBranches(GlobalBranchMatcher branches) {
- this.branches = branches;
- }
-
- @Editable(name="Path Patterns", order=200, description="Optionally specify "
- + "<a href='http://wiki.pmease.com/display/gp/Pattern+Set'>path patterns</a> to filter change "
- + "notifications. For instance, Specifying this field as <em>module1/**</em> tells GitPlex to "
- + "only send notificiations if the change (pull request or commit) touches any file under "
- + "<em>module1</em>. If not specified, notification will be sent for all changes of specified "
- + "branches.")
- public String getPaths() {
- return paths;
- }
-
- public void setPaths(String paths) {
- this.paths = paths;
- }
-
- @Editable(name="Notification Source", order=300)
- @NotNull
- public Source getSource() {
- return source;
- }
-
- public void setSource(Source source) {
- this.source = source;
- }
-
-}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/model/CommitWatch.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/model/CommitWatch.java
new file mode 100644
index 0000000000..c0b02a4933
--- /dev/null
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/model/CommitWatch.java
@@ -0,0 +1,36 @@
+package com.pmease.gitplex.core.model;
+
+import javax.persistence.Entity;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+
+import com.pmease.commons.hibernate.AbstractEntity;
+
+@SuppressWarnings("serial")
+@Entity
+public class CommitWatch extends AbstractEntity {
+
+ @ManyToOne
+ @JoinColumn(nullable=false)
+ private Branch branch;
+
+ public Branch getBranch() {
+ return branch;
+ }
+
+ public void setBranch(Branch branch) {
+ this.branch = branch;
+ }
+
+ @ManyToOne
+ @JoinColumn(nullable=false)
+ private User user;
+
+ public User getUser() {
+ return user;
+ }
+
+ public void setUser(User user) {
+ this.user = user;
+ }
+}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/model/PullRequestComment.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/model/PullRequestComment.java
index 343a4a46f7..a7811d3b91 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/model/PullRequestComment.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/model/PullRequestComment.java
@@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
+import javax.annotation.Nullable;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
@@ -34,7 +35,6 @@ public class PullRequestComment extends AbstractEntity implements InlineComment
private PullRequest request;
@ManyToOne
- @JoinColumn(nullable=false)
private User user;
@Column(nullable=false)
@@ -58,11 +58,12 @@ public class PullRequestComment extends AbstractEntity implements InlineComment
this.request = request;
}
+ @Nullable
public User getUser() {
return user;
}
- public void setUser(User user) {
+ public void setUser(@Nullable User user) {
this.user = user;
}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/model/PullRequestUpdate.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/model/PullRequestUpdate.java
index e880d39288..4c58a9dfdd 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/model/PullRequestUpdate.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/model/PullRequestUpdate.java
@@ -12,7 +12,6 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;
-import javax.annotation.Nullable;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
@@ -39,9 +38,6 @@ public class PullRequestUpdate extends AbstractEntity {
@Column(nullable=false)
private String headCommitHash;
- @ManyToOne
- private User user;
-
@Column(nullable=false)
private Date date;
@@ -68,15 +64,6 @@ public class PullRequestUpdate extends AbstractEntity {
this.headCommitHash = headCommitHash;
}
- @Nullable
- public User getUser() {
- return user;
- }
-
- public void setUser(User user) {
- this.user = user;
- }
-
public Date getDate() {
return date;
}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/model/PullRequestWatch.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/model/PullRequestWatch.java
new file mode 100644
index 0000000000..4b18424c98
--- /dev/null
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/model/PullRequestWatch.java
@@ -0,0 +1,36 @@
+package com.pmease.gitplex.core.model;
+
+import javax.persistence.Entity;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+
+import com.pmease.commons.hibernate.AbstractEntity;
+
+@SuppressWarnings("serial")
+@Entity
+public class PullRequestWatch extends AbstractEntity {
+
+ @ManyToOne
+ @JoinColumn(nullable=false)
+ private Branch branch;
+
+ public Branch getBranch() {
+ return branch;
+ }
+
+ public void setBranch(Branch branch) {
+ this.branch = branch;
+ }
+
+ @ManyToOne
+ @JoinColumn(nullable=false)
+ private User user;
+
+ public User getUser() {
+ return user;
+ }
+
+ public void setUser(User user) {
+ this.user = user;
+ }
+}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/model/Repository.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/model/Repository.java
index 0b8c5b9aa6..08cfd1d624 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/model/Repository.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/model/Repository.java
@@ -71,8 +71,6 @@ public class Repository extends AbstractEntity implements UserBelonging {
private String description;
- private transient String defaultBranch;
-
@Lob
@Column(nullable=false)
private ArrayList<GateKeeper> gateKeepers = new ArrayList<>();
@@ -337,17 +335,19 @@ public class Repository extends AbstractEntity implements UserBelonging {
return GitPlex.getInstance().getServerUrl() + "/" + getFullName();
}
- public String getDefaultBranch() {
- if (defaultBranch == null)
- defaultBranch = git().resolveDefaultBranch();
- return defaultBranch;
+ public Branch getDefaultBranch() {
+ for (Branch branch: getBranches()) {
+ if (branch.isDefault())
+ return branch;
+ }
+ throw new IllegalStateException();
}
public String defaultBranchIfNull(@Nullable String revision) {
if (revision != null)
return revision;
else
- return getDefaultBranch();
+ return getDefaultBranch().getName();
}
/**
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/model/User.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/model/User.java
index 7b51ab7afe..0076eae337 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/model/User.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/model/User.java
@@ -8,7 +8,6 @@ import java.util.Date;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
-import javax.persistence.Lob;
import javax.persistence.OneToMany;
import org.eclipse.jgit.lib.PersonIdent;
@@ -71,11 +70,13 @@ public class User extends AbstractUser implements ProtectedObject {
@OneToMany(mappedBy="user", cascade=CascadeType.REMOVE)
private Collection<PullRequestCommentReply> requestCommentReplies = new ArrayList<>();
- @Lob
- @Column(nullable=false)
- private ArrayList<ChangeSubscription> changeSubscriptions = new ArrayList<>();
+ @OneToMany(mappedBy="user", cascade=CascadeType.REMOVE)
+ private Collection<CommitWatch> commitWatches = new ArrayList<>();
- @Editable(order=100)
+ @OneToMany(mappedBy="user", cascade=CascadeType.REMOVE)
+ private Collection<PullRequestWatch> requestWatches = new ArrayList<>();
+
+ @Editable(order=100)
@UserName
@NotEmpty
@Override
@@ -209,17 +210,25 @@ public class User extends AbstractUser implements ProtectedObject {
return requestCommentReplies;
}
- public void setCommentReplies(Collection<PullRequestCommentReply> requestCommentReplies) {
+ public void setRequestCommentReplies(
+ Collection<PullRequestCommentReply> requestCommentReplies) {
this.requestCommentReplies = requestCommentReplies;
}
- public ArrayList<ChangeSubscription> getChangeSubscriptions() {
- return changeSubscriptions;
+ public Collection<CommitWatch> getCommitWatches() {
+ return commitWatches;
+ }
+
+ public void setCommitWatches(Collection<CommitWatch> commitWatches) {
+ this.commitWatches = commitWatches;
+ }
+
+ public Collection<PullRequestWatch> getRequestWatches() {
+ return requestWatches;
}
- public void setChangeSubscriptions(
- ArrayList<ChangeSubscription> changeSubscriptions) {
- this.changeSubscriptions = changeSubscriptions;
+ public void setRequestWatches(Collection<PullRequestWatch> requestWatches) {
+ this.requestWatches = requestWatches;
}
@Override
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/GitPlexMappings.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/GitPlexMappings.java
index 6a9c93bd8c..5933b72185 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/GitPlexMappings.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/GitPlexMappings.java
@@ -21,7 +21,6 @@ import com.pmease.gitplex.web.page.account.MemberSettingPage;
import com.pmease.gitplex.web.page.account.RegisterPage;
import com.pmease.gitplex.web.page.account.repository.NewRepositoryPage;
import com.pmease.gitplex.web.page.account.repository.RepositoriesPage;
-import com.pmease.gitplex.web.page.account.subscription.ChangeSubscriptionPage;
import com.pmease.gitplex.web.page.account.team.AccountTeamsPage;
import com.pmease.gitplex.web.page.account.team.AddTeamPage;
import com.pmease.gitplex.web.page.account.team.EditTeamPage;
@@ -113,7 +112,6 @@ public class GitPlexMappings extends CompoundRequestMapper {
addPage("${user}/settings/teams", AccountTeamsPage.class);
addPage("${user}/settings/teams/new", AddTeamPage.class);
addPage("${user}/settings/teams/${teamId}", EditTeamPage.class);
- addPage("${user}/settings/subscriptions", ChangeSubscriptionPage.class);
}
private void addRepositoryPages() {
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/account/AccountPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/account/AccountPage.java
index 85c9936a67..0622adf09a 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/account/AccountPage.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/account/AccountPage.java
@@ -25,7 +25,6 @@ import com.pmease.gitplex.web.component.user.AvatarMode;
import com.pmease.gitplex.web.component.user.UserLink;
import com.pmease.gitplex.web.model.UserModel;
import com.pmease.gitplex.web.page.account.repository.RepositoriesPage;
-import com.pmease.gitplex.web.page.account.subscription.ChangeSubscriptionPage;
import com.pmease.gitplex.web.page.account.team.AccountTeamsPage;
import com.pmease.gitplex.web.page.account.team.EditTeamPage;
@@ -47,7 +46,6 @@ public abstract class AccountPage extends AccountBasePage {
tabs.add(new AccountTab(Model.of("Repositories"), "fa fa-repo", RepositoriesPage.class));
tabs.add(new AccountTab(Model.of("Teams"), "fa fa-group-o", AccountTeamsPage.class, EditTeamPage.class));
tabs.add(new AccountTab(Model.of("Members"), "fa fa-user-o", MemberSettingPage.class));
- tabs.add(new AccountTab(Model.of("Subscriptions"), "fa fa-eye-open", ChangeSubscriptionPage.class));
tabs.add(new AccountTab(Model.of("Profile"), "fa fa-gear", AccountProfilePage.class));
add(new Tabbable("tabs", tabs));
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/account/subscription/ChangeSubscriptionEditor.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/account/subscription/ChangeSubscriptionEditor.html
deleted file mode 100644
index b9fc15e2fa..0000000000
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/account/subscription/ChangeSubscriptionEditor.html
+++ /dev/null
@@ -1,10 +0,0 @@
-<wicket:panel>
- <form wicket:id="form">
- <div wicket:id="feedback"></div>
- <div wicket:id="editor"></div>
- <div class="submits">
- <button wicket:id="save" class="btn btn-primary dirty-aware">Save</button> &nbsp;
- <button wicket:id="cancel" class="btn btn-default">Cancel</button>
- </div>
- </form>
-</wicket:panel>
\ No newline at end of file
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/account/subscription/ChangeSubscriptionEditor.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/account/subscription/ChangeSubscriptionEditor.java
deleted file mode 100644
index 6dcb7cf2c8..0000000000
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/account/subscription/ChangeSubscriptionEditor.java
+++ /dev/null
@@ -1,62 +0,0 @@
-package com.pmease.gitplex.web.page.account.subscription;
-
-import org.apache.wicket.ajax.AjaxRequestTarget;
-import org.apache.wicket.ajax.markup.html.AjaxLink;
-import org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink;
-import org.apache.wicket.markup.html.form.Form;
-import org.apache.wicket.markup.html.panel.Panel;
-
-import com.pmease.commons.wicket.component.feedback.FeedbackPanel;
-import com.pmease.commons.wicket.editable.BeanContext;
-import com.pmease.gitplex.core.model.ChangeSubscription;
-
-@SuppressWarnings("serial")
-abstract class ChangeSubscriptionEditor extends Panel {
-
- private final ChangeSubscription subscription;
-
- public ChangeSubscriptionEditor(String id, ChangeSubscription subscription) {
- super(id);
-
- this.subscription = subscription;
- }
-
- @Override
- protected void onInitialize() {
- super.onInitialize();
-
- setOutputMarkupId(true);
-
- Form<?> form = new Form<Void>("form");
- form.add(new FeedbackPanel("feedback", form));
- form.add(BeanContext.editBean("editor", subscription));
- form.add(new AjaxSubmitLink("save") {
-
- @Override
- protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
- super.onSubmit(target, form);
- onSave(target, subscription);
- }
-
- @Override
- protected void onError(AjaxRequestTarget target, Form<?> form) {
- super.onError(target, form);
- target.add(form);
- }
-
- });
- form.add(new AjaxLink<Void>("cancel") {
-
- @Override
- public void onClick(AjaxRequestTarget target) {
- onCancel(target);
- }
-
- });
- add(form);
- }
-
- protected abstract void onSave(AjaxRequestTarget target, ChangeSubscription subscription);
-
- protected abstract void onCancel(AjaxRequestTarget target);
-}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/account/subscription/ChangeSubscriptionPage.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/account/subscription/ChangeSubscriptionPage.html
deleted file mode 100644
index 443550a5aa..0000000000
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/account/subscription/ChangeSubscriptionPage.html
+++ /dev/null
@@ -1,29 +0,0 @@
-<html xmlns:wicket>
-<wicket:extend>
- <section wicket:id="changeSubscriptions" class="change-subscriptions">
- <div class="head">Change Subscriptions</div>
- <div class="body">
- <ul class="list-unstyled subscriptions">
- <li wicket:id="subscriptions"><div wicket:id="subscription"></div></li>
- </ul>
- <div wicket:id="newSubscription"></div>
- <div class="help-block"><i class="fa fa-light-bulb fa-lg"></i>
- <p>Define change subscriptions here if you want to be notified of commits or pull requests
- of specified branch and path. If a change matches multiple subscriptions, the first matched
- subscription will be used.</p>
- </div>
- </div>
- </section>
- <wicket:fragment wicket:id="editNewFrag">
- <div class="subscription panel panel-default">
- <div class="panel-heading"><div class="panel-title">Add New Subscription</div></div>
- <div class="panel-body">
- <div wicket:id="editor"></div>
- </div>
- </div>
- </wicket:fragment>
- <wicket:fragment wicket:id="addNewLinkFrag">
- <a wicket:id="link" class="add-new">Add Subscription <i class="fa fa-plus-round fa-lg"></i></a>
- </wicket:fragment>
-</wicket:extend>
-</html>
\ No newline at end of file
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/account/subscription/ChangeSubscriptionPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/account/subscription/ChangeSubscriptionPage.java
deleted file mode 100644
index 0538e88d5d..0000000000
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/account/subscription/ChangeSubscriptionPage.java
+++ /dev/null
@@ -1,133 +0,0 @@
-package com.pmease.gitplex.web.page.account.subscription;
-
-import java.util.List;
-
-import org.apache.shiro.SecurityUtils;
-import org.apache.wicket.Component;
-import org.apache.wicket.ajax.AjaxRequestTarget;
-import org.apache.wicket.ajax.markup.html.AjaxLink;
-import org.apache.wicket.markup.html.WebMarkupContainer;
-import org.apache.wicket.markup.html.list.ListItem;
-import org.apache.wicket.markup.html.list.ListView;
-import org.apache.wicket.markup.html.panel.Fragment;
-import org.apache.wicket.model.AbstractReadOnlyModel;
-import org.apache.wicket.request.mapper.parameter.PageParameters;
-
-import com.pmease.commons.wicket.behavior.sortable.SortBehavior;
-import com.pmease.commons.wicket.behavior.sortable.SortPosition;
-import com.pmease.gitplex.core.GitPlex;
-import com.pmease.gitplex.core.manager.UserManager;
-import com.pmease.gitplex.core.model.ChangeSubscription;
-import com.pmease.gitplex.core.permission.ObjectPermission;
-import com.pmease.gitplex.web.page.account.AccountPage;
-
-@SuppressWarnings("serial")
-public class ChangeSubscriptionPage extends AccountPage {
-
- private WebMarkupContainer container;
-
- public ChangeSubscriptionPage(PageParameters params) {
- super(params);
- }
-
- @Override
- protected void onInitialize() {
- super.onInitialize();
-
- container = new WebMarkupContainer("changeSubscriptions");
- container.setOutputMarkupId(true);
- add(container);
- container.add(new ListView<ChangeSubscription>("subscriptions", new AbstractReadOnlyModel<List<ChangeSubscription>>() {
-
- @Override
- public List<ChangeSubscription> getObject() {
- return getAccount().getChangeSubscriptions();
- }
- }) {
-
- @Override
- protected void populateItem(final ListItem<ChangeSubscription> item) {
- item.add(new ChangeSubscriptionPanel("subscription", item.getModelObject()) {
-
- @Override
- protected void onDelete(AjaxRequestTarget target) {
- getAccount().getChangeSubscriptions().remove(item.getIndex());
- GitPlex.getInstance(UserManager.class).save(getAccount());
- target.add(container);
- }
-
- @Override
- protected void onSave(AjaxRequestTarget target, ChangeSubscription subscription) {
- getAccount().getChangeSubscriptions().set(item.getIndex(), subscription);
- GitPlex.getInstance(UserManager.class).save(getAccount());
- }
-
- });
- }
-
- });
-
- container.add(new SortBehavior() {
-
- @Override
- protected void onSort(AjaxRequestTarget target, SortPosition from, SortPosition to) {
- List<ChangeSubscription> subscriptions = getAccount().getChangeSubscriptions();
- ChangeSubscription subscription = subscriptions.get(from.getItemIndex());
- subscriptions.set(from.getItemIndex(), subscriptions.set(to.getItemIndex(), subscription));
- GitPlex.getInstance(UserManager.class).save(getAccount());
-
- target.add(container);
- }
-
- }.handle(".handle").items("li"));
-
- container.add(newAddNewFrag());
- }
-
- private Component newAddNewFrag() {
- Fragment fragment = new Fragment("newSubscription", "addNewLinkFrag", this);
- fragment.add(new AjaxLink<Void>("link") {
-
- @Override
- public void onClick(AjaxRequestTarget target) {
- Fragment fragment = new Fragment("newSubscription", "editNewFrag", getPage());
- fragment.setOutputMarkupId(true);
- fragment.add(new ChangeSubscriptionEditor("editor", new ChangeSubscription()) {
-
- @Override
- protected void onSave(AjaxRequestTarget target, ChangeSubscription subscription) {
- getAccount().getChangeSubscriptions().add(subscription);
- GitPlex.getInstance(UserManager.class).save(getAccount());
- container.replace(newAddNewFrag());
- target.add(container);
- }
-
- @Override
- protected void onCancel(AjaxRequestTarget target) {
- Component newAddNewFrag = newAddNewFrag();
- container.replace(newAddNewFrag);
- target.add(newAddNewFrag);
- }
-
- });
- container.replace(fragment);
- target.add(fragment);
- }
-
- });
- fragment.setOutputMarkupId(true);
- return fragment;
- }
-
- @Override
- protected String getPageTitle() {
- return "Change Subscriptions - " + getAccount();
- }
-
- @Override
- protected boolean isPermitted() {
- return super.isPermitted()
- && SecurityUtils.getSubject().isPermitted(ObjectPermission.ofUserAdmin(getAccount()));
- }
-
-}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/account/subscription/ChangeSubscriptionPanel.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/account/subscription/ChangeSubscriptionPanel.html
deleted file mode 100644
index f8b7f5597b..0000000000
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/account/subscription/ChangeSubscriptionPanel.html
+++ /dev/null
@@ -1,12 +0,0 @@
-<wicket:panel>
- <div class="policy panel panel-default">
- <div class="panel-heading">
- <span class="handle" title="Drag to reorder subscriptions"><i class="fa fa-grip fa-lg"></i></span>
- <a wicket:id="edit" title="Edit this subscription"><i class="fa fa-pencil fa"></i></a>
- <a wicket:id="delete" title="Delete this subscription"><i class="fa fa-times fa-lg"></i></a>
- </div>
- <div class="panel-body">
- <div wicket:id="subscription"></div>
- </div>
- </div>
-</wicket:panel>
\ No newline at end of file
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/account/subscription/ChangeSubscriptionPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/account/subscription/ChangeSubscriptionPanel.java
deleted file mode 100644
index 6ed86e590e..0000000000
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/account/subscription/ChangeSubscriptionPanel.java
+++ /dev/null
@@ -1,71 +0,0 @@
-package com.pmease.gitplex.web.page.account.subscription;
-
-import org.apache.wicket.Component;
-import org.apache.wicket.ajax.AjaxRequestTarget;
-import org.apache.wicket.ajax.markup.html.AjaxLink;
-import org.apache.wicket.markup.html.panel.Panel;
-
-import com.pmease.commons.wicket.behavior.ConfirmBehavior;
-import com.pmease.commons.wicket.editable.BeanContext;
-import com.pmease.gitplex.core.model.ChangeSubscription;
-
-@SuppressWarnings("serial")
-abstract class ChangeSubscriptionPanel extends Panel {
-
- private final ChangeSubscription subscription;
-
- public ChangeSubscriptionPanel(String id, ChangeSubscription subscription) {
- super(id);
-
- this.subscription = subscription;
- }
-
- @Override
- protected void onInitialize() {
- super.onInitialize();
-
- add(new AjaxLink<Void>("edit") {
-
- @Override
- public void onClick(AjaxRequestTarget target) {
- ChangeSubscriptionEditor editor = new ChangeSubscriptionEditor("subscription", subscription) {
-
- @Override
- protected void onSave(AjaxRequestTarget target, ChangeSubscription subscription) {
- ChangeSubscriptionPanel.this.onSave(target, subscription);
- Component subscriptionViewer = BeanContext.viewBean("subscription", subscription).setOutputMarkupId(true);
- ChangeSubscriptionPanel.this.replace(subscriptionViewer);
- target.add(subscriptionViewer);
- }
-
- @Override
- protected void onCancel(AjaxRequestTarget target) {
- Component subscriptionViewer = BeanContext.viewBean("subscription", subscription).setOutputMarkupId(true);
- ChangeSubscriptionPanel.this.replace(subscriptionViewer);
- target.add(subscriptionViewer);
- }
-
- };
- ChangeSubscriptionPanel.this.replace(editor);
- target.add(editor);
- }
-
- });
-
- add(new AjaxLink<Void>("delete") {
-
- @Override
- public void onClick(AjaxRequestTarget target) {
- onDelete(target);
- }
-
- }.add(new ConfirmBehavior("Do you really want to delete this subscription?")));
-
- add(BeanContext.viewBean("subscription", subscription).setOutputMarkupId(true));
- }
-
- protected abstract void onDelete(AjaxRequestTarget target);
-
- protected abstract void onSave(AjaxRequestTarget target, ChangeSubscription subscription);
-
-}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/RepositoryPage.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/RepositoryPage.html
index b034af9e2d..c7672971a6 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/RepositoryPage.html
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/RepositoryPage.html
@@ -18,7 +18,6 @@
<li>
<div class="btn-group">
<a class="btn btn-default popup-marker"><i class="fa fa-download"></i> Clone <span class="caret"></span></a>
- <a class="btn btn-default"><i class="fa fa-eye-open"></i> Watch <span class="caret"></span></a>
<a wicket:id="forkRepo" class="btn btn-default"><i class="fa fa-branch-add"></i> Fork</a>
<a class="btn btn-default"><i class="fa fa-branch-compare"></i> Compare</a>
</div>
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/admin/GeneralSettingPage.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/admin/GeneralSettingPage.html
index 1c56e9f291..73cbe6ad95 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/admin/GeneralSettingPage.html
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/admin/GeneralSettingPage.html
@@ -28,8 +28,6 @@
<div wicket:id="name"></div>
<div wicket:id="description"></div>
<hr />
- <div wicket:id="defaultBranch"></div>
- <hr />
<div wicket:id="forkable"></div>
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/admin/GeneralSettingPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/admin/GeneralSettingPage.java
index 68a9394260..1c0c62dcdd 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/admin/GeneralSettingPage.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/admin/GeneralSettingPage.java
@@ -1,7 +1,5 @@
package com.pmease.gitplex.web.page.repository.admin;
-import java.util.List;
-
import org.apache.commons.io.FileUtils;
import org.apache.shiro.SecurityUtils;
import org.apache.wicket.ajax.AjaxRequestTarget;
@@ -12,7 +10,6 @@ import org.apache.wicket.feedback.ComponentFeedbackMessageFilter;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.model.AbstractReadOnlyModel;
-import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.model.PropertyModel;
import org.apache.wicket.request.mapper.parameter.PageParameters;
@@ -22,9 +19,6 @@ import org.apache.wicket.validation.IValidator;
import org.apache.wicket.validation.ValidationError;
import com.google.common.base.Objects;
-import com.google.common.base.Strings;
-import com.google.common.collect.Lists;
-import com.pmease.commons.git.Git;
import com.pmease.commons.wicket.behavior.ConfirmBehavior;
import com.pmease.commons.wicket.component.feedback.FeedbackPanel;
import com.pmease.gitplex.core.GitPlex;
@@ -33,7 +27,6 @@ import com.pmease.gitplex.core.model.Repository;
import com.pmease.gitplex.core.permission.ObjectPermission;
import com.pmease.gitplex.web.common.quantity.Data;
import com.pmease.gitplex.web.common.wicket.form.checkbox.CheckBoxElement;
-import com.pmease.gitplex.web.common.wicket.form.select.DropDownChoiceElement;
import com.pmease.gitplex.web.common.wicket.form.textfield.TextFieldElement;
import com.pmease.gitplex.web.page.account.AccountHomePage;
import com.pmease.gitplex.web.page.repository.RepositoryPage;
@@ -46,7 +39,6 @@ public class GeneralSettingPage extends RepositoryPage {
}
private String repositoryName;
- private String defaultBranchName;
@Override
protected void onInitialize() {
@@ -108,27 +100,6 @@ public class GeneralSettingPage extends RepositoryPage {
new PropertyModel<Boolean>(repoModel, "forkable"),
Model.of("Enable/Disable whether this repository can be forked by others")));
- // Default branch is recorded in HEAD ref of the repository, since no any branches exist in
- // repository when it is created, it might be more appropriate to assign default branch directly
- // via branches page.
- IModel<List<? extends String>> branchesModel = new AbstractReadOnlyModel<List<? extends String>>() {
-
- @Override
- public List<String> getObject() {
- Repository repository = getRepository();
- Git git = repository.git();
- return Lists.newArrayList(git.listBranches().keySet());
- }
- };
-
- defaultBranchName = getRepository().git().resolveDefaultBranch();
- form.add(new DropDownChoiceElement<String>(
- "defaultBranch",
- "Default Branch",
- new PropertyModel<String>(this, "defaultBranchName"),
- branchesModel)
- .setHelp("Set default branch for browsing. By default, it is \"master\"." ));
-
form.add(new AjaxButton("submit", form) {
@Override
protected void onError(AjaxRequestTarget target, Form<?> form) {
@@ -142,11 +113,6 @@ public class GeneralSettingPage extends RepositoryPage {
if (nameChanged) {
repository.setName(repositoryName);
}
-// repository.setDefaultBranchName(defaultBranch);
-
- if (!Strings.isNullOrEmpty(defaultBranchName)) {
- repository.git().updateDefaultBranch(defaultBranchName);
- }
GitPlex.getInstance(RepositoryManager.class).save(repository);
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/code/branches/BranchesPage.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/code/branches/BranchesPage.html
index 7da790279c..23b3bd63be 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/code/branches/BranchesPage.html
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/code/branches/BranchesPage.html
@@ -21,7 +21,10 @@
<td class="">
</td>
<td class="actions">
- Base branch
+ <button wicket:id="unwatchCommits" class="btn btn-default" title="You are watching commits of this branch, click to unwatch"><i class="fa fa-eye-open"></i> <i class="fa fa-commit"></i> </button>
+ <button wicket:id="unwatchRequests" class="btn btn-default" title="You are watching pull requests of this branch, click to unwatch"><i class="fa fa-eye-open"></i> <i class="fa fa-branch-merge"></i> </button>
+ <button wicket:id="watchCommits" class="btn btn-default" title="You are not watching commits of this branch, click to watch"><i class="fa fa-eye-slash"></i> <i class="fa fa-commit"></i> </button>
+ <button wicket:id="watchRequests" class="btn btn-default" title="You are not watching pull requests of this branch, click to watch"><i class="fa fa-eye-slash"></i> <i class="fa fa-branch-merge"></i> </button>
</td>
</tr>
<tr class="branch" wicket:id="branches">
@@ -32,6 +35,10 @@
<wicket:container wicket:id="statbar"></wicket:container>
</td>
<td class="actions">
+ <button wicket:id="unwatchCommits" class="btn btn-default" title="You are watching commits of this branch, click to unwatch"><i class="fa fa-eye-open"></i> <i class="fa fa-commit"></i> </button>
+ <button wicket:id="unwatchRequests" class="btn btn-default" title="You are watching pull requests of this branch, click to unwatch"><i class="fa fa-eye-open"></i> <i class="fa fa-branch-merge"></i> </button>
+ <button wicket:id="watchCommits" class="btn btn-default" title="You are not watching commits of this branch, click to watch"><i class="fa fa-eye-slash"></i> <i class="fa fa-commit"></i> </button>
+ <button wicket:id="watchRequests" class="btn btn-default" title="You are not watching pull requests of this branch, click to watch"><i class="fa fa-eye-slash"></i> <i class="fa fa-branch-merge"></i> </button>
<button wicket:id="compareLink" class="btn btn-default"><i class="fa fa-branch-compare"></i> Compare</button>
<span wicket:id="pullName"></span>
</td>
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/code/branches/BranchesPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/code/branches/BranchesPage.java
index deb9da318d..c2b4140e85 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/code/branches/BranchesPage.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/code/branches/BranchesPage.java
@@ -206,6 +206,7 @@ public class BranchesPage extends RepositoryPage {
// TODO: Change this to LINK to pull request
item.add(new Label("pullName", request.getId()));
}
+
}
});
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/NewRequestPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/NewRequestPage.java
index 3d33fb5c61..5503db23c7 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/NewRequestPage.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/NewRequestPage.java
@@ -123,7 +123,6 @@ public class NewRequestPage extends RepositoryPage {
PullRequestUpdate update = new PullRequestUpdate();
pullRequest.getUpdates().add(update);
update.setRequest(pullRequest);
- update.setUser(currentUser);
update.setHeadCommitHash(source.getHeadCommitHash());
pullRequest.setUpdateDate(new Date());
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/RequestUpdatesPage.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/RequestUpdatesPage.html
index 4f585356d6..38f39f9af6 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/RequestUpdatesPage.html
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/RequestUpdatesPage.html
@@ -2,7 +2,7 @@
<ul wicket:id="requestUpdatesContainer" class="updates list-unstyled">
<li wicket:id="updates" class="update activity">
<div class="summary">
- <span wicket:id="name" class="user"></span> pushed update #<span wicket:id="updateNo"></span> <span wicket:id="age"></span>
+ Update #<span wicket:id="updateNo"></span>, pushed <span wicket:id="age"></span>
<span class="actions">
<a wicket:id="compare"><span class="fa fa-diff"></span></a>
</span>
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/RequestUpdatesPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/RequestUpdatesPage.java
index 68e1c87166..47809dcf8d 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/RequestUpdatesPage.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/RequestUpdatesPage.java
@@ -67,7 +67,6 @@ public class RequestUpdatesPage extends RequestDetailPage {
protected void populateItem(final ListItem<PullRequestUpdate> updateItem) {
PullRequestUpdate update = updateItem.getModelObject();
- updateItem.add(new UserLink("name", new UserModel(update.getUser()), AvatarMode.NAME));
List<PullRequestUpdate> updates = update.getRequest().getSortedUpdates();
int updateNo = updates.indexOf(update) + 1;
updateItem.add(new Label("updateNo", updateNo));
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/activity/UpdatePullRequest.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/activity/UpdatePullRequest.java
index 11b709260e..135fb889c6 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/activity/UpdatePullRequest.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/activity/UpdatePullRequest.java
@@ -38,7 +38,7 @@ public class UpdatePullRequest implements PullRequestActivity {
@Override
public User getUser() {
- return getUpdate().getUser();
+ return null;
}
public PullRequestUpdate getUpdate() {