Skip to content

Commit

Permalink
[6.4.0] Show fetch progress for the mod command (#19542)
Browse files Browse the repository at this point in the history
By sending out the proper events to let the UiEventHandler know that we
want progress displayed.

Fixes #19252

PiperOrigin-RevId: 565701083
Change-Id: If4853cc70c0fad2e0b0bebd2378dddab05e37ce1
  • Loading branch information
Wyverald authored Sep 15, 2023
1 parent 3142438 commit e36ca59
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSortedSet;
import com.google.common.collect.Iterables;
import com.google.devtools.build.lib.analysis.NoBuildEvent;
import com.google.devtools.build.lib.analysis.NoBuildRequestFinishedEvent;
import com.google.devtools.build.lib.bazel.bzlmod.BazelDepGraphValue;
import com.google.devtools.build.lib.bazel.bzlmod.BazelModuleInspectorValue;
import com.google.devtools.build.lib.bazel.bzlmod.BazelModuleInspectorValue.AugmentedModule;
Expand Down Expand Up @@ -106,6 +108,23 @@ public void editOptions(OptionsParser optionsParser) {

@Override
public BlazeCommandResult exec(CommandEnvironment env, OptionsParsingResult options) {
env.getEventBus()
.post(
new NoBuildEvent(
env.getCommandName(),
env.getCommandStartTime(),
/* separateFinishedEvent= */ true,
/* showProgress= */ true,
/* id= */ null));
BlazeCommandResult result = execInternal(env, options);
env.getEventBus()
.post(
new NoBuildRequestFinishedEvent(
result.getExitCode(), env.getRuntime().getClock().currentTimeMillis()));
return result;
}

private BlazeCommandResult execInternal(CommandEnvironment env, OptionsParsingResult options) {
BazelDepGraphValue depGraphValue;
BazelModuleInspectorValue moduleInspector;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,9 @@ private void completeBuild() {
return;
}
buildRunning = false;
// Have to set this, otherwise there's a lingering "checking cached actions" message for the
// `mod` command, which doesn't even run any actions.
stateTracker.setBuildComplete();
}
stopUpdateThread();
synchronized (this) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
import javax.annotation.Nullable;
import javax.annotation.concurrent.GuardedBy;
import javax.annotation.concurrent.GuardedBy;
import javax.annotation.concurrent.ThreadSafe;

/** Tracks state for the UI. */
Expand Down Expand Up @@ -465,8 +465,7 @@ synchronized void progressReceiverAvailable(ExecutionProgressReceiverAvailableEv
}

void buildComplete(BuildCompleteEvent event) {
buildComplete = true;
buildCompleteAt = Instant.ofEpochMilli(clock.currentTimeMillis());
setBuildComplete();

if (event.getResult().getSuccess()) {
status = "INFO";
Expand Down Expand Up @@ -500,6 +499,11 @@ protected boolean buildCompleted() {
return buildComplete;
}

public void setBuildComplete() {
buildComplete = true;
buildCompleteAt = Instant.ofEpochMilli(clock.currentTimeMillis());
}

synchronized void downloadProgress(FetchProgress event) {
String url = event.getResourceIdentifier();
if (event.isFinished()) {
Expand Down

0 comments on commit e36ca59

Please sign in to comment.