summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNasser Grainawi <nasser@codeaurora.org>2022-02-28 12:25:51 -0700
committerNasser Grainawi <nasser@codeaurora.org>2022-03-01 09:03:21 -0700
commit5b5eff464d3a4c906ff844718ab08597f3d53854 (patch)
tree04c8f5264d7b6dcf8313775ecd6e375978d345c7
parent04e6dbf1a31e80a06d44f87c695916c144728a52 (diff)
parent996d20a54fd6765b30f1f0a36d3ae895ee9d8cea (diff)
Merge branch 'stable-3.4' into stable-3.5
* stable-3.4: config-gerrit: Fix 'database' references Remove leftover receive.changeUpdateThreads references config-gerrit: Remove extra list continuations Fix the ${hash} substitution for diff file web links Add ${hash} as a substitution variable for gitweb file links Change-Id: I5377a1cb9007e7de545d6b6874592a80d06aaa4a Release-Notes: skip
-rw-r--r--Documentation/config-gerrit.txt47
-rw-r--r--Documentation/config-gitweb.txt17
-rw-r--r--java/com/google/gerrit/acceptance/AbstractDaemonTest.java1
-rw-r--r--java/com/google/gerrit/acceptance/ExtensionRegistry.java8
-rw-r--r--java/com/google/gerrit/extensions/webui/FileWebLink.java3
-rw-r--r--java/com/google/gerrit/server/WebLinks.java8
-rw-r--r--java/com/google/gerrit/server/config/GitwebConfig.java4
-rw-r--r--java/com/google/gerrit/server/restapi/change/GetDiff.java13
-rw-r--r--javatests/com/google/gerrit/acceptance/api/revision/RevisionDiffIT.java36
9 files changed, 98 insertions, 39 deletions
diff --git a/Documentation/config-gerrit.txt b/Documentation/config-gerrit.txt
index 30999813b0..ab0657a183 100644
--- a/Documentation/config-gerrit.txt
+++ b/Documentation/config-gerrit.txt
@@ -256,8 +256,8 @@ the randomly generated HTTP password is used for authentication. On the other ha
if link:#auth.gitBasicAuthPolicy[`auth.gitBasicAuthPolicy`] is set to `HTTP_LDAP`,
the password in the request is first checked against the HTTP password and, if
it does not match, it is then validated against the LDAP password.
-Service users that only exist in the Gerrit database are authenticated by their
-HTTP passwords.
+Service users that are link:cmd-create-account.html[internal-only] are
+authenticated by their HTTP passwords.
* `LDAP_BIND`
+
@@ -611,7 +611,7 @@ needs to have `http.cookieFile` set to a local file, otherwise every
single call would trigger a full LDAP authentication and groups resolution
which could introduce a noticeable latency on the overall execution
and produce unwanted load to the LDAP server.
-+
+
[[auth.gitOAuthProvider]]auth.gitOAuthProvider::
+
Selects the OAuth 2 provider to authenticate git over HTTP traffic with.
@@ -714,8 +714,10 @@ By default, true.
[[auth.autoUpdateAccountActiveStatus]]auth.autoUpdateAccountActiveStatus::
+
Whether to allow automatic synchronization of an account's inactive flag upon login.
++
If set to true, upon login, if the authentication back-end reports the account as active,
-the account's inactive flag in the internal Gerrit database will be updated to be active.
+the account's inactive flag in NoteDb will be updated to be active.
++
If the authentication back-end reports the account as inactive, the account's flag will be
updated to be inactive and the login attempt will be blocked. Users enabling this feature
should ensure that their authentication back-end is supported. Currently, only
@@ -985,8 +987,8 @@ that change updates are not communicated between Gerrit servers. Hence
this cache should be disabled in a cluster setup using multiple primary
or multiple replica nodes.
+
-The cache should be flushed whenever the database changes table is modified
-outside of Gerrit.
+The cache should be flushed whenever NoteDb change metadata in a repository is
+modified outside of Gerrit.
cache `"git_modified_files"`::
+
@@ -1342,7 +1344,7 @@ may use the `administrateServer` capability.
Whether the first user that logs in to the Gerrit server should
automatically be added to the administrator group and hence get the
`administrateServer` capability assigned. This is useful to bootstrap
-the authentication database.
+the link:config-accounts.html[account data].
+
Default is true.
@@ -2296,7 +2298,7 @@ to have Gerrit display URLs from this server, rather than itself.
By default unset, as the HTTP daemon must be configured externally
by the system administrator, and might not even be running on the
same host as Gerrit.
-+
+
[[gerrit.installBatchModule]]gerrit.installBatchModule::
+
Repeatable list of class name of additional Guice modules to load as
@@ -2306,7 +2308,7 @@ class needs to be either declared in Gerrit or an additional JAR
located under the `/lib` directory.
+
By default unset.
-+
+
[[gerrit.installDbModule]]gerrit.installDbModule::
+
Repeatable list of class name of additional Guice modules to load at
@@ -2586,8 +2588,9 @@ at the contents of a file in a specific commit when `gitweb.type` is
set to `custom`.
+
Valid replacements are `${project}` for the project name in Gerrit,
-`${file}` for the file name and `${commit}` for the SHA-1 hash for
-the commit.
+`${file}` for the file name, `${hash}` for the SHA-1 hash for the commit,
+and `${commit}` for the change ref or SHA-1 of the commit if no base
+patch set.
[[gitweb.filehistory]]gitweb.filehistory::
+
@@ -4143,18 +4146,6 @@ the client.
+
Default is 5 minutes.
-[[receive.changeUpdateThreads]]receive.changeUpdateThreads::
-+
-Number of threads to perform change creation or patch set updates
-concurrently. Each thread uses its own database connection from
-the database connection pool, and if all threads are busy then
-main receive thread will also perform a change creation or patch
-set update.
-+
-Defaults to 1, using only the main receive thread. This feature is for
-databases with very high latency that can benefit from concurrent
-operations when multiple changes are impacted at once.
-
[[receive.checkMagicRefs]]receive.checkMagicRefs::
+
If true, Gerrit will verify the destination repository has
@@ -4396,9 +4387,8 @@ than `INHERIT`.
[[repository.name.ownerGroup]]repository.<name>.ownerGroup::
+
-A name of a group which exists in the database. Zero, one or many
-groups are allowed. Each on its own line. Groups which don't exist
-in the database are ignored.
+A name of a link:config-groups.html[group] which exists. Zero, one or many
+groups are allowed. Each on its own line. Groups which don't exist are ignored.
[[retry]]
=== Section retry
@@ -5237,6 +5227,7 @@ are provided. If set to 0, suggestions are always provided. This is only
used for suggesting accounts when adding members to a group.
+
By default 0.
+
[[suggest.relevantChanges]]suggest.relevantChanges::
+
When suggesting reviewers, we go over recent changes of the user, and
@@ -5747,10 +5738,6 @@ Sample `etc/secure.config`:
[auth]
registerEmailPrivateKey = 2zHNrXE2bsoylzUqDxZp0H1cqUmjgWb6
-[database]
- username = webuser
- password = s3kr3t
-
[ldap]
password = l3tm3srch
diff --git a/Documentation/config-gitweb.txt b/Documentation/config-gitweb.txt
index 46c9ced2b4..00e33a35d3 100644
--- a/Documentation/config-gitweb.txt
+++ b/Documentation/config-gitweb.txt
@@ -268,7 +268,22 @@ Gerrit, such as cgit.
cgit can be used by specifying `gitweb.type` to be 'cgit'.
-It is also possible to define custom patterns.
+It is also possible to define custom patterns. Gitea can be used
+with custom patterns for example:
+
+----
+ git config -f $site_path/etc/gerrit.config gitweb.type custom
+ git config -f $site_path/etc/gerrit.config gitweb.urlEncode false
+ git config -f $site_path/etc/gerrit.config gitweb.linkname gitea
+ git config -f $site_path/etc/gerrit.config gitweb.url https://gitea.example.org/
+ git config -f $site_path/etc/gerrit.config gitweb.branch ${project}/src/branch/${branch}
+ git config -f $site_path/etc/gerrit.config gitweb.file ${project}/src/commit/${hash}/${file}
+ git config -f $site_path/etc/gerrit.config gitweb.filehistory ${project}/commits/branch/${branch}/${file}
+ git config -f $site_path/etc/gerrit.config gitweb.project ${project}
+ git config -f $site_path/etc/gerrit.config gitweb.revision ${project}/commit/${commit}
+ git config -f $site_path/etc/gerrit.config gitweb.roottree ${project}/src/commit/${commit}
+ git config -f $site_path/etc/gerrit.config gitweb.tag ${project}/src/tag/${tag}
+----
=== SEE ALSO
diff --git a/java/com/google/gerrit/acceptance/AbstractDaemonTest.java b/java/com/google/gerrit/acceptance/AbstractDaemonTest.java
index c68a4fc179..3934a6a1c8 100644
--- a/java/com/google/gerrit/acceptance/AbstractDaemonTest.java
+++ b/java/com/google/gerrit/acceptance/AbstractDaemonTest.java
@@ -458,7 +458,6 @@ public abstract class AbstractDaemonTest {
baseConfig.setInt("index", null, "batchThreads", -1);
- baseConfig.setInt("receive", null, "changeUpdateThreads", 4);
Module module = createModule();
Module auditModule = createAuditModule();
Module sshModule = createSshModule();
diff --git a/java/com/google/gerrit/acceptance/ExtensionRegistry.java b/java/com/google/gerrit/acceptance/ExtensionRegistry.java
index 1e5598eed1..3844788d8a 100644
--- a/java/com/google/gerrit/acceptance/ExtensionRegistry.java
+++ b/java/com/google/gerrit/acceptance/ExtensionRegistry.java
@@ -36,6 +36,7 @@ import com.google.gerrit.extensions.registration.PrivateInternals_DynamicMapImpl
import com.google.gerrit.extensions.registration.RegistrationHandle;
import com.google.gerrit.extensions.webui.EditWebLink;
import com.google.gerrit.extensions.webui.FileHistoryWebLink;
+import com.google.gerrit.extensions.webui.FileWebLink;
import com.google.gerrit.extensions.webui.PatchSetWebLink;
import com.google.gerrit.extensions.webui.ResolveConflictsWebLink;
import com.google.gerrit.server.ExceptionHook;
@@ -81,6 +82,7 @@ public class ExtensionRegistry {
private final DynamicSet<PatchSetWebLink> patchSetWebLinks;
private final DynamicSet<ResolveConflictsWebLink> resolveConflictsWebLinks;
private final DynamicSet<EditWebLink> editWebLinks;
+ private final DynamicSet<FileWebLink> fileWebLinks;
private final DynamicSet<RevisionCreatedListener> revisionCreatedListeners;
private final DynamicSet<GroupBackend> groupBackends;
private final DynamicSet<AccountActivationValidationListener>
@@ -119,6 +121,7 @@ public class ExtensionRegistry {
DynamicSet<PatchSetWebLink> patchSetWebLinks,
DynamicSet<ResolveConflictsWebLink> resolveConflictsWebLinks,
DynamicSet<EditWebLink> editWebLinks,
+ DynamicSet<FileWebLink> fileWebLinks,
DynamicSet<RevisionCreatedListener> revisionCreatedListeners,
DynamicSet<GroupBackend> groupBackends,
DynamicSet<AccountActivationValidationListener> accountActivationValidationListeners,
@@ -152,6 +155,7 @@ public class ExtensionRegistry {
this.fileHistoryWebLinks = fileHistoryWebLinks;
this.patchSetWebLinks = patchSetWebLinks;
this.editWebLinks = editWebLinks;
+ this.fileWebLinks = fileWebLinks;
this.resolveConflictsWebLinks = resolveConflictsWebLinks;
this.revisionCreatedListeners = revisionCreatedListeners;
this.groupBackends = groupBackends;
@@ -264,6 +268,10 @@ public class ExtensionRegistry {
return add(editWebLinks, editWebLink);
}
+ public Registration add(FileWebLink fileWebLink) {
+ return add(fileWebLinks, fileWebLink);
+ }
+
public Registration add(RevisionCreatedListener revisionCreatedListener) {
return add(revisionCreatedListeners, revisionCreatedListener);
}
diff --git a/java/com/google/gerrit/extensions/webui/FileWebLink.java b/java/com/google/gerrit/extensions/webui/FileWebLink.java
index c03d606a27..dc386b310d 100644
--- a/java/com/google/gerrit/extensions/webui/FileWebLink.java
+++ b/java/com/google/gerrit/extensions/webui/FileWebLink.java
@@ -32,8 +32,9 @@ public interface FileWebLink extends WebLink {
*
* @param projectName Name of the project
* @param revision Name of the revision (e.g. branch or commit ID)
+ * @param hash SHA-1 of the commit
* @param fileName Name of the file
* @return WebLinkInfo that links to project in external service, null if there should be no link.
*/
- WebLinkInfo getFileWebLink(String projectName, String revision, String fileName);
+ WebLinkInfo getFileWebLink(String projectName, String revision, String hash, String fileName);
}
diff --git a/java/com/google/gerrit/server/WebLinks.java b/java/com/google/gerrit/server/WebLinks.java
index 3c6957383d..2cf2326412 100644
--- a/java/com/google/gerrit/server/WebLinks.java
+++ b/java/com/google/gerrit/server/WebLinks.java
@@ -154,13 +154,15 @@ public class WebLinks {
* Returns links for files
*
* @param project Project name.
- * @param revision SHA1 of revision.
+ * @param revision Name of the revision (e.g. branch or commit ID)
+ * @param hash SHA1 of revision.
* @param file File name.
*/
- public ImmutableList<WebLinkInfo> getFileLinks(String project, String revision, String file) {
+ public ImmutableList<WebLinkInfo> getFileLinks(
+ String project, String revision, String hash, String file) {
return Patch.isMagic(file)
? ImmutableList.of()
- : filterLinks(fileLinks, webLink -> webLink.getFileWebLink(project, revision, file));
+ : filterLinks(fileLinks, webLink -> webLink.getFileWebLink(project, revision, hash, file));
}
/**
diff --git a/java/com/google/gerrit/server/config/GitwebConfig.java b/java/com/google/gerrit/server/config/GitwebConfig.java
index 38a86f008e..c477bb5a0b 100644
--- a/java/com/google/gerrit/server/config/GitwebConfig.java
+++ b/java/com/google/gerrit/server/config/GitwebConfig.java
@@ -318,11 +318,13 @@ public class GitwebConfig {
}
@Override
- public WebLinkInfo getFileWebLink(String projectName, String revision, String fileName) {
+ public WebLinkInfo getFileWebLink(
+ String projectName, String revision, String hash, String fileName) {
if (file != null) {
return link(
file.replace("project", encode(projectName))
.replace("commit", encode(revision))
+ .replace("hash", encode(hash))
.replace("file", encode(fileName))
.toString());
}
diff --git a/java/com/google/gerrit/server/restapi/change/GetDiff.java b/java/com/google/gerrit/server/restapi/change/GetDiff.java
index dd951a8cbb..942419859b 100644
--- a/java/com/google/gerrit/server/restapi/change/GetDiff.java
+++ b/java/com/google/gerrit/server/restapi/change/GetDiff.java
@@ -184,6 +184,8 @@ public class GetDiff implements RestReadView<FileResource> {
private final DiffSide sideB;
private final String revA;
private final String revB;
+ private final String hashA;
+ private final String hashB;
private final FileResource resource;
@Nullable private final PatchSet basePatchSet;
@@ -202,6 +204,7 @@ public class GetDiff implements RestReadView<FileResource> {
this.sideB = sideB;
revA = basePatchSet != null ? basePatchSet.refName() : sideA.fileInfo().commitId;
+ hashA = sideA.fileInfo().commitId;
RevisionResource revision = resource.getRevision();
revB =
@@ -209,8 +212,9 @@ public class GetDiff implements RestReadView<FileResource> {
.getEdit()
.map(edit -> edit.getRefName())
.orElseGet(() -> revision.getPatchSet().refName());
+ hashB = sideB.fileInfo().commitId;
- logger.atFine().log("revA = %s, revB = %s", revA, revB);
+ logger.atFine().log("revA = %s, hashA = %s, revB = %s, hashB = %s", revA, hashA, revB, hashB);
}
@Override
@@ -234,14 +238,19 @@ public class GetDiff implements RestReadView<FileResource> {
@Override
public ImmutableList<WebLinkInfo> getFileWebLinks(DiffSide.Type type) {
String rev = getSideRev(type);
+ String hash = getSideHash(type);
DiffSide side = getDiffSide(type);
- return webLinks.getFileLinks(projectName.get(), rev, side.fileName());
+ return webLinks.getFileLinks(projectName.get(), rev, hash, side.fileName());
}
private String getSideRev(DiffSide.Type sideType) {
return DiffSide.Type.SIDE_A == sideType ? revA : revB;
}
+ private String getSideHash(DiffSide.Type sideType) {
+ return DiffSide.Type.SIDE_A == sideType ? hashA : hashB;
+ }
+
private DiffSide getDiffSide(DiffSide.Type sideType) {
return DiffSide.Type.SIDE_A == sideType ? sideA : sideB;
}
diff --git a/javatests/com/google/gerrit/acceptance/api/revision/RevisionDiffIT.java b/javatests/com/google/gerrit/acceptance/api/revision/RevisionDiffIT.java
index a6666d482a..e645ecf45f 100644
--- a/javatests/com/google/gerrit/acceptance/api/revision/RevisionDiffIT.java
+++ b/javatests/com/google/gerrit/acceptance/api/revision/RevisionDiffIT.java
@@ -50,6 +50,7 @@ import com.google.gerrit.extensions.common.WebLinkInfo;
import com.google.gerrit.extensions.restapi.BadRequestException;
import com.google.gerrit.extensions.restapi.BinaryResult;
import com.google.gerrit.extensions.webui.EditWebLink;
+import com.google.gerrit.extensions.webui.FileWebLink;
import com.google.gerrit.server.patch.DiffOperations;
import com.google.gerrit.server.patch.filediff.FileDiffOutput;
import com.google.inject.Inject;
@@ -196,6 +197,26 @@ public class RevisionDiffIT extends AbstractDaemonTest {
}
@Test
+ public void gitwebFileWebLinkIncludedInDiff() throws Exception {
+ try (Registration registration = newGitwebFileWebLink()) {
+ String fileName = "foo.txt";
+ String fileContent = "bar\n";
+ PushOneCommit.Result result = createChange("Add a file", fileName, fileContent);
+ DiffInfo info =
+ gApi.changes()
+ .id(result.getChangeId())
+ .revision(result.getCommit().name())
+ .file(fileName)
+ .diff();
+ assertThat(info.metaB.webLinks).hasSize(1);
+ assertThat(info.metaB.webLinks.get(0).url)
+ .isEqualTo(
+ String.format(
+ "http://gitweb/?p=%s;hb=%s;f=%s", project, result.getCommit().name(), fileName));
+ }
+ }
+
+ @Test
public void deletedFileIsIncludedInDiff() throws Exception {
gApi.changes().id(changeId).edit().deleteFile(FILE_NAME);
gApi.changes().id(changeId).edit().publish();
@@ -2964,6 +2985,21 @@ public class RevisionDiffIT extends AbstractDaemonTest {
return extensionRegistry.newRegistration().add(webLink);
}
+ private Registration newGitwebFileWebLink() {
+ FileWebLink fileWebLink =
+ new FileWebLink() {
+ @Override
+ public WebLinkInfo getFileWebLink(
+ String projectName, String revision, String hash, String fileName) {
+ return new WebLinkInfo(
+ "name",
+ "imageURL",
+ String.format("http://gitweb/?p=%s;hb=%s;f=%s", projectName, hash, fileName));
+ }
+ };
+ return extensionRegistry.newRegistration().add(fileWebLink);
+ }
+
private String updatedCommitMessage() {
return "An unchanged patchset\n\nChange-Id: " + changeId;
}