Merge "Add gitweb.linkDrafts to control if gitweb links are shown on drafts"

This commit is contained in:
David Pursehouse
2013-04-17 03:08:00 +00:00
committed by Gerrit Code Review
5 changed files with 38 additions and 1 deletions

View File

@@ -1320,6 +1320,16 @@ using the property 'gitweb.pathSeparator'.
+ +
Valid values are the characters '*', '(' and ')'. Valid values are the characters '*', '(' and ')'.
[[gitweb.linkDrafts]]gitweb.linkDrafts::
+
Whether or not Gerrit should provide links to gitweb on draft patch sets.
+
By default, Gerrit will show links to gitweb on all patch sets. If gitweb
only allows publicly viewable references, set this to false to remove
the links to draft patch sets from the change review screen.
+
Valid values are "true" and "false," default is "true."
[[groups]]Section groups [[groups]]Section groups
~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~

View File

@@ -75,6 +75,9 @@ public class GitWebType {
* project names */ * project names */
private char pathSeparator = '/'; private char pathSeparator = '/';
/** Whether to include links to draft patch sets */
private boolean linkDrafts;
/** Private default constructor for gson. */ /** Private default constructor for gson. */
protected GitWebType() { protected GitWebType() {
} }
@@ -124,6 +127,15 @@ public class GitWebType {
return fileHistory; return fileHistory;
} }
/**
* Get whether to link to draft patch sets
*
* @return True to link
*/
public boolean getLinkDrafts() {
return linkDrafts;
}
/** /**
* Set the pattern for branch view. * Set the pattern for branch view.
* *
@@ -201,4 +213,8 @@ public class GitWebType {
public void setPathSeparator(char separator) { public void setPathSeparator(char separator) {
this.pathSeparator = separator; this.pathSeparator = separator;
} }
public void setLinkDrafts(boolean linkDrafts) {
this.linkDrafts = linkDrafts;
}
} }

View File

@@ -35,6 +35,16 @@ public class GitwebLink {
type = link.type; type = link.type;
} }
/**
* Can we link to a patch set if it's a draft
*
* @param ps Patch set to check draft status
* @return true if it's not a draft, or we can link to drafts
*/
public boolean canLink(final PatchSet ps) {
return !ps.isDraft() || type.getLinkDrafts();
}
public String getLinkName() { public String getLinkName() {
return "(" + type.getLinkName() + ")"; return "(" + type.getLinkName() + ")";
} }

View File

@@ -91,7 +91,7 @@ class PatchSetComplexDisclosurePanel extends ComplexDisclosurePanel
final InlineLabel revtxt = new InlineLabel(ps.getRevision().get() + " "); final InlineLabel revtxt = new InlineLabel(ps.getRevision().get() + " ");
revtxt.addStyleName(Gerrit.RESOURCES.css().patchSetRevision()); revtxt.addStyleName(Gerrit.RESOURCES.css().patchSetRevision());
getHeader().add(revtxt); getHeader().add(revtxt);
if (gw != null) { if (gw != null && gw.canLink(ps)) {
final Anchor revlink = final Anchor revlink =
new Anchor(gw.getLinkName(), false, gw.toRevision(changeDetail.getChange() new Anchor(gw.getLinkName(), false, gw.toRevision(changeDetail.getChange()
.getProject(), ps)); .getProject(), ps));

View File

@@ -55,6 +55,7 @@ public class GitWebConfig {
type.setProject(cfg.getString("gitweb", null, "project")); type.setProject(cfg.getString("gitweb", null, "project"));
type.setRevision(cfg.getString("gitweb", null, "revision")); type.setRevision(cfg.getString("gitweb", null, "revision"));
type.setFileHistory(cfg.getString("gitweb", null, "filehistory")); type.setFileHistory(cfg.getString("gitweb", null, "filehistory"));
type.setLinkDrafts(cfg.getBoolean("gitweb", null, "linkdrafts", true));
String pathSeparator = cfg.getString("gitweb", null, "pathSeparator"); String pathSeparator = cfg.getString("gitweb", null, "pathSeparator");
if (pathSeparator != null) { if (pathSeparator != null) {
if (pathSeparator.length() == 1) { if (pathSeparator.length() == 1) {