Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 3 additions & 12 deletions src/libfetchers/git-utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -592,24 +592,15 @@ struct GitRepoImpl : GitRepo, std::enable_shared_from_this<GitRepoImpl>

if (ExecutablePath::load().findName("git")) {
auto dir = this->path;
Strings gitArgs{"-C", dir.string(), "--git-dir", ".", "fetch", "--quiet", "--force"};
Strings gitArgs{"-C", dir.string(), "--git-dir", ".", "fetch", "--progress", "--force"};
if (shallow)
append(gitArgs, {"--depth", "1"});
append(gitArgs, {std::string("--"), url, refspec});

auto [status, output] = runProgram(
RunOptions{
.program = "git",
.lookupPath = true,
// FIXME: git stderr messes up our progress indicator, so
// we're using --quiet for now. Should process its stderr.
.args = gitArgs,
.input = {},
.mergeStderrToStdout = true,
.isInteractive = true});
auto status = runProgram(RunOptions{.program = "git", .args = gitArgs, .isInteractive = true}).first;

if (status > 0)
throw Error("Failed to fetch git repository %s : %s", url, output);
throw Error("Failed to fetch git repository '%s'", url);
} else {
// Fall back to using libgit2 for fetching. This does not
// support SSH very well.
Expand Down
22 changes: 18 additions & 4 deletions src/libmain/progress-bar.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class ProgressBar : public Logger
ActivityId parent;
std::optional<std::string> name;
std::chrono::time_point<std::chrono::steady_clock> startTime;
bool logged = false;
};

struct ActivitiesByType
Expand Down Expand Up @@ -142,8 +143,14 @@ class ProgressBar : public Logger
return;
}

if (state->active)
if (state->active) {
writeToStderr("\r\e[K");
/* Show activities that were previously only shown on the
progress bar. Otherwise the user won't know what's
happening. */
for (auto & act : state->activities)
logActivity(*state, lvlNotice, act);
}
}

void resume() override
Expand Down Expand Up @@ -196,6 +203,14 @@ class ProgressBar : public Logger
}
}

void logActivity(State & state, Verbosity lvl, ActInfo & act)
{
if (!act.logged && lvl <= verbosity && !act.s.empty() && act.type != actBuildWaiting) {
log(state, lvl, act.s + "...");
act.logged = true;
}
}

void startActivity(
ActivityId act,
Verbosity lvl,
Expand All @@ -206,15 +221,14 @@ class ProgressBar : public Logger
{
auto state(state_.lock());

if (lvl <= verbosity && !s.empty() && type != actBuildWaiting)
log(*state, lvl, s + "...");

state->activities.emplace_back(
ActInfo{.s = s, .type = type, .parent = parent, .startTime = std::chrono::steady_clock::now()});
auto i = std::prev(state->activities.end());
state->its.emplace(act, i);
state->activitiesByType[type].its.emplace(act, i);

logActivity(*state, lvl, *i);

if (type == actBuild) {
std::string name(storePathToName(getS(fields, 0)));
if (hasSuffix(name, ".drv"))
Expand Down