Skip to content

Commit

Permalink
Fix prettier.sh (#8303)
Browse files Browse the repository at this point in the history
`prettier.sh` has been broken since 260b7e7 - the bash syntax `[[ -z
"${paths[*]+}" ]]` for checking whether an array is empty doesn't seem
to work.
  • Loading branch information
bduffany authored Feb 4, 2025
1 parent abfb49a commit 5c76716
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 51 deletions.
15 changes: 13 additions & 2 deletions app/invocation/cache_requests_card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,12 @@ export default class CacheRequestsCardComponent extends React.Component<CacheReq
In all other cases, this is a special cache access (e.g. for BES purposes) with
no link to an action.
*/
if (looksLikeDigest(result.actionId) || result.actionId === "input" || result.actionId === "output" || result.actionId === "prefetcher") {
if (
looksLikeDigest(result.actionId) ||
result.actionId === "input" ||
result.actionId === "output" ||
result.actionId === "prefetcher"
) {
if (groupTarget === null) {
name = result.targetId;
if (groupActionId === null) {
Expand Down Expand Up @@ -600,7 +605,13 @@ export default class CacheRequestsCardComponent extends React.Component<CacheReq
{result.actionId && (
<>
<b>Action ID</b>
<span>{result.actionId === "input" ? "input (to local execution of this action)" : result.actionId === "output" ? "output (explicitly requested)" : result.actionId} </span>
<span>
{result.actionId === "input"
? "input (to local execution of this action)"
: result.actionId === "output"
? "output (explicitly requested)"
: result.actionId}{" "}
</span>
</>
)}
{result.name ? (
Expand Down
7 changes: 4 additions & 3 deletions docs/remote-bazel-introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,10 @@ If your branch hasn’t been recently rebased against the default branch, this
patchset can be large, slowing down the CLI.

How to Fix It:
* Rebase your local branch onto the default branch.
* Push your local branch to the remote.
* Disable git mirroring with `--run_from_branch` or `--run_from_commit`.

- Rebase your local branch onto the default branch.
- Push your local branch to the remote.
- Disable git mirroring with `--run_from_branch` or `--run_from_commit`.

#### Configuring the remote runner

Expand Down
34 changes: 18 additions & 16 deletions enterprise/app/code/code_v2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -265,21 +265,23 @@ export default class CodeComponentV2 extends React.Component<Props, State> {
req.decorationsRequest.diagnostics = true;

let rsp = await rpcService.service.kytheProxy(req);
const newDecor = rsp.decorationsReply?.reference.map((x) => {
const startLine = x.span?.start?.lineNumber || 0;
const startColumn = x.span?.start?.columnOffset || 0;
const endLine = x.span?.end?.lineNumber || 0;
const endColumn = x.span?.end?.columnOffset || 0;
const monacoRange = new monaco.Range(startLine, startColumn + 1, endLine, endColumn + 1);
const displayOptions = this.getDisplayOptions(x);
if (displayOptions === null) {
return null;
}
return {
range: monacoRange,
options: displayOptions,
};
}).filter((x) => x !== null);
const newDecor = rsp.decorationsReply?.reference
.map((x) => {
const startLine = x.span?.start?.lineNumber || 0;
const startColumn = x.span?.start?.columnOffset || 0;
const endLine = x.span?.end?.lineNumber || 0;
const endColumn = x.span?.end?.columnOffset || 0;
const monacoRange = new monaco.Range(startLine, startColumn + 1, endLine, endColumn + 1);
const displayOptions = this.getDisplayOptions(x);
if (displayOptions === null) {
return null;
}
return {
range: monacoRange,
options: displayOptions,
};
})
.filter((x) => x !== null);

// Paging @jdhollen
}
Expand Down Expand Up @@ -421,7 +423,7 @@ export default class CodeComponentV2 extends React.Component<Props, State> {

if (this.currentPath()) {
const url = new URL(window.location.href);
this.fetchIfNeededAndNavigate(this.currentPath(), "?"+url.searchParams.toString());
this.fetchIfNeededAndNavigate(this.currentPath(), "?" + url.searchParams.toString());
} else {
this.editor.setValue(
["// Welcome to BuildBuddy Code!", "", "// Click on a file to the left to get start editing."].join("\n")
Expand Down
14 changes: 7 additions & 7 deletions enterprise/app/codesearch/codesearch.css
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,11 @@
}

.code-search .statsForNerds {
color: #aaa;
font-size: 0.8em;
padding: 10px 10px 10px 10px;
display: flex;
align-items: center;
justify-content: center;
flex-wrap: wrap;
color: #aaa;
font-size: 0.8em;
padding: 10px 10px 10px 10px;
display: flex;
align-items: center;
justify-content: center;
flex-wrap: wrap;
}
13 changes: 8 additions & 5 deletions enterprise/app/codesearch/codesearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default class CodeSearchComponent extends React.Component<Props, State> {
return;
}

this.setState({ loading: true, response: undefined, inputText: this.getQuery()});
this.setState({ loading: true, response: undefined, inputText: this.getQuery() });
rpcService.service
.search(new search.SearchRequest({ query: new search.Query({ term: this.getQuery() }) }))
.then((response) => {
Expand All @@ -49,10 +49,10 @@ export default class CodeSearchComponent extends React.Component<Props, State> {
.catch((e) => {
const parsedError = BuildBuddyError.parse(e);
if (parsedError.code == "InvalidArgument") {
this.setState({errorMessage: String(parsedError.description)});
this.setState({ errorMessage: String(parsedError.description) });
} else {
errorService.handleError(e);
}
}
})
.finally(() => this.setState({ loading: false }));
}
Expand Down Expand Up @@ -131,7 +131,7 @@ export default class CodeSearchComponent extends React.Component<Props, State> {
<div className="circle">
<XCircle className="icon gray" />
<h2>Invalid Search Query</h2>
<p>{this.state.errorMessage}</p>
<p>{this.state.errorMessage}</p>
</div>
</div>
);
Expand Down Expand Up @@ -162,7 +162,10 @@ export default class CodeSearchComponent extends React.Component<Props, State> {
))}
</div>
<div className="statsForNerds">
<span>Found {this.getStat("TOTAL_DOCS_SCORED_COUNT")} results ({(this.getStat("TOTAL_SEARCH_DURATION")/1e6).toFixed(2)}ms)</span>
<span>
Found {this.getStat("TOTAL_DOCS_SCORED_COUNT")} results (
{(this.getStat("TOTAL_SEARCH_DURATION") / 1e6).toFixed(2)}ms)
</span>
</div>
</div>
);
Expand Down
14 changes: 5 additions & 9 deletions enterprise/app/tap/flakes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,7 @@ export default class FlakesComponent extends React.Component<Props, State> {
target={targetLabel}
testSuite={testSuite}
testResult={s.event!.testResult!}
dark={this.props.dark}
></TargetFlakyTestCardComponent>
dark={this.props.dark}></TargetFlakyTestCardComponent>
);
});
} else if (testXmlDoc.testLogString) {
Expand All @@ -378,8 +377,7 @@ export default class FlakesComponent extends React.Component<Props, State> {
target={targetLabel}
logContents={testXmlDoc.testLogString}
testResult={s.event!.testResult!}
dark={this.props.dark}
></FlakyTargetSampleLogCardComponent>
dark={this.props.dark}></FlakyTargetSampleLogCardComponent>
);
}
})}
Expand Down Expand Up @@ -416,7 +414,7 @@ export default class FlakesComponent extends React.Component<Props, State> {
);
}

