SubmoduleOp: Have a flag for verbosity of superproject messages
The revision log being merged is actually redundant information; it can be obtained later by looking at the submodule updates. Change-Id: I30aaeb96e62ce4fc9e15127d3ec72cd5a5ce34ff
This commit is contained in:
parent
159f5bcfcb
commit
0f724ff504
@ -3772,6 +3772,18 @@ If no groups are added, any user will be allowed to execute
|
||||
'upload-pack' on the server.
|
||||
|
||||
|
||||
[[submodule]]
|
||||
=== Section submodule
|
||||
|
||||
[[submodule.verbosesuperprojectupdate]]submodule.verboseSuperprojectUpdate
|
||||
+
|
||||
When using link:user-submodules.html#automatic_update[automatic superproject updates]
|
||||
this option will determine if the submodule commit messages are included into
|
||||
the commit message of the superproject update.
|
||||
+
|
||||
By default this is true.
|
||||
|
||||
|
||||
[[user]]
|
||||
=== Section user
|
||||
|
||||
|
@ -97,6 +97,7 @@ to identify if it registers any submodules (if the commit contains new
|
||||
gitlinks and a .gitmodules file with all required info) and if so,
|
||||
a new submodule subscription is registered.
|
||||
|
||||
[[automatic_update]]
|
||||
== Automatic Update of Superprojects
|
||||
|
||||
After a superproject is subscribed to a submodule, it is not
|
||||
|
@ -16,6 +16,8 @@ package com.google.gerrit.acceptance.git;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import com.google.gerrit.acceptance.GerritConfig;
|
||||
|
||||
import org.eclipse.jgit.junit.TestRepository;
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
import org.eclipse.jgit.revwalk.RevCommit;
|
||||
@ -50,6 +52,31 @@ public class SubmoduleSubscriptionsIT extends AbstractSubmoduleSubscription {
|
||||
}
|
||||
|
||||
@Test
|
||||
@GerritConfig(name = "submodule.verboseSuperprojectUpdate", value = "false")
|
||||
public void testSubmoduleShortCommitMessage() throws Exception {
|
||||
TestRepository<?> superRepo = createProjectWithPush("super-project");
|
||||
TestRepository<?> subRepo = createProjectWithPush("subscribed-to-project");
|
||||
|
||||
pushChangeTo(subRepo, "master");
|
||||
createSubscription(superRepo, "master", "subscribed-to-project", "master");
|
||||
|
||||
// The first update doesn't include any commit messages
|
||||
ObjectId subRepoId = pushChangeTo(subRepo, "master");
|
||||
expectToHaveSubmoduleState(superRepo, "master",
|
||||
"subscribed-to-project", subRepoId);
|
||||
expectToHaveCommitMessage(superRepo, "master",
|
||||
"Updated git submodules\n\n");
|
||||
|
||||
// Any following update also has a short message
|
||||
subRepoId = pushChangeTo(subRepo, "master");
|
||||
expectToHaveSubmoduleState(superRepo, "master",
|
||||
"subscribed-to-project", subRepoId);
|
||||
expectToHaveCommitMessage(superRepo, "master",
|
||||
"Updated git submodules\n\n");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
public void testSubmoduleCommitMessage() throws Exception {
|
||||
TestRepository<?> superRepo = createProjectWithPush("super-project");
|
||||
TestRepository<?> subRepo = createProjectWithPush("subscribed-to-project");
|
||||
|
@ -25,6 +25,7 @@ import com.google.gerrit.reviewdb.client.SubmoduleSubscription;
|
||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||
import com.google.gerrit.server.GerritPersonIdent;
|
||||
import com.google.gerrit.server.config.CanonicalWebUrl;
|
||||
import com.google.gerrit.server.config.GerritServerConfig;
|
||||
import com.google.gerrit.server.extensions.events.GitReferenceUpdated;
|
||||
import com.google.gerrit.server.util.SubmoduleSectionParser;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
@ -42,6 +43,7 @@ import org.eclipse.jgit.errors.IncorrectObjectTypeException;
|
||||
import org.eclipse.jgit.errors.MissingObjectException;
|
||||
import org.eclipse.jgit.lib.BlobBasedConfig;
|
||||
import org.eclipse.jgit.lib.CommitBuilder;
|
||||
import org.eclipse.jgit.lib.Config;
|
||||
import org.eclipse.jgit.lib.Constants;
|
||||
import org.eclipse.jgit.lib.FileMode;
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
@ -76,11 +78,13 @@ public class SubmoduleOp {
|
||||
private final Account account;
|
||||
private final ChangeHooks changeHooks;
|
||||
private final SubmoduleSectionParser.Factory subSecParserFactory;
|
||||
private final boolean verboseSuperProject;
|
||||
|
||||
@Inject
|
||||
public SubmoduleOp(
|
||||
@CanonicalWebUrl @Nullable Provider<String> urlProvider,
|
||||
@GerritPersonIdent PersonIdent myIdent,
|
||||
@GerritServerConfig Config cfg,
|
||||
GitRepositoryManager repoManager,
|
||||
GitReferenceUpdated gitRefUpdated,
|
||||
@Nullable Account account,
|
||||
@ -93,6 +97,8 @@ public class SubmoduleOp {
|
||||
this.account = account;
|
||||
this.changeHooks = changeHooks;
|
||||
this.subSecParserFactory = subSecParserFactory;
|
||||
this.verboseSuperProject = cfg.getBoolean("submodule",
|
||||
"verboseSuperprojectUpdate", true);
|
||||
|
||||
updatedSubscribers = new HashSet<>();
|
||||
}
|
||||
@ -274,24 +280,25 @@ public class SubmoduleOp {
|
||||
ent.setObjectId(updateTo);
|
||||
}
|
||||
});
|
||||
if (verboseSuperProject) {
|
||||
msgbuf.append("Project: " + s.getSubmodule().getParentKey().get());
|
||||
msgbuf.append(" " + s.getSubmodule().getShortName());
|
||||
msgbuf.append(" " + updateTo.getName());
|
||||
msgbuf.append("\n\n");
|
||||
|
||||
msgbuf.append("Project: " + s.getSubmodule().getParentKey().get());
|
||||
msgbuf.append(" " + s.getSubmodule().getShortName());
|
||||
msgbuf.append(" " + updateTo.getName());
|
||||
msgbuf.append("\n\n");
|
||||
try {
|
||||
rw.markStart(newCommit);
|
||||
|
||||
try {
|
||||
rw.markStart(newCommit);
|
||||
|
||||
if (oldId != null) {
|
||||
rw.markUninteresting(rw.parseCommit(oldId));
|
||||
if (oldId != null) {
|
||||
rw.markUninteresting(rw.parseCommit(oldId));
|
||||
}
|
||||
for (RevCommit c : rw) {
|
||||
msgbuf.append(c.getFullMessage() + "\n\n");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
logAndThrowSubmoduleException("Could not perform a revwalk to "
|
||||
+ "create superproject commit message", e);
|
||||
}
|
||||
for (RevCommit c : rw) {
|
||||
msgbuf.append(c.getFullMessage() + "\n\n");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
logAndThrowSubmoduleException("Could not perform a revwalk to "
|
||||
+ "create superproject commit message", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user