Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly determine channel for APIs with dependencies. #48

Merged
merged 1 commit into from
Mar 6, 2023
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
26 changes: 25 additions & 1 deletion tools/lib/channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,28 @@ export function mostReleasedChannel(a, b) {
} else {
return b;
}
}
}

/**
* Finds the channel that is furthest from 'stable'. If either param is `undefined`, returns the other.
*
* @param {chromeTypes.Channel | undefined} a
* @param {chromeTypes.Channel | undefined} b
* @return {chromeTypes.Channel | undefined}
*/
export function leastReleasedChannel(a, b) {
if (!a) {
return b;
} else if (!b) {
return a;
}

const indexA = channelOrdering.indexOf(a);
const indexB = channelOrdering.indexOf(b);

if (indexA > indexB) {
return a;
} else {
return b;
}
}
4 changes: 2 additions & 2 deletions tools/override.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

import * as chromeTypes from '../types/chrome.js';
import * as overrideTypes from '../types/override.js';
import { mostReleasedChannel } from './lib/channel.js';
import { leastReleasedChannel, mostReleasedChannel } from './lib/channel.js';
import { buildNamespaceAwareMarkdownRewrite } from './lib/comment.js';
import { FeatureQuery } from './lib/feature-query.js';
import { namespaceNameFromId, parentId } from './lib/traverse.js';
Expand Down Expand Up @@ -446,7 +446,7 @@ export class RenderOverride extends EmptyRenderOverride {
let bestChannel = undefined;

this.#fq.checkFeature(id, (f, otherId) => {
bestChannel = mostReleasedChannel(bestChannel, f.channel);
bestChannel = leastReleasedChannel(bestChannel, f.channel);
});

return bestChannel ?? 'stable';
Expand Down