let tableData = singleTarget ? [] : this.state.tableData?.stats ?? [];
let tableData = singleTarget ? [] : (this.state.tableData?.stats ?? []);
let sortFn: (a: target.AggregateTargetStats, b: target.AggregateTargetStats) => number;
if (this.state.tableSort === "Flakes") {
sortFn = (a, b) => {
Expand Down Expand Up @@ -490,8 +488,7 @@ export default class FlakesComponent extends React.Component<Props, State> {
<TapEmptyStateComponent
title="No flakes found!"
message="Wow! Either you have no flaky CI tests, or no CI test data all. To see CI test data, make sure your CI tests are configured as follows:"
showV2Instructions={true}
></TapEmptyStateComponent>
showV2Instructions={true}></TapEmptyStateComponent>
);
}

Expand Down Expand Up @@ -526,8 +523,7 @@ export default class FlakesComponent extends React.Component<Props, State> {
}}
formatXAxisLabel={(ts) => moment.unix(ts).format("MMM D")}
formatHoverXAxisLabel={(ts) => moment.unix(ts).format("dddd, MMMM Do YYYY")}
ticks={[]}
></TrendsChartComponent>
ticks={[]}></TrendsChartComponent>
</div>
</div>
{tableData.length > 0 && (
Expand Down
25 changes: 16 additions & 9 deletions tools/prettier/prettier.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,20 @@

# --- begin runfiles.bash initialization v3 ---
# Copy-pasted from the Bazel Bash runfiles library v3.
set -uo pipefail; set +e; f=bazel_tools/tools/bash/runfiles/runfiles.bash
source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \
source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null || \
source "$0.runfiles/$f" 2>/dev/null || \
source "$(grep -sm1 "^$f " "$0.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \
source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \
{ echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e
set -uo pipefail
set +e
f=bazel_tools/tools/bash/runfiles/runfiles.bash
source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null ||
source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null ||
source "$0.runfiles/$f" 2>/dev/null ||
source "$(grep -sm1 "^$f " "$0.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null ||
source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null ||
{
echo >&2 "ERROR: cannot find $f"
exit 1
}
f=
set -e
# --- end runfiles.bash initialization v3 ---

if [[ -n "${BUILD_WORKSPACE_DIRECTORY}" ]]; then
Expand Down Expand Up @@ -58,7 +65,7 @@ function paths_to_format() {
# not just changed files:
# - The prettier version in yarn.lock
# - Any prettier configuration in .prettierrc
if (git diff "$DIFF_BASE" -- yarn.lock | grep -q prettier) || (git diff "$DIFF_BASE" -- .prettierrc | grep -q .); then
if (git diff "$DIFF_BASE" -- yarn.lock | grep -q prettier) || (git diff "$DIFF_BASE" -- .prettierrc tools/prettier/prettier.sh | grep -q .); then
git ls-files -- "${GIT_FILE_PATTERNS[@]}"
else
git diff --name-only --diff-filter=AMRCT "$DIFF_BASE" -- "${GIT_FILE_PATTERNS[@]}"
Expand All @@ -70,7 +77,7 @@ while read -r path; do
paths+=("$path")
done < <(paths_to_format)

if [[ -z "${paths[*]+}" ]]; then
if [[ ${#paths} -eq -0 ]]; then
exit 0
fi

Expand Down

0 comments on commit 5c76716

Please sign in to comment.