content_type
stringclasses 8
values | main_lang
stringclasses 7
values | message
stringlengths 1
50
| sha
stringlengths 40
40
| patch
stringlengths 52
962k
| file_count
int64 1
300
|
---|---|---|---|---|---|
Text | Text | codify trans tag | 4b26f679fd819609a751743918ca41725d9291dc | <ide><path>docs/how-to-translate-the-website.md
<ide> const username = 'moT';
<ide>
<ide> The above example passes an object to the `t` function with a `username` variable. The variable will be used in the JSON value where `{{username}}` is.
<ide>
<del>## Translate with the \<Trans\> Component
<add>## Translate with the `Trans` Component
<ide>
<ide> The general rule is to use the "t" function when you can. But there's a `Trans` component for when that isn't enough, usually when you have elements embedded in the text. You can use the `Trans` component with any type of react component.
<ide> | 1 |
Text | Text | clarify rewrites and other docs cleanup. | f6c60946a300cf0b29977ae027b0c0cc056d8602 | <ide><path>docs/api-reference/next.config.js/basepath.md
<ide> description: Learn more about setting a base path in Next.js
<ide>
<ide> # Base Path
<ide>
<del>> This feature was introduced in [Next.js 9.5](https://nextjs.org/blog/next-9-5) and up. If you’re using older versions of Next.js, please upgrade before trying it out.
<add><details>
<add> <summary><b>Version History</b></summary>
<add>
<add>| Version | Changes |
<add>| -------- | ---------------- |
<add>| `v9.5.0` | Base Path added. |
<add>
<add></details>
<ide>
<ide> To deploy a Next.js application under a sub-path of a domain you can use the `basePath` config option.
<ide>
<ide><path>docs/api-reference/next.config.js/headers.md
<ide> description: Add custom HTTP headers to your Next.js app.
<ide>
<ide> # Headers
<ide>
<del>> This feature was introduced in [Next.js 9.5](https://nextjs.org/blog/next-9-5) and up. If you’re using older versions of Next.js, please upgrade before trying it out.
<del>
<ide> <details open>
<ide> <summary><b>Examples</b></summary>
<ide> <ul>
<ide> description: Add custom HTTP headers to your Next.js app.
<ide> <details>
<ide> <summary><b>Version History</b></summary>
<ide>
<del>| Version | Changes |
<del>| --------- | ------------ |
<del>| `v10.2.0` | `has` added. |
<add>| Version | Changes |
<add>| --------- | -------------- |
<add>| `v10.2.0` | `has` added. |
<add>| `v9.5.0` | Headers added. |
<ide>
<ide> </details>
<ide>
<ide><path>docs/api-reference/next.config.js/redirects.md
<ide> description: Add redirects to your Next.js app.
<ide>
<ide> # Redirects
<ide>
<del>> This feature was introduced in [Next.js 9.5](https://nextjs.org/blog/next-9-5) and up. If you’re using older versions of Next.js, please upgrade before trying it out.
<del>
<ide> <details open>
<ide> <summary><b>Examples</b></summary>
<ide> <ul>
<ide> description: Add redirects to your Next.js app.
<ide> <details>
<ide> <summary><b>Version History</b></summary>
<ide>
<del>| Version | Changes |
<del>| --------- | ------------ |
<del>| `v10.2.0` | `has` added. |
<add>| Version | Changes |
<add>| --------- | ---------------- |
<add>| `v10.2.0` | `has` added. |
<add>| `v9.5.0` | Redirects added. |
<ide>
<ide> </details>
<ide>
<ide><path>docs/api-reference/next.config.js/rewrites.md
<ide> description: Add rewrites to your Next.js app.
<ide>
<ide> # Rewrites
<ide>
<del>> This feature was introduced in [Next.js 9.5](https://nextjs.org/blog/next-9-5) and up. If you’re using older versions of Next.js, please upgrade before trying it out.
<del>
<ide> <details open>
<ide> <summary><b>Examples</b></summary>
<ide> <ul>
<ide> description: Add rewrites to your Next.js app.
<ide> <details>
<ide> <summary><b>Version History</b></summary>
<ide>
<del>| Version | Changes |
<del>| --------- | ------------ |
<del>| `v10.2.0` | `has` added. |
<add>| Version | Changes |
<add>| --------- | --------------- |
<add>| `v10.2.0` | `has` added. |
<add>| `v9.5.0` | Rewrites added. |
<ide>
<ide> </details>
<ide>
<ide> Rewrites allow you to map an incoming request path to a different destination path.
<ide>
<add>Rewrites act as a URL proxy and mask the destination path, making it appear the user hasn't changed their location on the site. In contrast, [redirects](/docs/api-reference/next.config.js/redirects.md) will reroute to a new page a show the URL changes.
<add>
<ide> Rewrites are only available on the Node.js environment and do not affect client-side routing.
<ide>
<ide> To use rewrites you can use the `rewrites` key in `next.config.js`:
<ide> module.exports = {
<ide> }
<ide> ```
<ide>
<del>See additional information on incremental adoption [in the docs here](https://nextjs.org/docs/migrating/incremental-adoption).
<add>See additional information on incremental adoption [in the docs here](/docs/migrating/incremental-adoption.md).
<ide>
<ide> ### Rewrites with basePath support
<ide>
<ide><path>docs/api-reference/next.config.js/trailing-slash.md
<ide> description: Configure Next.js pages to resolve with or without a trailing slash
<ide>
<ide> # Trailing Slash
<ide>
<del>> This feature was introduced in [Next.js 9.5](https://nextjs.org/blog/next-9-5) and up. If you’re using older versions of Next.js, please upgrade before trying it out.
<add><details>
<add> <summary><b>Version History</b></summary>
<add>
<add>| Version | Changes |
<add>| -------- | --------------------- |
<add>| `v9.5.0` | Trailing Slash added. |
<add>
<add></details>
<ide>
<ide> By default Next.js will redirect urls with trailing slashes to their counterpart without a trailing slash. For example `/about/` will redirect to `/about`. You can configure this behavior to act the opposite way, where urls without trailing slashes are redirected to their counterparts with trailing slashes.
<ide>
<ide><path>docs/basic-features/data-fetching.md
<ide> export default Blog
<ide>
<ide> ### Incremental Static Regeneration
<ide>
<del>> This feature was introduced in [Next.js 9.5](https://nextjs.org/blog/next-9-5#stable-incremental-static-regeneration) and up. If you’re using older versions of Next.js, please upgrade before trying Incremental Static Regeneration.
<del>
<ide> <details open>
<ide> <summary><b>Examples</b></summary>
<ide> <ul>
<del> <li><a href="https://reactions-demo.vercel.app/">Static Reactions Demo</a></li>
<add> <li><a href="https://nextjs.org/commerce">Next.js Commerce</a></li>
<add> <li><a href="https://reactions-demo.vercel.app/">GitHub Reactions Demo</a></li>
<add> <li><a href="https://static-tweet.vercel.app/">Static Tweet Demo</a></li>
<ide> </ul>
<ide> </details>
<ide>
<del>With [`getStaticProps`](#getstaticprops-static-generation) you don't have to stop relying on dynamic content, as **static content can also be dynamic**. Incremental Static Regeneration allows you to update _existing_ pages by re-rendering them in the background as traffic comes in.
<add><details>
<add> <summary><b>Version History</b></summary>
<add>
<add>| Version | Changes |
<add>| -------- | ---------------- |
<add>| `v9.5.0` | Base Path added. |
<ide>
<del>Inspired by [stale-while-revalidate](https://tools.ietf.org/html/rfc5861), background regeneration ensures traffic is served uninterruptedly, always from static storage, and the newly built page is pushed only after it's done generating.
<add></details>
<ide>
<del>Consider our previous [`getStaticProps` example](#simple-example), but now with regeneration enabled:
<add>Next.js allows you to create or update static pages _after_ you’ve built your site. Incremental Static Regeneration (ISR) enables you to use static-generation on a per-page basis, **without needing to rebuild the entire site**. With ISR, you can retain the benefits of static while scaling to millions of pages.
<add>
<add>Consider our previous [`getStaticProps` example](#simple-example), but now with Incremental Static Regeneration enabled through the `revalidate` property:
<ide>
<ide> ```jsx
<ide> function Blog({ posts }) {
<ide> export async function getStaticProps() {
<ide> },
<ide> // Next.js will attempt to re-generate the page:
<ide> // - When a request comes in
<del> // - At most once every second
<del> revalidate: 1, // In seconds
<add> // - At most once every 10 seconds
<add> revalidate: 10, // In seconds
<ide> }
<ide> }
<ide>
<add>// This function gets called at build time on server-side.
<add>// It may be called again, on a serverless function, if
<add>// the path has not been generated.
<add>export async function getStaticPaths() {
<add> const res = await fetch('https://.../posts')
<add> const posts = await res.json()
<add>
<add> // Get the paths we want to pre-render based on posts
<add> const paths = posts.map((post) => ({
<add> params: { id: post.id },
<add> }))
<add>
<add> // We'll pre-render only these paths at build time.
<add> // { fallback: blocking } will server-render pages
<add> // on-demand if the path doesn't exist.
<add> return { paths, fallback: 'blocking' }
<add>}
<add>
<ide> export default Blog
<ide> ```
<ide>
<del>Now the list of blog posts will be revalidated once per second; if you add a new blog post it will be available almost immediately, without having to re-build your app or make a new deployment.
<del>
<del>This works perfectly with [`fallback: true`](#fallback-true). Because now you can have a list of posts that's always up to date with the latest posts, and have a [blog post page](#fallback-pages) that generates blog posts on-demand, no matter how many posts you add or update.
<add>When a request is made to a page that was pre-rendered at build time, it will initially show the cached page.
<ide>
<del>#### Static content at scale
<add>- Any requests to the page after the initial request and before 10 seconds are also cached and instantaneous.
<add>- After the 10-second window, the next request will still show the cached (stale) page
<add>- Next.js triggers a regeneration of the page in the background.
<add>- Once the page has been successfully generated, Next.js will invalidate the cache and show the updated product page. If the background regeneration fails, the old page remains unaltered.
<ide>
<del>Unlike traditional SSR, [Incremental Static Regeneration](#incremental-static-regeneration) ensures you retain the benefits of static:
<add>When a request is made to a path that hasn’t been generated, Next.js will server-render the page on the first request. Future requests will serve the static file from the cache.
<ide>
<del>- No spikes in latency. Pages are served consistently fast
<del>- Pages never go offline. If the background page re-generation fails, the old page remains unaltered
<del>- Low database and backend load. Pages are re-computed at most once concurrently
<add>To learn how to persist the cache globally and handle rollbacks, learn more about [Incremental Static Regeneration](https://vercel.com/docs/next.js/incremental-static-regeneration).
<ide>
<ide> ### Reading files: Use `process.cwd()`
<ide> | 6 |
Java | Java | fix memory leak | 9dc03854056e766f7beaf03a89c7409f34607d8b | <ide><path>ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java
<ide> public void onCatalystInstanceDestroy() {
<ide>
<ide> getReactApplicationContext().unregisterComponentCallbacks(mMemoryTrimCallback);
<ide> YogaNodePool.get().clear();
<add> ViewManagerPropertyUpdater.clear();
<ide> }
<ide>
<ide> private static Map<String, Object> createConstants(
<ide><path>ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManagerPropertyUpdater.java
<ide> public interface Settable {
<ide> new HashMap<>();
<ide> private static final Map<Class<?>, ShadowNodeSetter<?>> SHADOW_NODE_SETTER_MAP = new HashMap<>();
<ide>
<add> public static void clear() {
<add> ViewManagersPropertyCache.clear();
<add> VIEW_MANAGER_SETTER_MAP.clear();
<add> SHADOW_NODE_SETTER_MAP.clear();
<add> }
<add>
<ide> public static <T extends ViewManager, V extends View> void updateProps(
<ide> T manager,
<ide> V v,
<ide><path>ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManagersPropertyCache.java
<ide> private static final Map<Class, Map<String, PropSetter>> CLASS_PROPS_CACHE = new HashMap<>();
<ide> private static final Map<String, PropSetter> EMPTY_PROPS_MAP = new HashMap<>();
<ide>
<add> public static void clear() {
<add> CLASS_PROPS_CACHE.clear();
<add> EMPTY_PROPS_MAP.clear();
<add> }
<add>
<ide> /*package*/ static abstract class PropSetter {
<ide>
<ide> protected final String mPropName; | 3 |
Text | Text | remove unmaintained digest authentication package | facb433c89ae52a618857b50a1bdf109392c380c | <ide><path>docs/api-guide/authentication.md
<ide> Install the package using `pip`.
<ide>
<ide> For details on configuration and usage see the Django REST framework OAuth documentation for [authentication][django-rest-framework-oauth-authentication] and [permissions][django-rest-framework-oauth-permissions].
<ide>
<del>## Digest Authentication
<del>
<del>HTTP digest authentication is a widely implemented scheme that was intended to replace HTTP basic authentication, and which provides a simple encrypted authentication mechanism. [Juan Riaza][juanriaza] maintains the [djangorestframework-digestauth][djangorestframework-digestauth] package which provides HTTP digest authentication support for REST framework.
<del>
<ide> ## JSON Web Token Authentication
<ide>
<ide> JSON Web Token is a fairly new standard which can be used for token-based authentication. Unlike the built-in TokenAuthentication scheme, JWT Authentication doesn't need to use a database to validate a token. A package for JWT authentication is [djangorestframework-simplejwt][djangorestframework-simplejwt] which provides some features as well as a pluggable token blacklist app. | 1 |
Javascript | Javascript | fix react native open source | 63f990121ad5f58dfd07ccfed2bb640b08164f73 | <ide><path>IntegrationTests/IntegrationTestsApp.js
<ide> class IntegrationTestsApp extends React.Component<{}, $FlowFixMeState> {
<ide> if (this.state.test) {
<ide> return (
<ide> <ScrollView>
<del> {/* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses
<del> * an error when upgrading Flow's support for React. Common errors
<del> * found when upgrading Flow's React support are documented at
<del> * https://fburl.com/eq7bs81w */}
<add> {/* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This
<add> * comment suppresses an error when upgrading Flow's support for
<add> * React. To see the error delete this comment and run Flow. */}
<ide> <this.state.test />
<ide> </ScrollView>
<ide> );
<ide><path>Libraries/Animated/src/AnimatedEvent.js
<ide> class AnimatedEvent {
<ide> recMapping.setValue(recEvt);
<ide> } else if (typeof recMapping === 'object') {
<ide> for (const mappingKey in recMapping) {
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment
<del> * suppresses an error found when Flow v0.53 was deployed. To see
<del> * the error delete this comment and run Flow. */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This
<add> * comment suppresses an error when upgrading Flow's support for
<add> * React. To see the error delete this comment and run Flow. */
<ide> traverse(recMapping[mappingKey], recEvt[mappingKey], mappingKey);
<ide> }
<ide> }
<ide><path>Libraries/Components/ActivityIndicator/ActivityIndicator.js
<ide> type DefaultProps = {
<ide> /**
<ide> * Displays a circular loading indicator.
<ide> */
<del>/* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses an error
<del> * found when Flow v0.53 was deployed. To see the error delete this comment and
<del> * run Flow. */
<add>/* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This comment
<add> * suppresses an error when upgrading Flow's support for React. To see the
<add> * error delete this comment and run Flow. */
<ide> const ActivityIndicator = createReactClass({
<ide> displayName: 'ActivityIndicator',
<ide> mixins: [NativeMethodsMixin],
<ide><path>Libraries/Components/CheckBox/CheckBox.js
<ide> let CheckBox = createReactClass({
<ide> <RCTCheckBox
<ide> {...props}
<ide> ref={ref => {
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses an
<del> * error when upgrading Flow's support for React. Common errors found
<del> * when upgrading Flow's React support are documented at
<del> * https://fburl.com/eq7bs81w */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This
<add> * comment suppresses an error when upgrading Flow's support for
<add> * React. To see the error delete this comment and run Flow. */
<ide> this._rctCheckBox = ref;
<ide> }}
<ide> onChange={this._onChange}
<ide><path>Libraries/Components/ScrollView/ScrollView.js
<ide> const ScrollView = createReactClass({
<ide> },
<ide>
<ide> _getKeyForIndex: function(index, childArray) {
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses an
<del> * error found when Flow v0.53 was deployed. To see the error delete this
<del> * comment and run Flow. */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This comment
<add> * suppresses an error when upgrading Flow's support for React. To see the
<add> * error delete this comment and run Flow. */
<ide> const child = childArray[index];
<ide> return child && child.key;
<ide> },
<ide> const ScrollView = createReactClass({
<ide> if (!this.props.stickyHeaderIndices) {
<ide> return;
<ide> }
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses an
<del> * error found when Flow v0.53 was deployed. To see the error delete this
<del> * comment and run Flow. */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This comment
<add> * suppresses an error when upgrading Flow's support for React. To see the
<add> * error delete this comment and run Flow. */
<ide> const childArray = React.Children.toArray(this.props.children);
<ide> if (key !== this._getKeyForIndex(index, childArray)) {
<ide> // ignore stale layout update
<ide> const ScrollView = createReactClass({
<ide> const layoutY = event.nativeEvent.layout.y;
<ide> this._headerLayoutYs.set(key, layoutY);
<ide>
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses an
<del> * error found when Flow v0.53 was deployed. To see the error delete this
<del> * comment and run Flow. */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This comment
<add> * suppresses an error when upgrading Flow's support for React. To see the
<add> * error delete this comment and run Flow. */
<ide> const indexOfIndex = this.props.stickyHeaderIndices.indexOf(index);
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses an
<del> * error found when Flow v0.53 was deployed. To see the error delete this
<del> * comment and run Flow. */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This comment
<add> * suppresses an error when upgrading Flow's support for React. To see the
<add> * error delete this comment and run Flow. */
<ide> const previousHeaderIndex = this.props.stickyHeaderIndices[indexOfIndex - 1];
<ide> if (previousHeaderIndex != null) {
<ide> const previousHeader = this._stickyHeaderRefs.get(
<ide> const ScrollView = createReactClass({
<ide>
<ide> const {stickyHeaderIndices} = this.props;
<ide> const hasStickyHeaders = stickyHeaderIndices && stickyHeaderIndices.length > 0;
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses an
<del> * error found when Flow v0.53 was deployed. To see the error delete this
<del> * comment and run Flow. */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This comment
<add> * suppresses an error when upgrading Flow's support for React. To see the
<add> * error delete this comment and run Flow. */
<ide> const childArray = hasStickyHeaders && React.Children.toArray(this.props.children);
<ide> const children = hasStickyHeaders ?
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses an
<del> * error found when Flow v0.53 was deployed. To see the error delete this
<del> * comment and run Flow. */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This
<add> * comment suppresses an error when upgrading Flow's support for React.
<add> * To see the error delete this comment and run Flow. */
<ide> childArray.map((child, index) => {
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses an
<del> * error found when Flow v0.53 was deployed. To see the error delete
<del> * this comment and run Flow. */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This
<add> * comment suppresses an error when upgrading Flow's support for React.
<add> * To see the error delete this comment and run Flow. */
<ide> const indexOfIndex = child ? stickyHeaderIndices.indexOf(index) : -1;
<ide> if (indexOfIndex > -1) {
<ide> const key = child.key;
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses
<del> * an error found when Flow v0.53 was deployed. To see the error
<del> * delete this comment and run Flow. */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This
<add> * comment suppresses an error when upgrading Flow's support for
<add> * React. To see the error delete this comment and run Flow. */
<ide> const nextIndex = stickyHeaderIndices[indexOfIndex + 1];
<ide> return (
<ide> <ScrollViewStickyHeader
<ide> key={key}
<ide> ref={(ref) => this._setStickyHeaderRef(key, ref)}
<ide> nextHeaderLayoutY={
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment
<del> * suppresses an error found when Flow v0.53 was deployed. To
<del> * see the error delete this comment and run Flow. */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss)
<add> * This comment suppresses an error when upgrading Flow's
<add> * support for React. To see the error delete this comment and
<add> * run Flow. */
<ide> this._headerLayoutYs.get(this._getKeyForIndex(nextIndex, childArray))
<ide> }
<ide> onLayout={(event) => this._onStickyHeaderLayout(index, event, key)}
<ide> const ScrollView = createReactClass({
<ide> return child;
<ide> }
<ide> }) :
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses an
<del> * error found when Flow v0.53 was deployed. To see the error delete this
<del> * comment and run Flow. */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This
<add> * comment suppresses an error when upgrading Flow's support for React.
<add> * To see the error delete this comment and run Flow. */
<ide> this.props.children;
<ide> const contentContainer =
<ide> <ScrollContentContainerViewClass
<ide> {...contentSizeChangeProps}
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses an
<del> * error when upgrading Flow's support for React. Common errors found
<del> * when upgrading Flow's React support are documented at
<del> * https://fburl.com/eq7bs81w */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This
<add> * comment suppresses an error when upgrading Flow's support for React.
<add> * To see the error delete this comment and run Flow. */
<ide> ref={this._setInnerViewRef}
<ide> style={contentContainerStyle}
<ide> removeClippedSubviews={
<ide> const ScrollView = createReactClass({
<ide> onResponderGrant: this.scrollResponderHandleResponderGrant,
<ide> onResponderReject: this.scrollResponderHandleResponderReject,
<ide> onResponderRelease: this.scrollResponderHandleResponderRelease,
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses an
<del> * error found when Flow v0.53 was deployed. To see the error delete this
<del> * comment and run Flow. */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This
<add> * comment suppresses an error when upgrading Flow's support for React.
<add> * To see the error delete this comment and run Flow. */
<ide> onResponderTerminate: this.scrollResponderHandleTerminate,
<ide> onResponderTerminationRequest: this.scrollResponderHandleTerminationRequest,
<ide> onScroll: this._handleScroll,
<ide> const ScrollView = createReactClass({
<ide> // On iOS the RefreshControl is a child of the ScrollView.
<ide> // tvOS lacks native support for RefreshControl, so don't include it in that case
<ide> return (
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses
<del> * an error when upgrading Flow's support for React. Common errors
<del> * found when upgrading Flow's React support are documented at
<del> * https://fburl.com/eq7bs81w */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This
<add> * comment suppresses an error when upgrading Flow's support for
<add> * React. To see the error delete this comment and run Flow. */
<ide> <ScrollViewClass {...props} ref={this._setScrollViewRef}>
<ide> {Platform.isTVOS ? null : refreshControl}
<ide> {contentContainer}
<ide> const ScrollView = createReactClass({
<ide> return React.cloneElement(
<ide> refreshControl,
<ide> {style: props.style},
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses
<del> * an error when upgrading Flow's support for React. Common errors
<del> * found when upgrading Flow's React support are documented at
<del> * https://fburl.com/eq7bs81w */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This
<add> * comment suppresses an error when upgrading Flow's support for
<add> * React. To see the error delete this comment and run Flow. */
<ide> <ScrollViewClass {...props} style={baseStyle} ref={this._setScrollViewRef}>
<ide> {contentContainer}
<ide> </ScrollViewClass>
<ide> );
<ide> }
<ide> }
<ide> return (
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses an
<del> * error when upgrading Flow's support for React. Common errors found
<del> * when upgrading Flow's React support are documented at
<del> * https://fburl.com/eq7bs81w */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This
<add> * comment suppresses an error when upgrading Flow's support for React.
<add> * To see the error delete this comment and run Flow. */
<ide> <ScrollViewClass {...props} ref={this._setScrollViewRef}>
<ide> {contentContainer}
<ide> </ScrollViewClass>
<ide><path>Libraries/Components/Switch/Switch.js
<ide> var Switch = createReactClass({
<ide> this._rctSwitch.setNativeProps({value: this.props.value});
<ide> }
<ide> //Change the props after the native props are set in case the props change removes the component
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses an
<del> * error found when Flow v0.53 was deployed. To see the error delete this
<del> * comment and run Flow. */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This comment
<add> * suppresses an error when upgrading Flow's support for React. To see the
<add> * error delete this comment and run Flow. */
<ide> this.props.onChange && this.props.onChange(event);
<ide> this.props.onValueChange && this.props.onValueChange(event.nativeEvent.value);
<ide> },
<ide> var Switch = createReactClass({
<ide> return (
<ide> <RCTSwitch
<ide> {...props}
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses an
<del> * error when upgrading Flow's support for React. Common errors found
<del> * when upgrading Flow's React support are documented at
<del> * https://fburl.com/eq7bs81w */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This
<add> * comment suppresses an error when upgrading Flow's support for React.
<add> * To see the error delete this comment and run Flow. */
<ide> ref={(ref) => { this._rctSwitch = ref; }}
<ide> onChange={this._onChange}
<ide> />
<ide><path>Libraries/Components/TextInput/TextInput.js
<ide> const TextInput = createReactClass({
<ide> }
<ide> props.autoCapitalize =
<ide> UIManager.AndroidTextInput.Constants.AutoCapitalizationType[this.props.autoCapitalize];
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses an
<del> * error found when Flow v0.53 was deployed. To see the error delete this
<del> * comment and run Flow. */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This comment
<add> * suppresses an error when upgrading Flow's support for React. To see the
<add> * error delete this comment and run Flow. */
<ide> var children = this.props.children;
<ide> var childCount = 0;
<ide> React.Children.forEach(children, () => ++childCount);
<ide> const TextInput = createReactClass({
<ide> },
<ide>
<ide> _onTextInput: function(event: Event) {
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses an
<del> * error found when Flow v0.53 was deployed. To see the error delete this
<del> * comment and run Flow. */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This comment
<add> * suppresses an error when upgrading Flow's support for React. To see the
<add> * error delete this comment and run Flow. */
<ide> this.props.onTextInput && this.props.onTextInput(event);
<ide> },
<ide>
<ide><path>Libraries/Components/Touchable/TouchableBounce.js
<ide> var TouchableBounce = createReactClass({
<ide> render: function(): React.Element<any> {
<ide> return (
<ide> <Animated.View
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses an
<del> * error when upgrading Flow's support for React. Common errors found
<del> * when upgrading Flow's React support are documented at
<del> * https://fburl.com/eq7bs81w */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This
<add> * comment suppresses an error when upgrading Flow's support for React.
<add> * To see the error delete this comment and run Flow. */
<ide> style={[{transform: [{scale: this.state.scale}]}, this.props.style]}
<ide> accessible={this.props.accessible !== false}
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses an
<del> * error when upgrading Flow's support for React. Common errors found
<del> * when upgrading Flow's React support are documented at
<del> * https://fburl.com/eq7bs81w */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This
<add> * comment suppresses an error when upgrading Flow's support for React.
<add> * To see the error delete this comment and run Flow. */
<ide> accessibilityLabel={this.props.accessibilityLabel}
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses an
<del> * error when upgrading Flow's support for React. Common errors found
<del> * when upgrading Flow's React support are documented at
<del> * https://fburl.com/eq7bs81w */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This
<add> * comment suppresses an error when upgrading Flow's support for React.
<add> * To see the error delete this comment and run Flow. */
<ide> accessibilityComponentType={this.props.accessibilityComponentType}
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses an
<del> * error when upgrading Flow's support for React. Common errors found
<del> * when upgrading Flow's React support are documented at
<del> * https://fburl.com/eq7bs81w */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This
<add> * comment suppresses an error when upgrading Flow's support for React.
<add> * To see the error delete this comment and run Flow. */
<ide> accessibilityTraits={this.props.accessibilityTraits}
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses an
<del> * error when upgrading Flow's support for React. Common errors found
<del> * when upgrading Flow's React support are documented at
<del> * https://fburl.com/eq7bs81w */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This
<add> * comment suppresses an error when upgrading Flow's support for React.
<add> * To see the error delete this comment and run Flow. */
<ide> nativeID={this.props.nativeID}
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses an
<del> * error when upgrading Flow's support for React. Common errors found
<del> * when upgrading Flow's React support are documented at
<del> * https://fburl.com/eq7bs81w */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This
<add> * comment suppresses an error when upgrading Flow's support for React.
<add> * To see the error delete this comment and run Flow. */
<ide> testID={this.props.testID}
<ide> hitSlop={this.props.hitSlop}
<ide> onStartShouldSetResponder={this.touchableHandleStartShouldSetResponder}
<ide><path>Libraries/Components/Touchable/TouchableHighlight.js
<ide> var TouchableHighlight = createReactClass({
<ide> },
<ide>
<ide> getInitialState: function() {
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses an
<del> * error found when Flow v0.53 was deployed. To see the error delete this
<del> * comment and run Flow. */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This comment
<add> * suppresses an error when upgrading Flow's support for React. To see the
<add> * error delete this comment and run Flow. */
<ide> this._isMounted = false;
<ide> return merge(
<ide> this.touchableGetInitialState(), this._computeSyntheticState(this.props)
<ide> );
<ide> },
<ide>
<ide> componentDidMount: function() {
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses an
<del> * error found when Flow v0.53 was deployed. To see the error delete this
<del> * comment and run Flow. */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This comment
<add> * suppresses an error when upgrading Flow's support for React. To see the
<add> * error delete this comment and run Flow. */
<ide> this._isMounted = true;
<ide> ensurePositiveDelayProps(this.props);
<ide> ensureComponentIsNative(this.refs[CHILD_REF]);
<ide> },
<ide>
<ide> componentWillUnmount: function() {
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses an
<del> * error found when Flow v0.53 was deployed. To see the error delete this
<del> * comment and run Flow. */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This comment
<add> * suppresses an error when upgrading Flow's support for React. To see the
<add> * error delete this comment and run Flow. */
<ide> this._isMounted = false;
<ide> },
<ide>
<ide> var TouchableHighlight = createReactClass({
<ide> */
<ide> touchableHandleActivePressIn: function(e: Event) {
<ide> this.clearTimeout(this._hideTimeout);
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses an
<del> * error found when Flow v0.53 was deployed. To see the error delete this
<del> * comment and run Flow. */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This comment
<add> * suppresses an error when upgrading Flow's support for React. To see the
<add> * error delete this comment and run Flow. */
<ide> this._hideTimeout = null;
<ide> this._showUnderlay();
<ide> this.props.onPressIn && this.props.onPressIn(e);
<ide> var TouchableHighlight = createReactClass({
<ide> touchableHandlePress: function(e: Event) {
<ide> this.clearTimeout(this._hideTimeout);
<ide> this._showUnderlay();
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses an
<del> * error found when Flow v0.53 was deployed. To see the error delete this
<del> * comment and run Flow. */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This comment
<add> * suppresses an error when upgrading Flow's support for React. To see the
<add> * error delete this comment and run Flow. */
<ide> this._hideTimeout = this.setTimeout(this._hideUnderlay,
<ide> this.props.delayPressOut || 100);
<ide> this.props.onPress && this.props.onPress(e);
<ide> var TouchableHighlight = createReactClass({
<ide>
<ide> _hideUnderlay: function() {
<ide> this.clearTimeout(this._hideTimeout);
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses an
<del> * error found when Flow v0.53 was deployed. To see the error delete this
<del> * comment and run Flow. */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This comment
<add> * suppresses an error when upgrading Flow's support for React. To see the
<add> * error delete this comment and run Flow. */
<ide> this._hideTimeout = null;
<ide> if (this._hasPressHandler() && this.refs[UNDERLAY_REF]) {
<ide> this.refs[CHILD_REF].setNativeProps(INACTIVE_CHILD_PROPS);
<ide> var TouchableHighlight = createReactClass({
<ide> return (
<ide> <View
<ide> accessible={this.props.accessible !== false}
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses an
<del> * error found when Flow v0.53 was deployed. To see the error delete
<del> * this comment and run Flow. */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This
<add> * comment suppresses an error when upgrading Flow's support for React.
<add> * To see the error delete this comment and run Flow. */
<ide> accessibilityLabel={this.props.accessibilityLabel}
<ide> accessibilityComponentType={this.props.accessibilityComponentType}
<ide> accessibilityTraits={this.props.accessibilityTraits}
<ide> var TouchableHighlight = createReactClass({
<ide> onResponderMove={this.touchableHandleResponderMove}
<ide> onResponderRelease={this.touchableHandleResponderRelease}
<ide> onResponderTerminate={this.touchableHandleResponderTerminate}
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses an
<del> * error found when Flow v0.53 was deployed. To see the error delete
<del> * this comment and run Flow. */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This
<add> * comment suppresses an error when upgrading Flow's support for React.
<add> * To see the error delete this comment and run Flow. */
<ide> nativeID={this.props.nativeID}
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses an
<del> * error found when Flow v0.53 was deployed. To see the error delete
<del> * this comment and run Flow. */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This
<add> * comment suppresses an error when upgrading Flow's support for React.
<add> * To see the error delete this comment and run Flow. */
<ide> testID={this.props.testID}>
<ide> {React.cloneElement(
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses
<del> * an error found when Flow v0.53 was deployed. To see the error
<del> * delete this comment and run Flow. */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This
<add> * comment suppresses an error when upgrading Flow's support for
<add> * React. To see the error delete this comment and run Flow. */
<ide> React.Children.only(this.props.children),
<ide> {
<ide> ref: CHILD_REF,
<ide><path>Libraries/Experimental/SwipeableRow/SwipeableListView.js
<ide> class SwipeableListView extends React.Component<Props, State> {
<ide>
<ide> render(): React.Node {
<ide> return (
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses an
<del> * error found when Flow v0.53 was deployed. To see the error delete this
<del> * comment and run Flow. */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This
<add> * comment suppresses an error when upgrading Flow's support for React.
<add> * To see the error delete this comment and run Flow. */
<ide> <ListView
<ide> {...this.props}
<ide> ref={(ref) => {
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses
<del> * an error when upgrading Flow's support for React. Common errors
<del> * found when upgrading Flow's React support are documented at
<del> * https://fburl.com/eq7bs81w */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This
<add> * comment suppresses an error when upgrading Flow's support for
<add> * React. To see the error delete this comment and run Flow. */
<ide> this._listViewRef = ref;
<ide> }}
<ide> dataSource={this.state.dataSource.getDataSource()}
<ide><path>Libraries/Experimental/WindowedListView.js
<ide> class CellRenderer extends React.Component<CellProps> {
<ide> return newProps.rowData !== this.props.rowData;
<ide> }
<ide> _setRef = (ref) => {
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses an
<del> * error when upgrading Flow's support for React. Common errors found when
<del> * upgrading Flow's React support are documented at
<del> * https://fburl.com/eq7bs81w */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This comment
<add> * suppresses an error when upgrading Flow's support for React. To see the
<add> * error delete this comment and run Flow. */
<ide> this._containerRef = ref;
<ide> };
<ide> render() {
<ide><path>Libraries/Image/ImageBackground.js
<ide> class ImageBackground extends React.Component<$FlowFixMeProps> {
<ide> _viewRef: ?NativeMethodsMixinType = null;
<ide>
<ide> _captureRef = ref => {
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses an
<del> * error when upgrading Flow's support for React. Common errors found when
<del> * upgrading Flow's React support are documented at
<del> * https://fburl.com/eq7bs81w */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This comment
<add> * suppresses an error when upgrading Flow's support for React. To see the
<add> * error delete this comment and run Flow. */
<ide> this._viewRef = ref;
<ide> };
<ide>
<ide><path>Libraries/Lists/FlatList.js
<ide> class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
<ide> _listRef: VirtualizedList;
<ide>
<ide> _captureRef = ref => {
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses an
<del> * error when upgrading Flow's support for React. Common errors found when
<del> * upgrading Flow's React support are documented at
<del> * https://fburl.com/eq7bs81w */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This comment
<add> * suppresses an error when upgrading Flow's support for React. To see the
<add> * error delete this comment and run Flow. */
<ide> this._listRef = ref;
<ide> };
<ide>
<ide><path>Libraries/Lists/ListView/ListView.js
<ide> var DEFAULT_SCROLL_CALLBACK_THROTTLE = 50;
<ide> * rendering rows.
<ide> */
<ide>
<del>/* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses an error
<del> * found when Flow v0.53 was deployed. To see the error delete this comment and
<del> * run Flow. */
<add>/* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This comment
<add> * suppresses an error when upgrading Flow's support for React. To see the
<add> * error delete this comment and run Flow. */
<ide> var ListView = createReactClass({
<ide> displayName: 'ListView',
<ide> _childFrames: ([]: Array<Object>),
<ide> var ListView = createReactClass({
<ide> }
<ide> Object.assign(props, {
<ide> onScroll: this._onScroll,
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses an
<del> * error found when Flow v0.53 was deployed. To see the error delete this
<del> * comment and run Flow. */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This
<add> * comment suppresses an error when upgrading Flow's support for React.
<add> * To see the error delete this comment and run Flow. */
<ide> stickyHeaderIndices: this.props.stickyHeaderIndices.concat(
<ide> stickySectionHeaderIndices,
<ide> ),
<ide><path>Libraries/Lists/MetroListView.js
<ide> type Item = any;
<ide> type NormalProps = {
<ide> FooterComponent?: React.ComponentType<*>,
<ide> renderItem: (info: Object) => ?React.Element<any>,
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses an error
<del> * found when Flow v0.53 was deployed. To see the error delete this comment
<del> * and run Flow. */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This comment
<add> * suppresses an error when upgrading Flow's support for React. To see the
<add> * error delete this comment and run Flow. */
<ide> renderSectionHeader?: ({section: Object}) => ?React.Element<any>,
<ide> SeparatorComponent?: ?React.ComponentType<*>, // not supported yet
<ide>
<ide> class MetroListView extends React.Component<Props, $FlowFixMeState> {
<ide> renderScrollComponent: (props: Props) => {
<ide> if (props.onRefresh) {
<ide> return (
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses
<del> * an error found when Flow v0.53 was deployed. To see the error
<del> * delete this comment and run Flow. */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This
<add> * comment suppresses an error when upgrading Flow's support for
<add> * React. To see the error delete this comment and run Flow. */
<ide> <ScrollView
<ide> {...props}
<ide> refreshControl={
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment
<del> * suppresses an error found when Flow v0.53 was deployed. To see
<del> * the error delete this comment and run Flow. */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss)
<add> * This comment suppresses an error when upgrading Flow's support
<add> * for React. To see the error delete this comment and run Flow.
<add> */
<ide> <RefreshControl
<ide> refreshing={props.refreshing}
<ide> onRefresh={props.onRefresh}
<ide> class MetroListView extends React.Component<Props, $FlowFixMeState> {
<ide> />
<ide> );
<ide> } else {
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses an
<del> * error found when Flow v0.53 was deployed. To see the error delete
<del> * this comment and run Flow. */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This
<add> * comment suppresses an error when upgrading Flow's support for React.
<add> * To see the error delete this comment and run Flow. */
<ide> return <ScrollView {...props} />;
<ide> }
<ide> },
<ide> class MetroListView extends React.Component<Props, $FlowFixMeState> {
<ide> }
<ide> render() {
<ide> return (
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses an
<del> * error found when Flow v0.53 was deployed. To see the error delete this
<del> * comment and run Flow. */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This
<add> * comment suppresses an error when upgrading Flow's support for React.
<add> * To see the error delete this comment and run Flow. */
<ide> <ListView
<ide> {...this.props}
<ide> dataSource={this.state.ds}
<ide> class MetroListView extends React.Component<Props, $FlowFixMeState> {
<ide> }
<ide> _listRef: ListView;
<ide> _captureRef = ref => {
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses an
<del> * error when upgrading Flow's support for React. Common errors found when
<del> * upgrading Flow's React support are documented at
<del> * https://fburl.com/eq7bs81w */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This comment
<add> * suppresses an error when upgrading Flow's support for React. To see the
<add> * error delete this comment and run Flow. */
<ide> this._listRef = ref;
<ide> };
<ide> _computeState(props: Props, state) {
<ide> class MetroListView extends React.Component<Props, $FlowFixMeState> {
<ide> };
<ide> }
<ide> }
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses an error
<del> * when upgrading Flow's support for React. Common errors found when
<del> * upgrading Flow's React support are documented at
<del> * https://fburl.com/eq7bs81w */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This comment
<add> * suppresses an error when upgrading Flow's support for React. To see the
<add> * error delete this comment and run Flow. */
<ide> _renderFooter = () => <this.props.FooterComponent key="$footer" />;
<ide> _renderRow = (item, sectionID, rowID, highlightRow) => {
<ide> return this.props.renderItem({item, index: rowID});
<ide> class MetroListView extends React.Component<Props, $FlowFixMeState> {
<ide> return renderSectionHeader({section});
<ide> };
<ide> _renderSeparator = (sID, rID) =>
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses an
<del> * error when upgrading Flow's support for React. Common errors found when
<del> * upgrading Flow's React support are documented at
<del> * https://fburl.com/eq7bs81w */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This comment
<add> * suppresses an error when upgrading Flow's support for React. To see the
<add> * error delete this comment and run Flow. */
<ide> <this.props.SeparatorComponent key={sID + rID} />;
<ide> }
<ide>
<ide><path>Libraries/Lists/SectionList.js
<ide> class SectionList<SectionT: SectionBase<any>> extends React.PureComponent<
<ide>
<ide> _wrapperListRef: MetroListView | VirtualizedSectionList<any>;
<ide> _captureRef = ref => {
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses an
<del> * error when upgrading Flow's support for React. Common errors found when
<del> * upgrading Flow's React support are documented at
<del> * https://fburl.com/eq7bs81w */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This comment
<add> * suppresses an error when upgrading Flow's support for React. To see the
<add> * error delete this comment and run Flow. */
<ide> this._wrapperListRef = ref;
<ide> };
<ide> }
<ide><path>Libraries/Lists/VirtualizedList.js
<ide> class VirtualizedList extends React.PureComponent<Props, State> {
<ide> this._footerLength -
<ide> this._scrollMetrics.visibleLength,
<ide> );
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses an
<del> * error when upgrading Flow's support for React. Common errors found when
<del> * upgrading Flow's React support are documented at
<del> * https://fburl.com/eq7bs81w */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This comment
<add> * suppresses an error when upgrading Flow's support for React. To see the
<add> * error delete this comment and run Flow. */
<ide> this._scrollRef.scrollTo(
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses an
<del> * error when upgrading Flow's support for React. Common errors found
<del> * when upgrading Flow's React support are documented at
<del> * https://fburl.com/eq7bs81w */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This
<add> * comment suppresses an error when upgrading Flow's support for React.
<add> * To see the error delete this comment and run Flow. */
<ide> this.props.horizontal ? {x: offset, animated} : {y: offset, animated},
<ide> );
<ide> }
<ide> class VirtualizedList extends React.PureComponent<Props, State> {
<ide> (viewPosition || 0) *
<ide> (this._scrollMetrics.visibleLength - frame.length),
<ide> ) - (viewOffset || 0);
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses an
<del> * error when upgrading Flow's support for React. Common errors found when
<del> * upgrading Flow's React support are documented at
<del> * https://fburl.com/eq7bs81w */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This comment
<add> * suppresses an error when upgrading Flow's support for React. To see the
<add> * error delete this comment and run Flow. */
<ide> this._scrollRef.scrollTo(
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses an
<del> * error when upgrading Flow's support for React. Common errors found
<del> * when upgrading Flow's React support are documented at
<del> * https://fburl.com/eq7bs81w */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This
<add> * comment suppresses an error when upgrading Flow's support for React.
<add> * To see the error delete this comment and run Flow. */
<ide> horizontal ? {x: offset, animated} : {y: offset, animated},
<ide> );
<ide> }
<ide> class VirtualizedList extends React.PureComponent<Props, State> {
<ide> */
<ide> scrollToOffset(params: {animated?: ?boolean, offset: number}) {
<ide> const {animated, offset} = params;
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses an
<del> * error when upgrading Flow's support for React. Common errors found when
<del> * upgrading Flow's React support are documented at
<del> * https://fburl.com/eq7bs81w */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This comment
<add> * suppresses an error when upgrading Flow's support for React. To see the
<add> * error delete this comment and run Flow. */
<ide> this._scrollRef.scrollTo(
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses an
<del> * error when upgrading Flow's support for React. Common errors found
<del> * when upgrading Flow's React support are documented at
<del> * https://fburl.com/eq7bs81w */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This
<add> * comment suppresses an error when upgrading Flow's support for React.
<add> * To see the error delete this comment and run Flow. */
<ide> this.props.horizontal ? {x: offset, animated} : {y: offset, animated},
<ide> );
<ide> }
<ide> class VirtualizedList extends React.PureComponent<Props, State> {
<ide> }
<ide>
<ide> flashScrollIndicators() {
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses an
<del> * error when upgrading Flow's support for React. Common errors found when
<del> * upgrading Flow's React support are documented at
<del> * https://fburl.com/eq7bs81w */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This comment
<add> * suppresses an error when upgrading Flow's support for React. To see the
<add> * error delete this comment and run Flow. */
<ide> this._scrollRef.flashScrollIndicators();
<ide> }
<ide>
<ide> class VirtualizedList extends React.PureComponent<Props, State> {
<ide> */
<ide> getScrollResponder() {
<ide> if (this._scrollRef && this._scrollRef.getScrollResponder) {
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses an
<del> * error when upgrading Flow's support for React. Common errors found
<del> * when upgrading Flow's React support are documented at
<del> * https://fburl.com/eq7bs81w */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This
<add> * comment suppresses an error when upgrading Flow's support for React.
<add> * To see the error delete this comment and run Flow. */
<ide> return this._scrollRef.getScrollResponder();
<ide> }
<ide> }
<ide>
<ide> getScrollableNode() {
<ide> if (this._scrollRef && this._scrollRef.getScrollableNode) {
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses an
<del> * error when upgrading Flow's support for React. Common errors found
<del> * when upgrading Flow's React support are documented at
<del> * https://fburl.com/eq7bs81w */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This
<add> * comment suppresses an error when upgrading Flow's support for React.
<add> * To see the error delete this comment and run Flow. */
<ide> return this._scrollRef.getScrollableNode();
<ide> } else {
<ide> return ReactNative.findNodeHandle(this._scrollRef);
<ide> class VirtualizedList extends React.PureComponent<Props, State> {
<ide>
<ide> setNativeProps(props: Object) {
<ide> if (this._scrollRef) {
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses an
<del> * error when upgrading Flow's support for React. Common errors found
<del> * when upgrading Flow's React support are documented at
<del> * https://fburl.com/eq7bs81w */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This
<add> * comment suppresses an error when upgrading Flow's support for React.
<add> * To see the error delete this comment and run Flow. */
<ide> this._scrollRef.setNativeProps(props);
<ide> }
<ide> }
<ide> class VirtualizedList extends React.PureComponent<Props, State> {
<ide> ? ListHeaderComponent // $FlowFixMe
<ide> : <ListHeaderComponent />;
<ide> cells.push(
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses an
<del> * error when upgrading Flow's support for React. Common errors found
<del> * when upgrading Flow's React support are documented at
<del> * https://fburl.com/eq7bs81w */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This
<add> * comment suppresses an error when upgrading Flow's support for React.
<add> * To see the error delete this comment and run Flow. */
<ide> <View
<ide> key="$header"
<ide> onLayout={this._onLayoutHeader}
<ide> class VirtualizedList extends React.PureComponent<Props, State> {
<ide> ? ListEmptyComponent // $FlowFixMe
<ide> : <ListEmptyComponent />;
<ide> cells.push(
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses an
<del> * error when upgrading Flow's support for React. Common errors found
<del> * when upgrading Flow's React support are documented at
<del> * https://fburl.com/eq7bs81w */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This
<add> * comment suppresses an error when upgrading Flow's support for React.
<add> * To see the error delete this comment and run Flow. */
<ide> <View
<ide> key="$empty"
<ide> onLayout={this._onLayoutEmpty}
<ide> class VirtualizedList extends React.PureComponent<Props, State> {
<ide> ? ListFooterComponent // $FlowFixMe
<ide> : <ListFooterComponent />;
<ide> cells.push(
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses an
<del> * error when upgrading Flow's support for React. Common errors found
<del> * when upgrading Flow's React support are documented at
<del> * https://fburl.com/eq7bs81w */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This
<add> * comment suppresses an error when upgrading Flow's support for React.
<add> * To see the error delete this comment and run Flow. */
<ide> <View
<ide> key="$footer"
<ide> onLayout={this._onLayoutFooter}
<ide> class VirtualizedList extends React.PureComponent<Props, State> {
<ide> '`',
<ide> );
<ide> return (
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses an
<del> * error found when Flow v0.53 was deployed. To see the error delete
<del> * this comment and run Flow. */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This
<add> * comment suppresses an error when upgrading Flow's support for React.
<add> * To see the error delete this comment and run Flow. */
<ide> <ScrollView
<ide> {...props}
<ide> refreshControl={
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment
<del> * suppresses an error found when Flow v0.53 was deployed. To see
<del> * the error delete this comment and run Flow. */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This
<add> * comment suppresses an error when upgrading Flow's support for
<add> * React. To see the error delete this comment and run Flow. */
<ide> <RefreshControl
<ide> refreshing={props.refreshing}
<ide> onRefresh={props.onRefresh}
<ide> class VirtualizedList extends React.PureComponent<Props, State> {
<ide> />
<ide> );
<ide> } else {
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses an
<del> * error found when Flow v0.53 was deployed. To see the error delete this
<del> * comment and run Flow. */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This
<add> * comment suppresses an error when upgrading Flow's support for React.
<add> * To see the error delete this comment and run Flow. */
<ide> return <ScrollView {...props} />;
<ide> }
<ide> };
<ide><path>Libraries/Lists/VirtualizedSectionList.js
<ide> class VirtualizedSectionList<SectionT: SectionBase> extends React.PureComponent<
<ide> _cellRefs = {};
<ide> _listRef: VirtualizedList;
<ide> _captureRef = ref => {
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses an
<del> * error when upgrading Flow's support for React. Common errors found when
<del> * upgrading Flow's React support are documented at
<del> * https://fburl.com/eq7bs81w */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This comment
<add> * suppresses an error when upgrading Flow's support for React. To see the
<add> * error delete this comment and run Flow. */
<ide> this._listRef = ref;
<ide> };
<ide> }
<ide><path>Libraries/ReactNative/AppContainer.js
<ide> type Context = {
<ide> rootTag: number,
<ide> };
<ide> type Props = {|
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses an error
<del> * when upgrading Flow's support for React. Common errors found when
<del> * upgrading Flow's React support are documented at
<del> * https://fburl.com/eq7bs81w */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This comment
<add> * suppresses an error when upgrading Flow's support for React. To see the
<add> * error delete this comment and run Flow. */
<ide> children?: React.Children,
<ide> rootTag: number,
<ide> WrapperComponent?: ?React.ComponentType<*>,
<ide> class AppContainer extends React.Component<Props, State> {
<ide> pointerEvents="box-none"
<ide> style={styles.appContainer}
<ide> ref={ref => {
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses
<del> * an error when upgrading Flow's support for React. Common errors
<del> * found when upgrading Flow's React support are documented at
<del> * https://fburl.com/eq7bs81w */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This
<add> * comment suppresses an error when upgrading Flow's support for
<add> * React. To see the error delete this comment and run Flow. */
<ide> this._mainRef = ref;
<ide> }}>
<ide> {this.props.children}
<ide><path>Libraries/ReactNative/verifyPropTypes.js
<ide> function verifyPropTypes(
<ide>
<ide> if (!propTypes) {
<ide> throw new Error(
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses an
<del> * error when upgrading Flow's support for React. Common errors found
<del> * when upgrading Flow's React support are documented at
<del> * https://fburl.com/eq7bs81w */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This
<add> * comment suppresses an error when upgrading Flow's support for React.
<add> * To see the error delete this comment and run Flow. */
<ide> '`' + componentName + '` has no propTypes defined`'
<ide> );
<ide> }
<ide> function verifyPropTypes(
<ide> (!nativePropsToIgnore || !nativePropsToIgnore[prop])) {
<ide> var message;
<ide> if (propTypes.hasOwnProperty(prop)) {
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses an
<del> * error when upgrading Flow's support for React. Common errors found
<del> * when upgrading Flow's React support are documented at
<del> * https://fburl.com/eq7bs81w */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This
<add> * comment suppresses an error when upgrading Flow's support for React.
<add> * To see the error delete this comment and run Flow. */
<ide> message = '`' + componentName + '` has incorrectly defined propType for native prop `' +
<ide> viewConfig.uiViewClassName + '.' + prop + '` of native type `' + nativeProps[prop];
<ide> } else {
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses an
<del> * error when upgrading Flow's support for React. Common errors found
<del> * when upgrading Flow's React support are documented at
<del> * https://fburl.com/eq7bs81w */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This
<add> * comment suppresses an error when upgrading Flow's support for React.
<add> * To see the error delete this comment and run Flow. */
<ide> message = '`' + componentName + '` has no propType for native prop `' +
<ide> viewConfig.uiViewClassName + '.' + prop + '` of native type `' +
<ide> nativeProps[prop] + '`';
<ide><path>Libraries/Renderer/shims/ReactNativeTypes.js
<ide> */
<ide> 'use strict';
<ide>
<del>/* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses an error
<del> * found when Flow v0.53 was deployed. To see the error delete this comment and
<del> * run Flow. */
<add>/* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This comment
<add> * suppresses an error when upgrading Flow's support for React. To see the
<add> * error delete this comment and run Flow. */
<ide> import type React from 'react';
<ide>
<ide> export type MeasureOnSuccessCallback = (
<ide><path>RNTester/js/ExampleTypes.js
<ide> */
<ide> 'use strict';
<ide>
<del>/* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses an error
<del> * found when Flow v0.53 was deployed. To see the error delete this comment and
<del> * run Flow. */
<add>/* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This comment
<add> * suppresses an error when upgrading Flow's support for React. To see the
<add> * error delete this comment and run Flow. */
<ide> import type React from 'react';
<ide>
<ide> export type Example = {
<ide><path>RNTester/js/ImageExample.js
<ide> var NetworkImageCallbackExample = createReactClass({
<ide> },
<ide>
<ide> _loadEventFired(event) {
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses an
<del> * error found when Flow v0.53 was deployed. To see the error delete this
<del> * comment and run Flow. */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This comment
<add> * suppresses an error when upgrading Flow's support for React. To see the
<add> * error delete this comment and run Flow. */
<ide> this.setState((state) => {
<ide> return state.events = [...state.events, event];
<ide> });
<ide><path>RNTester/js/PointerEventsExample.js
<ide> class ExampleBox extends React.Component<$FlowFixMeProps, $FlowFixMeState> {
<ide> <View
<ide> onTouchEndCapture={this.handleTouchCapture}
<ide> onTouchStart={this.flushReactChanges}>
<del> {/* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses
<del> * an error when upgrading Flow's support for React. Common errors
<del> * found when upgrading Flow's React support are documented at
<del> * https://fburl.com/eq7bs81w */}
<add> {/* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This
<add> * comment suppresses an error when upgrading Flow's support for
<add> * React. To see the error delete this comment and run Flow. */}
<ide> <this.props.Component onLog={this.handleLog} />
<ide> </View>
<ide> <View
<ide><path>RNTester/js/RNTesterApp.ios.js
<ide> class RNTesterApp extends React.Component<Props, RNTesterNavigationState> {
<ide> return (
<ide> <View style={styles.exampleContainer}>
<ide> <Header title="RNTester" />
<del> {/* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses
<del> * an error when upgrading Flow's support for React. Common errors
<del> * found when upgrading Flow's React support are documented at
<del> * https://fburl.com/eq7bs81w */}
<add> {/* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This
<add> * comment suppresses an error when upgrading Flow's support for
<add> * React. To see the error delete this comment and run Flow. */}
<ide> <RNTesterExampleList
<ide> onNavigate={this._handleAction}
<ide> list={RNTesterList}
<ide><path>RNTester/js/RNTesterStatePersister.js
<ide> function createContainer<Props: Object, State>(
<ide> },
<ide> ): React.ComponentType<Props> {
<ide> return class ComponentWithPersistedState extends React.Component<Props, $FlowFixMeState> {
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses an
<del> * error when upgrading Flow's support for React. Common errors found when
<del> * upgrading Flow's React support are documented at
<del> * https://fburl.com/eq7bs81w */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This comment
<add> * suppresses an error when upgrading Flow's support for React. To see the
<add> * error delete this comment and run Flow. */
<ide> static displayName = `RNTesterStatePersister(${Component.displayName || Component.name})`;
<ide> state = {value: spec.getInitialState(this.props)};
<ide> _cacheKey = `RNTester:${spec.version || 'v1'}:${spec.cacheKeySuffix(this.props)}`;
<ide><path>RNTester/js/ScrollViewExample.js
<ide> exports.examples = [
<ide> return (
<ide> <View>
<ide> <ScrollView
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment suppresses
<del> * an error when upgrading Flow's support for React. Common errors
<del> * found when upgrading Flow's React support are documented at
<del> * https://fburl.com/eq7bs81w */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This
<add> * comment suppresses an error when upgrading Flow's support for
<add> * React. To see the error delete this comment and run Flow. */
<ide> ref={(scrollView) => { _scrollView = scrollView; }}
<ide> automaticallyAdjustContentInsets={false}
<ide> onScroll={() => { console.log('onScroll!'); }}
<ide> exports.examples = [
<ide> <View style={addtionalStyles}>
<ide> <Text style={styles.text}>{title}</Text>
<ide> <ScrollView
<del> /* $FlowFixMe(>=0.53.0 site=react_native_fb) This comment
<del> * suppresses an error when upgrading Flow's support for React.
<del> * Common errors found when upgrading Flow's React support are
<del> * documented at https://fburl.com/eq7bs81w */
<add> /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This
<add> * comment suppresses an error when upgrading Flow's support for
<add> * React. To see the error delete this comment and run Flow. */
<ide> ref={(scrollView) => { _scrollView = scrollView; }}
<ide> automaticallyAdjustContentInsets={false}
<ide> horizontal={true} | 27 |
Javascript | Javascript | handle null targets at assign | 2e5a7e52a0385575bbb55a801471b009afafeca3 | <ide><path>src/ng/parse.js
<ide> ASTCompiler.prototype = {
<ide> self.if(self.stage === 'inputs' || 's', function() {
<ide> if (create && create !== 1) {
<ide> self.if(
<del> self.not(self.getHasOwnProperty('s', ast.name)),
<add> self.not(self.nonComputedMember('s', ast.name)),
<ide> self.lazyAssign(self.nonComputedMember('s', ast.name), '{}'));
<ide> }
<ide> self.assign(intoId, self.nonComputedMember('s', ast.name));
<ide> ASTCompiler.prototype = {
<ide> self.recurse(ast.property, right);
<ide> self.addEnsureSafeMemberName(right);
<ide> if (create && create !== 1) {
<del> self.if(self.not(right + ' in ' + left), self.lazyAssign(self.computedMember(left, right), '{}'));
<add> self.if(self.not(self.computedMember(left, right)), self.lazyAssign(self.computedMember(left, right), '{}'));
<ide> }
<ide> expression = self.ensureSafeObject(self.computedMember(left, right));
<ide> self.assign(intoId, expression);
<ide> ASTCompiler.prototype = {
<ide> } else {
<ide> ensureSafeMemberName(ast.property.name);
<ide> if (create && create !== 1) {
<del> self.if(self.not(self.escape(ast.property.name) + ' in ' + left), self.lazyAssign(self.nonComputedMember(left, ast.property.name), '{}'));
<add> self.if(self.not(self.nonComputedMember(left, ast.property.name)), self.lazyAssign(self.nonComputedMember(left, ast.property.name), '{}'));
<ide> }
<ide> expression = self.nonComputedMember(left, ast.property.name);
<ide> if (self.state.expensiveChecks || isPossiblyDangerousMemberName(ast.property.name)) {
<ide> ASTInterpreter.prototype = {
<ide> identifier: function(name, expensiveChecks, context, create, expression) {
<ide> return function(scope, locals, assign, inputs) {
<ide> var base = locals && (name in locals) ? locals : scope;
<del> if (create && create !== 1 && base && !(name in base)) {
<add> if (create && create !== 1 && base && !(base[name])) {
<ide> base[name] = {};
<ide> }
<ide> var value = base ? base[name] : undefined;
<ide> ASTInterpreter.prototype = {
<ide> if (lhs != null) {
<ide> rhs = right(scope, locals, assign, inputs);
<ide> ensureSafeMemberName(rhs, expression);
<del> if (create && create !== 1 && lhs && !(rhs in lhs)) {
<add> if (create && create !== 1 && lhs && !(lhs[rhs])) {
<ide> lhs[rhs] = {};
<ide> }
<ide> value = lhs[rhs];
<ide> ASTInterpreter.prototype = {
<ide> nonComputedMember: function(left, right, expensiveChecks, context, create, expression) {
<ide> return function(scope, locals, assign, inputs) {
<ide> var lhs = left(scope, locals, assign, inputs);
<del> if (create && create !== 1 && lhs && !(right in lhs)) {
<add> if (create && create !== 1 && lhs && !(lhs[right])) {
<ide> lhs[right] = {};
<ide> }
<ide> var value = lhs != null ? lhs[right] : undefined;
<ide><path>test/ng/parseSpec.js
<ide> describe('parser', function() {
<ide> fn.assign(scope, 123);
<ide> expect(scope.a.b.c).toEqual(123);
<ide> }));
<add>
<add> it('should create objects when finding a null', inject(function($parse) {
<add> var fn = $parse('foo.bar');
<add> var scope = {foo: null};
<add> fn.assign(scope, 123);
<add> expect(scope.foo.bar).toEqual(123);
<add> }));
<add>
<add> it('should create objects when finding a null', inject(function($parse) {
<add> var fn = $parse('foo["bar"]');
<add> var scope = {foo: null};
<add> fn.assign(scope, 123);
<add> expect(scope.foo.bar).toEqual(123);
<add> }));
<add>
<add> it('should create objects when finding a null', inject(function($parse) {
<add> var fn = $parse('foo.bar.baz');
<add> var scope = {foo: null};
<add> fn.assign(scope, 123);
<add> expect(scope.foo.bar.baz).toEqual(123);
<add> }));
<ide> });
<ide>
<ide> describe('one-time binding', function() { | 2 |
Javascript | Javascript | align $viewvalue description with $setviewvalue | aafbd944397bd18aca2cf94f71ae210dcae756fd | <ide><path>src/ng/directive/ngModel.js
<ide> var ngModelMinErr = minErr('ngModel');
<ide> * @ngdoc type
<ide> * @name ngModel.NgModelController
<ide> *
<del> * @property {string} $viewValue Actual string value in the view.
<add> * @property {*} $viewValue The actual value from the control's view. For `input` elements, this is a
<add> * String. See {@link ngModel.NgModelController#$setViewValue} for information about when the $viewValue
<add> * is set.
<ide> * @property {*} $modelValue The value in the model that the control is bound to.
<ide> * @property {Array.<Function>} $parsers Array of functions to execute, as a pipeline, whenever
<ide> the control reads value from the DOM. The functions are called in array order, each passing | 1 |
Text | Text | change dynamic imports to dynamic import | 5f9e9828de7e6ea7c3bf40fa3e973d7451eb84e9 | <ide><path>readme.md
<ide> For the documentation of the latest **stable** release, [visit here](https://git
<ide> - [With `<Link>`](#with-link-1)
<ide> - [Imperatively](#imperatively-1)
<ide> - [Custom server and routing](#custom-server-and-routing)
<del> - [Dynamic Imports](#dynamic-imports)
<add> - [Dynamic Import](#dynamic-import)
<ide> - [Custom `<Document>`](#custom-document)
<ide> - [Custom error handling](#custom-error-handling)
<ide> - [Custom configuration](#custom-configuration) | 1 |
Javascript | Javascript | remove unused var in net-server-try-ports | 24ee0d2111b3244a0eaff4b3b436e93efbbcc1a5 | <ide><path>test/parallel/test-net-server-try-ports.js
<ide> require('../common');
<ide> var assert = require('assert');
<ide> var net = require('net');
<ide>
<del>var connections = 0;
<del>
<ide> var server1listening = false;
<ide> var server2listening = false;
<ide> var server2eaddrinuse = false;
<ide>
<ide> var server1 = net.Server(function(socket) {
<del> connections++;
<ide> socket.destroy();
<ide> });
<ide>
<ide> var server2 = net.Server(function(socket) {
<del> connections++;
<ide> socket.destroy();
<ide> });
<ide> | 1 |
Javascript | Javascript | fix handling of null on ie | 271b535c8285cb90781bf1e8ee56d6e68210a6a9 | <ide><path>src/widgets.js
<ide> function valueAccessor(scope, element) {
<ide> }
<ide> },
<ide> set: function(value) {
<del> var oldValue = element[0].value,
<add> var oldValue = element.val(),
<ide> newValue = format(value);
<ide> if (oldValue != newValue) {
<del> element[0].value = newValue;
<add> element.val(newValue || ''); // needed for ie
<ide> }
<ide> validate();
<ide> }
<ide> };
<ide>
<ide> function validate() {
<del> var value = trim(element[0].value);
<add> var value = trim(element.val());
<ide> if (element[0].disabled || element[0].readOnly) {
<ide> elementError(element, NG_VALIDATION_ERROR, null);
<ide> invalidWidgets.markValid(element);
<ide> var textWidget = inputWidget('keyup change', modelAccessor, valueAccessor, initW
<ide> function initWidgetValue(initValue) {
<ide> return function (model, view) {
<ide> var value = view.get();
<del> if (!value && isDefined(initValue))
<add> if (!value && isDefined(initValue)) {
<ide> value = copy(initValue);
<add> }
<ide> if (isUndefined(model.get()) && isDefined(value)) {
<ide> model.set(value);
<ide> } | 1 |
Javascript | Javascript | restore v0.10.x setupmaster() behaviour | 4cd522d15796ac558a2be8c623ed3fc1d7dfe3a0 | <ide><path>lib/cluster.js
<ide> function masterInit() {
<ide> cluster.workers = {};
<ide>
<ide> var intercom = new EventEmitter;
<del> var settings = {
<del> args: process.argv.slice(2),
<del> exec: process.argv[1],
<del> execArgv: process.execArgv,
<del> silent: false
<del> };
<del> cluster.settings = settings;
<add> cluster.settings = {};
<ide>
<ide> // XXX(bnoordhuis) Fold cluster.schedulingPolicy into cluster.settings?
<ide> var schedulingPolicy = {
<ide> function masterInit() {
<ide> cluster.setupMaster = function(options) {
<ide> if (initialized === true) return;
<ide> initialized = true;
<add> var settings = {
<add> args: process.argv.slice(2),
<add> exec: process.argv[1],
<add> execArgv: process.execArgv,
<add> silent: false
<add> };
<ide> settings = util._extend(settings, options || {});
<ide> // Tell V8 to write profile data for each process to a separate file.
<ide> // Without --logfile=v8-%p.log, everything ends up in a single, unusable
<ide> function masterInit() {
<ide> var workerEnv = util._extend({}, process.env);
<ide> workerEnv = util._extend(workerEnv, env);
<ide> workerEnv.NODE_UNIQUE_ID = '' + worker.id;
<del> worker.process = fork(settings.exec, settings.args, {
<add> worker.process = fork(cluster.settings.exec, cluster.settings.args, {
<ide> env: workerEnv,
<del> silent: settings.silent,
<del> execArgv: createWorkerExecArgv(settings.execArgv, worker)
<add> silent: cluster.settings.silent,
<add> execArgv: createWorkerExecArgv(cluster.settings.execArgv, worker)
<ide> });
<ide> worker.process.once('exit', function(exitCode, signalCode) {
<ide> worker.suicide = !!worker.suicide; | 1 |
Python | Python | use with_extension to change the extension | e4fd5e39993cc2875e3dad536141d5178caaa3f0 | <ide><path>src/transformers/hf_argparser.py
<ide> DataClassType = NewType("DataClassType", Any)
<ide>
<ide>
<del>def trim_suffix(s: str, suffix: str):
<del> return s if not s.endswith(suffix) or len(suffix) == 0 else s[: -len(suffix)]
<del>
<del>
<ide> class HfArgumentParser(ArgumentParser):
<ide> """
<ide> This subclass of `argparse.ArgumentParser` uses type hints on dataclasses
<ide> def parse_args_into_dataclasses(
<ide> (same as argparse.ArgumentParser.parse_known_args)
<ide> """
<ide> if look_for_args_file and len(sys.argv):
<del> basename = trim_suffix(sys.argv[0], ".py")
<del> args_file = Path(f"{basename}.args")
<add> args_file = Path(sys.argv[0]).with_suffix(".args")
<ide> if args_file.exists():
<ide> fargs = args_file.read_text().split()
<ide> args = fargs + args if args is not None else fargs + sys.argv[1:] | 1 |
Javascript | Javascript | add tests for redirecttolearn | 014c26cd4e97f772ae19fca49150229dab727b60 | <ide><path>api-server/server/boot/challenge.js
<ide> import { homeLocation } from '../../../config/env';
<ide>
<ide> import { ifNoUserSend } from '../utils/middleware';
<ide> import { dasherize } from '../utils';
<del>import pathMigrations from '../resources/pathMigration.json';
<add>import _pathMigrations from '../resources/pathMigration.json';
<ide> import { fixCompletedChallengeItem } from '../../common/utils';
<ide>
<ide> const log = debug('fcc:boot:challenges');
<ide> export default async function bootChallenge(app, done) {
<ide> const send200toNonUser = ifNoUserSend(true);
<ide> const api = app.loopback.Router();
<ide> const router = app.loopback.Router();
<add> const redirectToLearn = createRedirectToLearn(_pathMigrations);
<ide> const challengeUrlResolver = await createChallengeUrlResolver(app);
<ide> const redirectToCurrentChallenge = createRedirectToCurrentChallenge(
<ide> challengeUrlResolver
<ide> export function createRedirectToCurrentChallenge(
<ide> };
<ide> }
<ide>
<del>function redirectToLearn(req, res) {
<del> const maybeChallenge = last(req.path.split('/'));
<del> if (maybeChallenge in pathMigrations) {
<del> const redirectPath = pathMigrations[maybeChallenge];
<del> return res.status(302).redirect(`${learnURL}${redirectPath}`);
<del> }
<del> return res.status(302).redirect(learnURL);
<add>export function createRedirectToLearn(
<add> pathMigrations,
<add> base = homeLocation,
<add> learn = learnURL
<add>) {
<add> return function redirectToLearn(req, res) {
<add> const maybeChallenge = last(req.path.split('/'));
<add> if (maybeChallenge in pathMigrations) {
<add> const redirectPath = pathMigrations[maybeChallenge];
<add> return res.status(302).redirect(`${base}${redirectPath}`);
<add> }
<add> return res.status(302).redirect(learn);
<add> };
<ide> }
<ide><path>api-server/server/boot_tests/challenge.test.js
<ide> import {
<ide> createChallengeUrlResolver,
<ide> createRedirectToCurrentChallenge,
<ide> getFirstChallenge,
<del> isValidChallengeCompletion
<add> isValidChallengeCompletion,
<add> createRedirectToLearn
<ide> } from '../boot/challenge';
<ide>
<ide> import {
<ide> import {
<ide> mockGetFirstChallenge,
<ide> firstChallengeQuery,
<ide> mockCompletedChallenge,
<del> mockCompletedChallenges
<add> mockCompletedChallenges,
<add> mockPathMigrationMap
<ide> } from './fixtures';
<ide>
<ide> describe('boot/challenge', () => {
<ide> describe('boot/challenge', () => {
<ide> });
<ide> });
<ide>
<del> xdescribe('redirectToLearn');
<add> describe('redirectToLearn', () => {
<add> const mockHome = 'https://example.com';
<add> const mockLearn = 'https://example.com/learn';
<add> const redirectToLearn = createRedirectToLearn(
<add> mockPathMigrationMap,
<add> mockHome,
<add> mockLearn
<add> );
<add>
<add> it('redirects to learn by default', () => {
<add> const req = mockReq({ path: '/challenges' });
<add> const res = mockRes();
<add>
<add> redirectToLearn(req, res);
<add>
<add> expect(res.redirect.calledWith(mockLearn)).toBe(true);
<add> });
<add>
<add> it('maps to the correct redirect if the path matches a challenge', () => {
<add> const req = mockReq({ path: '/challenges/challenge-two' });
<add> const res = mockRes();
<add> const expectedRedirect =
<add> 'https://example.com/learn/superblock/block/challenge-two';
<add> redirectToLearn(req, res);
<add>
<add> expect(res.redirect.calledWith(expectedRedirect)).toBe(true);
<add> });
<add> });
<ide> });
<ide><path>api-server/server/boot_tests/fixtures.js
<ide> export const firstChallengeQuery = {
<ide> // first challenge of the first block of the first superBlock
<ide> where: { challengeOrder: 0, superOrder: 1, order: 0 }
<ide> };
<add>
<add>export const mockPathMigrationMap = {
<add> 'challenge-one': '/learn/superblock/block/challenge-one',
<add> 'challenge-two': '/learn/superblock/block/challenge-two'
<add>}; | 3 |
Text | Text | replace medium link with fcc news | 704db73d0d877e174eeb6663e05e03dfc7d1306d | <ide><path>README.md
<ide> Our community also has:
<ide> - A [podcast](https://podcast.freecodecamp.org/) with technology insights and inspiring stories from developers.
<ide> - [Local study groups](https://study-group-directory.freecodecamp.org/) around the world, where you can code together in person
<ide> - A comprehensive [guide to thousands of programming topics](https://guide.freecodecamp.org/)
<del>- Medium's [largest technical publication](https://medium.freecodecamp.org)
<add>- The [Developer News](https://www.freecodecamp.org/news), a free, open source, no-ads place to cross-post your blog articles.
<ide> - A [Facebook group](https://www.facebook.com/groups/freeCodeCampEarth/permalink/428140994253892/) with over 100,000 members worldwide
<ide>
<ide> ### [Join our community here](https://www.freecodecamp.org/signin). | 1 |
Javascript | Javascript | fix imports order | 8e6f006f207fde704cec8fe536def0dca68692b3 | <ide><path>lib/dependencies/HarmonyExportInitFragment.js
<ide> class HarmonyExportInitFragment extends InitFragment {
<ide> ? `/* unused harmony export ${first(this.unusedExports)} */\n`
<ide> : "";
<ide> const definitions = [];
<del> for (const [key, value] of this.exportMap) {
<add> const orderedExportMap = Array.from(this.exportMap).sort(([a], [b]) =>
<add> a < b ? -1 : 1
<add> );
<add> for (const [key, value] of orderedExportMap) {
<ide> definitions.push(
<ide> `\n/* harmony export */ ${JSON.stringify(
<ide> key
<ide><path>test/configCases/issues/issue-11871-imports-order/a.js
<add>export const W = "w";
<add>export const A = "a";
<add>export const a = "a";
<add>export const _12 = "12";
<ide><path>test/configCases/issues/issue-11871-imports-order/index.js
<add>import * as values from "./a.js";
<add>
<add>it("imports should have correct order", () => {
<add> expect(Object.keys(values)).toEqual(["A", "W", "_12", "a"])
<add>});
<ide><path>test/configCases/issues/issue-11871-imports-order/webpack.config.js
<add>"use strict";
<add>
<add>/** @type {import("../../../../").Configuration[]} */
<add>module.exports = [
<add> {
<add> mode: "development"
<add> },
<add> {
<add> mode: "production"
<add> },
<add> {
<add> mode: "production",
<add> optimization: {
<add> concatenateModules: false
<add> }
<add> },
<add> {
<add> mode: "development",
<add> optimization: {
<add> concatenateModules: true
<add> }
<add> }
<add>]; | 4 |
Ruby | Ruby | reduce object allocation | a60e6ddb83b036f9b92af5dbcfda265cd0fde3b2 | <ide><path>actionview/lib/action_view/template.rb
<ide> def locals_code #:nodoc:
<ide> end
<ide>
<ide> def method_name #:nodoc:
<del> @method_name ||= "_#{identifier_method_name}__#{@identifier.hash}_#{__id__}".tr('-', "_")
<add> @method_name ||= begin
<add> m = "_#{identifier_method_name}__#{@identifier.hash}_#{__id__}"
<add> m.tr!('-', '_')
<add> m
<add> end
<ide> end
<ide>
<ide> def identifier_method_name #:nodoc: | 1 |
Ruby | Ruby | install tap command completions and manpages | 25396d9c4d7a7a111eebf02f0ebdbb0e69aad3b0 | <ide><path>Library/Homebrew/cmd/list.rb
<ide> def list
<ide> lib/ruby/site_ruby/[12].*
<ide> lib/ruby/vendor_ruby/[12].*
<ide> manpages/brew.1
<add> manpages/brew-cask.1
<ide> share/pypy/*
<ide> share/pypy3/*
<ide> share/info/dir
<ide><path>Library/Homebrew/cmd/tap.rb
<ide> module Homebrew
<ide>
<ide> def tap
<ide> if ARGV.include? "--repair"
<del> Tap.each(&:link_manpages)
<add> Tap.each(&:link_completions_and_manpages)
<ide> elsif ARGV.include? "--list-official"
<ide> require "official_taps"
<ide> puts OFFICIAL_TAPS.map { |t| "homebrew/#{t}" }
<ide><path>Library/Homebrew/cmd/update-report.rb
<ide> def update_report
<ide> puts if ARGV.include?("--preinstall")
<ide> end
<ide>
<del> link_completions_and_docs
<del> Tap.each(&:link_manpages)
<add> link_completions_manpages_and_docs
<add> Tap.each(&:link_completions_and_manpages)
<ide>
<ide> Homebrew.failed = true if ENV["HOMEBREW_UPDATE_FAILED"]
<ide>
<ide> def migrate_legacy_repository_if_necessary
<ide> EOS
<ide> end
<ide>
<del> link_completions_and_docs(new_homebrew_repository)
<add> link_completions_manpages_and_docs(new_homebrew_repository)
<ide>
<ide> ohai "Migrated HOMEBREW_REPOSITORY to #{new_homebrew_repository}!"
<ide> puts <<-EOS.undent
<ide> def migrate_legacy_repository_if_necessary
<ide> $stderr.puts e.backtrace
<ide> end
<ide>
<del> def link_completions_and_docs(repository = HOMEBREW_REPOSITORY)
<add> def link_completions_manpages_and_docs(repository = HOMEBREW_REPOSITORY)
<ide> command = "brew update"
<del> link_src_dst_dirs(repository/"completions/bash",
<del> HOMEBREW_PREFIX/"etc/bash_completion.d", command)
<del> link_src_dst_dirs(repository/"docs",
<del> HOMEBREW_PREFIX/"share/doc/homebrew", command, link_dir: true)
<del> link_src_dst_dirs(repository/"completions/zsh",
<del> HOMEBREW_PREFIX/"share/zsh/site-functions", command)
<del> link_src_dst_dirs(repository/"manpages",
<del> HOMEBREW_PREFIX/"share/man/man1", command)
<add> Utils::Link.link_completions(repository, command)
<add> Utils::Link.link_manpages(repository, command)
<add> Utils::Link.link_docs(repository, command)
<ide> rescue => e
<ide> ofail <<-EOS.undent
<ide> Failed to link all completions, docs and manpages:
<ide><path>Library/Homebrew/tap.rb
<ide> def install(options = {})
<ide> raise
<ide> end
<ide>
<del> link_manpages
<add> link_completions_and_manpages
<ide>
<ide> formula_count = formula_files.size
<ide> puts "Tapped #{formula_count} formula#{plural(formula_count, "e")} (#{path.abv})" unless quiet
<ide> def install(options = {})
<ide> EOS
<ide> end
<ide>
<del> def link_manpages
<del> link_path_manpages(path, "brew tap --repair")
<add> def link_completions_and_manpages
<add> command = "brew tap --repair"
<add> Utils::Link.link_manpages(path, command)
<add> Utils::Link.link_completions(path, command)
<ide> end
<ide>
<ide> # uninstall this {Tap}.
<ide> def uninstall
<ide> unpin if pinned?
<ide> formula_count = formula_files.size
<ide> Descriptions.uncache_formulae(formula_names)
<del> unlink_manpages
<add> Utils::Link.unlink_manpages(path)
<add> Utils::Link.unlink_completions(path)
<ide> path.rmtree
<ide> path.parent.rmdir_if_possible
<ide> puts "Untapped #{formula_count} formula#{plural(formula_count, "e")}"
<ide> clear_cache
<ide> end
<ide>
<del> def unlink_manpages
<del> return unless (path/"man").exist?
<del> (path/"man").find do |src|
<del> next if src.directory?
<del> dst = HOMEBREW_PREFIX/"share"/src.relative_path_from(path)
<del> dst.delete if dst.symlink? && src == dst.resolved_path
<del> dst.parent.rmdir_if_possible
<del> end
<del> end
<del>
<ide> # True if the {#remote} of {Tap} is customized.
<ide> def custom_remote?
<ide> return true unless remote
<ide><path>Library/Homebrew/test/tap_test.rb
<ide> class Foo < Formula
<ide> @cmd_file.parent.mkpath
<ide> touch @cmd_file
<ide> chmod 0755, @cmd_file
<del> @manpage_file = @path/"man/man1/brew-tap-cmd.1"
<add> @manpage_file = @path/"manpages/brew-tap-cmd.1"
<ide> @manpage_file.parent.mkpath
<ide> touch @manpage_file
<add> @bash_completion_file = @path/"completions/bash/brew-tap-cmd"
<add> @bash_completion_file.parent.mkpath
<add> touch @bash_completion_file
<add> @zsh_completion_file = @path/"completions/zsh/_brew-tap-cmd"
<add> @zsh_completion_file.parent.mkpath
<add> touch @zsh_completion_file
<add> @fish_completion_file = @path/"completions/fish/brew-tap-cmd.fish"
<add> @fish_completion_file.parent.mkpath
<add> touch @fish_completion_file
<ide> end
<ide>
<ide> def setup_git_repo
<ide> def test_install_and_uninstall
<ide> shutup { tap.install clone_target: @tap.path/".git" }
<ide> assert_predicate tap, :installed?
<ide> assert_predicate HOMEBREW_PREFIX/"share/man/man1/brew-tap-cmd.1", :file?
<add> assert_predicate HOMEBREW_PREFIX/"etc/bash_completion.d/brew-tap-cmd", :file?
<add> assert_predicate HOMEBREW_PREFIX/"share/zsh/site-functions/_brew-tap-cmd", :file?
<add> assert_predicate HOMEBREW_PREFIX/"share/fish/vendor_completions.d/brew-tap-cmd.fish", :file?
<ide> shutup { tap.uninstall }
<ide> refute_predicate tap, :installed?
<ide> refute_predicate HOMEBREW_PREFIX/"share/man/man1/brew-tap-cmd.1", :exist?
<ide> refute_predicate HOMEBREW_PREFIX/"share/man/man1", :exist?
<add> refute_predicate HOMEBREW_PREFIX/"etc/bash_completion.d/brew-tap-cmd", :exist?
<add> refute_predicate HOMEBREW_PREFIX/"share/zsh/site-functions/_brew-tap-cmd", :exist?
<add> refute_predicate HOMEBREW_PREFIX/"share/fish/vendor_completions.d/brew-tap-cmd.fish", :exist?
<add> ensure
<add> (HOMEBREW_PREFIX/"etc").rmtree if (HOMEBREW_PREFIX/"etc").exist?
<add> (HOMEBREW_PREFIX/"share").rmtree if (HOMEBREW_PREFIX/"share").exist?
<add> end
<add>
<add> def test_link_completions_and_manpages
<add> setup_tap_files
<add> setup_git_repo
<add> tap = Tap.new("Homebrew", "baz")
<add> shutup { tap.install clone_target: @tap.path/".git" }
<add> (HOMEBREW_PREFIX/"share/man/man1/brew-tap-cmd.1").delete
<add> (HOMEBREW_PREFIX/"etc/bash_completion.d/brew-tap-cmd").delete
<add> (HOMEBREW_PREFIX/"share/zsh/site-functions/_brew-tap-cmd").delete
<add> (HOMEBREW_PREFIX/"share/fish/vendor_completions.d/brew-tap-cmd.fish").delete
<add> shutup { tap.link_completions_and_manpages }
<add> assert_predicate HOMEBREW_PREFIX/"share/man/man1/brew-tap-cmd.1", :file?
<add> assert_predicate HOMEBREW_PREFIX/"etc/bash_completion.d/brew-tap-cmd", :file?
<add> assert_predicate HOMEBREW_PREFIX/"share/zsh/site-functions/_brew-tap-cmd", :file?
<add> assert_predicate HOMEBREW_PREFIX/"share/fish/vendor_completions.d/brew-tap-cmd.fish", :file?
<add> shutup { tap.uninstall }
<add> ensure
<add> (HOMEBREW_PREFIX/"etc").rmtree if (HOMEBREW_PREFIX/"etc").exist?
<add> (HOMEBREW_PREFIX/"share").rmtree if (HOMEBREW_PREFIX/"share").exist?
<ide> end
<ide>
<ide> def test_pin_and_unpin
<ide><path>Library/Homebrew/utils.rb
<ide> require "utils/github"
<ide> require "utils/hash"
<ide> require "utils/inreplace"
<add>require "utils/link"
<ide> require "utils/popen"
<ide> require "utils/tty"
<ide> require "time"
<ide> def truncate_text_to_approximate_size(s, max_bytes, options = {})
<ide> out
<ide> end
<ide>
<del>def link_src_dst_dirs(src_dir, dst_dir, command, link_dir: false)
<del> return unless src_dir.exist?
<del> conflicts = []
<del> src_paths = link_dir ? [src_dir] : src_dir.find
<del> src_paths.each do |src|
<del> next if src.directory? && !link_dir
<del> dst = dst_dir/src.relative_path_from(src_dir)
<del> if dst.symlink?
<del> next if src == dst.resolved_path
<del> dst.unlink
<del> end
<del> if dst.exist?
<del> conflicts << dst
<del> next
<del> end
<del> dst_dir.parent.mkpath
<del> dst.make_relative_symlink(src)
<del> end
<del>
<del> return if conflicts.empty?
<del> onoe <<-EOS.undent
<del> Could not link:
<del> #{conflicts.join("\n")}
<del>
<del> Please delete these paths and run `#{command}`.
<del> EOS
<del>end
<del>
<del>def link_path_manpages(path, command)
<del> link_src_dst_dirs(path/"man", HOMEBREW_PREFIX/"share/man", command)
<del>end
<del>
<ide> def migrate_legacy_keg_symlinks_if_necessary
<ide> legacy_linked_kegs = HOMEBREW_LIBRARY/"LinkedKegs"
<ide> return unless legacy_linked_kegs.directory?
<ide><path>Library/Homebrew/utils/link.rb
<add>module Utils
<add> module Link
<add> module_function
<add>
<add> def link_src_dst_dirs(src_dir, dst_dir, command, link_dir: false)
<add> return unless src_dir.exist?
<add> conflicts = []
<add> src_paths = link_dir ? [src_dir] : src_dir.find
<add> src_paths.each do |src|
<add> next if src.directory? && !link_dir
<add> dst = dst_dir/src.relative_path_from(src_dir)
<add> if dst.symlink?
<add> next if src == dst.resolved_path
<add> dst.unlink
<add> end
<add> if dst.exist?
<add> conflicts << dst
<add> next
<add> end
<add> dst_dir.parent.mkpath
<add> dst.make_relative_symlink(src)
<add> end
<add>
<add> return if conflicts.empty?
<add> onoe <<-EOS.undent
<add> Could not link:
<add> #{conflicts.join("\n")}
<add>
<add> Please delete these paths and run `#{command}`.
<add> EOS
<add> end
<add> private_class_method :link_src_dst_dirs
<add>
<add> def unlink_src_dst_dirs(src_dir, dst_dir, unlink_dir: false)
<add> return unless src_dir.exist?
<add> src_paths = unlink_dir ? [src_dir] : src_dir.find
<add> src_paths.each do |src|
<add> next if src.directory? && !unlink_dir
<add> dst = dst_dir/src.relative_path_from(src_dir)
<add> dst.delete if dst.symlink? && src == dst.resolved_path
<add> dst.parent.rmdir_if_possible
<add> end
<add> end
<add> private_class_method :unlink_src_dst_dirs
<add>
<add> def link_manpages(path, command)
<add> link_src_dst_dirs(path/"manpages", HOMEBREW_PREFIX/"share/man/man1", command)
<add> end
<add>
<add> def unlink_manpages(path)
<add> unlink_src_dst_dirs(path/"manpages", HOMEBREW_PREFIX/"share/man/man1")
<add> end
<add>
<add> def link_completions(path, command)
<add> link_src_dst_dirs(path/"completions/bash", HOMEBREW_PREFIX/"etc/bash_completion.d", command)
<add> link_src_dst_dirs(path/"completions/zsh", HOMEBREW_PREFIX/"share/zsh/site-functions", command)
<add> link_src_dst_dirs(path/"completions/fish", HOMEBREW_PREFIX/"share/fish/vendor_completions.d", command)
<add> end
<add>
<add> def unlink_completions(path)
<add> unlink_src_dst_dirs(path/"completions/bash", HOMEBREW_PREFIX/"etc/bash_completion.d")
<add> unlink_src_dst_dirs(path/"completions/zsh", HOMEBREW_PREFIX/"share/zsh/site-functions")
<add> unlink_src_dst_dirs(path/"completions/fish", HOMEBREW_PREFIX/"share/fish/vendor_completions.d")
<add> end
<add>
<add> def link_docs(path, command)
<add> link_src_dst_dirs(path/"docs", HOMEBREW_PREFIX/"share/doc/homebrew", command, link_dir: true)
<add> end
<add> end
<add>end | 7 |
Text | Text | remove linux from the unsupported tap list | 04473795b1abed43463cb4668a75cf3b0ea30b75 | <ide><path>docs/Interesting-Taps-and-Forks.md
<ide> Your taps are Git repositories located at `$(brew --repository)/Library/Taps`.
<ide> ## Unsupported interesting forks
<ide>
<ide> * [mistydemeo/tigerbrew](https://github.com/mistydemeo/tigerbrew): Experimental Tiger PowerPC version.
<del>
<del>* [Linuxbrew/brew](https://github.com/Linuxbrew/brew): Experimental Linux version. | 1 |
Text | Text | add text to 'irb' section. | 2e925ad6805bb6b4b8d37685b479e50800e74a99 | <ide><path>guide/english/ruby/index.md
<ide> To know about how to install Ruby through package managers, installers and sourc
<ide>
<ide> ## IRB
<ide>
<del>IRB stands for Interactive Ruby Shell. The abbreviation irb comes from the fact that the filename extension for Ruby is ".rb", although interactive Ruby files do not have an extension of ".irb". The program is launched from a command line and allows the execution of Ruby commands with an immediate response, experimenting in real-time. It features command history, line editing capabilities, and job control, and is able to communicate directly as a shell script over the Internet and interact with a live server. It was developed by Keiju Ishitsuka.
<add>IRB stands for Interactive Ruby Shell. The abbreviation irb comes from the fact that the filename extension for Ruby is ".rb", although interactive Ruby files do not have an extension of ".irb". The program is launched from a command line and allows the execution of Ruby commands with an immediate response, experimenting in real-time. It features command history, line editing capabilities, and job control, and is able to communicate directly as a shell script over the Internet and interact with a live server. Interactive Ruby Shell is a great way to explore the Ruby language and quickly test scripts. It was developed by Keiju Ishitsuka.
<ide>
<ide> ```shell
<ide> irb | 1 |
Text | Text | update serverrendering to highlight security issue | e2bdf4ad730b3cdd4fcdd36c6f5d578e7ff761a6 | <ide><path>docs/recipes/ServerRendering.md
<ide> function renderFullPage(html, preloadedState) {
<ide> <body>
<ide> <div id="root">${html}</div>
<ide> <script>
<add> // WARNING: See the following for Security isues with this approach:
<add> // http://redux.js.org/docs/recipes/ServerRendering.html#security-considerations
<ide> window.__PRELOADED_STATE__ = ${JSON.stringify(preloadedState)}
<ide> </script>
<ide> <script src="/static/bundle.js"></script> | 1 |
Javascript | Javascript | remove debugenvironment from oss | 01fffa245d642cae961b63e4ee0e026b6b2153d0 | <ide><path>Libraries/Utilities/DebugEnvironment.js
<del>/**
<del> * Copyright (c) 2013-present, Facebook, Inc.
<del> *
<del> * This source code is licensed under the MIT license found in the
<del> * LICENSE file in the root directory of this source tree.
<del> *
<del> * @providesModule DebugEnvironment
<del> * @flow
<del> */
<del>
<del>'use strict';
<del>
<del>module.exports = {
<del> // When crippled, synchronous JS function calls to native will fail.
<del> isCrippledMode: __DEV__ && !global.nativeCallSyncHook,
<del>}; | 1 |
PHP | PHP | implement date_format validation rule | a40aabbb05805cbbc7ea3a755f0131787b09e749 | <ide><path>application/language/en/validation.php
<ide> "countbetween" => "The :attribute must have between :min and :max selected elements.",
<ide> "countmax" => "The :attribute must have less than :max selected elements.",
<ide> "countmin" => "The :attribute must have at least :min selected elements.",
<add> "date_format" => "The :attribute must have a valid date format.",
<ide> "different" => "The :attribute and :other must be different.",
<ide> "email" => "The :attribute format is invalid.",
<ide> "exists" => "The selected :attribute is invalid.",
<ide><path>laravel/validator.php
<ide> protected function validate_after($attribute, $value, $parameters)
<ide> return (strtotime($value) > strtotime($parameters[0]));
<ide> }
<ide>
<add> /**
<add> * Validate the date conforms to a given format.
<add> *
<add> * @param string $attribute
<add> * @param mixed $value
<add> * @param array $parameters
<add> * @return bool
<add> */
<add> protected function validate_date_format($attribute, $value, $parameters)
<add> {
<add> return date_create_from_format($parameters[0], $value) !== false;
<add> }
<add>
<ide> /**
<ide> * Get the proper error message for an attribute and rule.
<ide> * | 2 |
Python | Python | replace deprecated functions nn 2 rnn | 84840387f3c0bda539673c64da5ae30ea5787626 | <ide><path>research/deep_speech/deep_speech_model.py
<ide>
<ide> # Supported rnn cells.
<ide> SUPPORTED_RNNS = {
<del> "lstm": tf.nn.rnn_cell.BasicLSTMCell,
<del> "rnn": tf.nn.rnn_cell.RNNCell,
<del> "gru": tf.nn.rnn_cell.GRUCell,
<add> "lstm": tf.contrib.rnn.BasicLSTMCell,
<add> "rnn": tf.contrib.rnn.RNNCell,
<add> "gru": tf.contrib.rnn.GRUCell,
<ide> }
<ide>
<ide> # Parameters for batch normalization. | 1 |
Java | Java | add clientrequest attribute for uri template | 9352e3d047e27a91149e471bac7584ff17fa6b92 | <ide><path>spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClient.java
<ide> */
<ide> class DefaultWebClient implements WebClient {
<ide>
<add> private static final String URI_TEMPLATE_ATTRIBUTE = WebClient.class.getName() + ".uriTemplate";
<add>
<ide> private static final Mono<ClientResponse> NO_HTTP_CLIENT_RESPONSE_ERROR = Mono.error(
<ide> new IllegalStateException("The underlying HTTP client completed without emitting a response."));
<ide>
<ide> private class DefaultRequestBodyUriSpec implements RequestBodyUriSpec {
<ide> @Nullable
<ide> private BodyInserter<?, ? super ClientHttpRequest> inserter;
<ide>
<del> @Nullable
<del> private Map<String, Object> attributes;
<add> private final Map<String, Object> attributes = new LinkedHashMap<>(4);
<add>
<ide>
<ide> DefaultRequestBodyUriSpec(HttpMethod httpMethod) {
<ide> this.httpMethod = httpMethod;
<ide> }
<ide>
<ide> @Override
<ide> public RequestBodySpec uri(String uriTemplate, Object... uriVariables) {
<add> attribute(URI_TEMPLATE_ATTRIBUTE, uriTemplate);
<ide> return uri(uriBuilderFactory.expand(uriTemplate, uriVariables));
<ide> }
<ide>
<ide> @Override
<ide> public RequestBodySpec uri(String uriTemplate, Map<String, ?> uriVariables) {
<add> attribute(URI_TEMPLATE_ATTRIBUTE, uriTemplate);
<ide> return uri(uriBuilderFactory.expand(uriTemplate, uriVariables));
<ide> }
<ide>
<ide> private MultiValueMap<String, String> getCookies() {
<ide> return this.cookies;
<ide> }
<ide>
<del> private Map<String, Object> getAttributes() {
<del> if (this.attributes == null) {
<del> this.attributes = new LinkedHashMap<>(4);
<del> }
<del> return this.attributes;
<del> }
<del>
<ide> @Override
<ide> public DefaultRequestBodyUriSpec header(String headerName, String... headerValues) {
<ide> for (String headerValue : headerValues) {
<ide> public DefaultRequestBodyUriSpec headers(Consumer<HttpHeaders> headersConsumer)
<ide>
<ide> @Override
<ide> public RequestBodySpec attribute(String name, Object value) {
<del> getAttributes().put(name, value);
<add> this.attributes.put(name, value);
<ide> return this;
<ide> }
<ide>
<ide> @Override
<ide> public RequestBodySpec attributes(Consumer<Map<String, Object>> attributesConsumer) {
<ide> Assert.notNull(attributesConsumer, "'attributesConsumer' must not be null");
<del> attributesConsumer.accept(getAttributes());
<add> attributesConsumer.accept(this.attributes);
<ide> return this;
<ide> }
<ide>
<ide> private ClientRequest.Builder initRequestBuilder() {
<ide> return ClientRequest.method(this.httpMethod, uri)
<ide> .headers(headers -> headers.addAll(initHeaders()))
<ide> .cookies(cookies -> cookies.addAll(initCookies()))
<del> .attributes(attributes -> attributes.putAll(getAttributes()));
<add> .attributes(attributes -> attributes.putAll(this.attributes));
<ide> }
<ide>
<ide> private HttpHeaders initHeaders() { | 1 |
Javascript | Javascript | add internal function _deprecationwarning() | 97900776bb3611877d126aa58743eb9b5b2a4be8 | <ide><path>lib/os.js
<ide> exports.platform = function() {
<ide> return process.platform;
<ide> };
<ide>
<del>var warnNetworkInterfaces = true;
<ide> exports.getNetworkInterfaces = function() {
<del> if (warnNetworkInterfaces) {
<del> console.error("os.getNetworkInterfaces() is deprecated - use os.networkInterfaces()");
<del> console.trace();
<del> warnNetworkInterfaces = false;
<del> }
<add> require('util')._deprecationWarning('os',
<add> 'os.getNetworkInterfaces() is deprecated - use os.networkInterfaces()');
<ide> return exports.networkInterfaces();
<ide> };
<ide><path>lib/sys.js
<ide>
<ide> var util = require('util');
<ide>
<del>var sysWarning;
<del>if (!sysWarning) {
<del> sysWarning = 'The "sys" module is now called "util". ' +
<del> 'It should have a similar interface.';
<del> if (process.env.NODE_DEBUG && process.env.NODE_DEBUG.indexOf('sys') != -1)
<del> console.trace(sysWarning);
<del> else
<del> console.error(sysWarning);
<del>}
<add>util._deprecationWarning('sys',
<add> 'The "sys" module is now called "util". It should have a similar interface.');
<ide>
<ide> exports.print = util.print;
<ide> exports.puts = util.puts;
<ide><path>lib/util.js
<ide> exports.inherits = function(ctor, superCtor) {
<ide> }
<ide> });
<ide> };
<add>
<add>var deprecationWarnings;
<add>
<add>exports._deprecationWarning = function(moduleId, message) {
<add> if (!deprecationWarnings)
<add> deprecationWarnings = {};
<add> else if (message in deprecationWarnings)
<add> return;
<add>
<add> deprecationWarnings[message] = true;
<add>
<add> if ((new RegExp('\\b' + moduleId + '\\b')).test(process.env.NODE_DEBUG))
<add> console.trace(message);
<add> else
<add> console.error(message);
<add>}; | 3 |
Javascript | Javascript | add clone property to bufferattribute.js | b17e3a5d557521fa9195267195de4305b276c464 | <ide><path>src/core/BufferAttribute.js
<ide> THREE.BufferAttribute.prototype = {
<ide>
<ide> return this;
<ide>
<add> },
<add>
<add> clone: function () {
<add>
<add> var attribute = new THREE.BufferAttribute( null, this.itemSize );
<add>
<add> var types = [ Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array ];
<add>
<add> var sourceArray = this.array;
<add>
<add> for ( var i = 0, il = types.length; i < il; i ++ ) {
<add>
<add> var type = types[ i ];
<add>
<add> if ( sourceArray instanceof type ) {
<add>
<add> attribute.array = new type( sourceArray );
<add> break;
<add>
<add> }
<add>
<add> }
<add>
<add> return attribute;
<add>
<ide> }
<ide>
<ide> }; | 1 |
Javascript | Javascript | add regex for expected error message | c13dda1c43a79d74c7aca085c42d2f19b8fd21b1 | <ide><path>test/parallel/test-tls-key-mismatch.js
<ide> if (!common.hasCrypto) {
<ide> const assert = require('assert');
<ide> const tls = require('tls');
<ide> const fs = require('fs');
<add>const errorMessageRegex = new RegExp('^Error: error:0B080074:x509 ' +
<add> 'certificate routines:X509_check_private_key:key values mismatch$');
<ide>
<ide> const options = {
<ide> key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'),
<ide> const options = {
<ide>
<ide> assert.throws(function() {
<ide> tls.createSecureContext(options);
<del>});
<add>}, errorMessageRegex); | 1 |
Python | Python | break long line | 78bb1d47eb482f74eb461d66248fbdf0a4e23786 | <ide><path>numpy/core/tests/test_mem_overlap.py
<ide> import itertools
<ide>
<ide> import numpy as np
<del>from numpy.testing import (run_module_suite, assert_, assert_raises, assert_equal, assert_array_equal,
<del> assert_allclose)
<add>from numpy.testing import (run_module_suite, assert_, assert_raises, assert_equal,
<add> assert_array_equal, assert_allclose)
<ide>
<ide> from numpy.core.multiarray_tests import solve_diophantine, internal_overlap
<ide> from numpy.core import umath_tests | 1 |
Javascript | Javascript | skip less and stabilize test-linux-perf.js | 546d6cdd9e70a9e25b3c43e88d3acac875a478f8 | <ide><path>test/fixtures/linux-perf.js
<ide> 'use strict';
<ide>
<del>const crypto = require('crypto');
<add>const { spawnSync } = require("child_process");
<add>const sleepTime = new Number(process.argv[2] || "0.1");
<add>const repeat = new Number(process.argv[3]) || 5;
<ide>
<del>// Functions should be complex enough for V8 to run them a few times before
<del>// compiling, but not complex enough to always stay in interpreted mode. They
<del>// should also take some time to run, otherwise Linux perf might miss them
<del>// entirely even when sampling at a high frequency.
<del>function functionOne(i) {
<del> for (let j=i; j > 0; j--) {
<del> crypto.createHash('md5').update(functionTwo(i, j)).digest("hex");
<del> }
<add>function functionOne() {
<add> functionTwo();
<ide> }
<ide>
<del>function functionTwo(x, y) {
<del> let data = ((((x * y) + (x / y)) * y) ** (x + 1)).toString();
<del> if (x % 2 == 0) {
<del> return crypto.createHash('md5').update(data.repeat((x % 100) + 1)).digest("hex");
<del> } else {
<del> return crypto.createHash('md5').update(data.repeat((y % 100) + 1)).digest("hex");
<del> }
<add>function functionTwo() {
<add> spawnSync('sleep', [`${sleepTime}`]);
<ide> }
<ide>
<del>for (let i = 0; i < 1000; i++) {
<del> functionOne(i);
<add>for (let i = 0; i < repeat; i++) {
<add> functionOne();
<ide> }
<ide><path>test/v8-updates/test-linux-perf.js
<ide> tmpdir.refresh();
<ide> if (process.config.variables.node_shared)
<ide> common.skip("can't test Linux perf with shared libraries yet");
<ide>
<del>const perfArgs = [
<add>if (!common.isLinux)
<add> common.skip('only testing Linux for now');
<add>
<add>const frequency = 99;
<add>
<add>const repeat = 5;
<add>
<add>// Expected number of samples we'll capture per repeat
<add>const sampleCount = 10;
<add>const sleepTime = sampleCount * (1.0 / frequency);
<add>
<add>const perfFlags = [
<ide> 'record',
<del> '-F999',
<add> `-F${frequency}`,
<ide> '-g',
<del> '--',
<del> process.execPath,
<add>];
<add>
<add>const nodeCommonFlags = [
<ide> '--perf-basic-prof',
<ide> '--interpreted-frames-native-stack',
<ide> '--no-turbo-inlining', // Otherwise simple functions might get inlined.
<add>];
<add>
<add>const perfInterpretedFramesArgs = [
<add> ...perfFlags,
<add> '--',
<add> process.execPath,
<add> ...nodeCommonFlags,
<add> '--no-opt',
<ide> fixtures.path('linux-perf.js'),
<add> `${sleepTime}`,
<add> `${repeat}`,
<add>];
<add>
<add>const perfCompiledFramesArgs = [
<add> ...perfFlags,
<add> '--',
<add> process.execPath,
<add> ...nodeCommonFlags,
<add> '--always-opt',
<add> fixtures.path('linux-perf.js'),
<add> `${sleepTime}`,
<add> `${repeat}`,
<add>];
<add>
<add>const perfArgsList = [
<add> perfInterpretedFramesArgs, perfCompiledFramesArgs
<ide> ];
<ide>
<ide> const perfScriptArgs = [
<ide> const options = {
<ide> encoding: 'utf-8',
<ide> };
<ide>
<del>if (!common.isLinux)
<del> common.skip('only testing Linux for now');
<del>
<del>const perf = spawnSync('perf', perfArgs, options);
<del>
<del>if (perf.error && perf.error.errno === 'ENOENT')
<del> common.skip('perf not found on system');
<del>
<del>if (perf.status !== 0) {
<del> common.skip(`Failed to execute perf: ${perf.stderr}`);
<del>}
<add>let output = '';
<ide>
<del>const perfScript = spawnSync('perf', perfScriptArgs, options);
<add>for (const perfArgs of perfArgsList) {
<add> const perf = spawnSync('perf', perfArgs, options);
<add> assert.ifError(perf.error);
<add> if (perf.status !== 0)
<add> throw new Error(`Failed to execute 'perf': ${perf.stderr}`);
<ide>
<del>if (perf.error)
<del> common.skip(`perf script aborted: ${perf.error.errno}`);
<add> const perfScript = spawnSync('perf', perfScriptArgs, options);
<add> assert.ifError(perfScript.error);
<add> if (perfScript.status !== 0)
<add> throw new Error(`Failed to execute perf script: ${perfScript.stderr}`);
<ide>
<del>if (perfScript.status !== 0) {
<del> common.skip(`Failed to execute perf script: ${perfScript.stderr}`);
<add> output += perfScript.stdout;
<ide> }
<ide>
<ide> const interpretedFunctionOneRe = /InterpretedFunction:functionOne/;
<ide> const compiledFunctionOneRe = /LazyCompile:\*functionOne/;
<ide> const interpretedFunctionTwoRe = /InterpretedFunction:functionTwo/;
<ide> const compiledFunctionTwoRe = /LazyCompile:\*functionTwo/;
<ide>
<del>const output = perfScript.stdout;
<ide>
<ide> assert.ok(output.match(interpretedFunctionOneRe),
<ide> "Couldn't find interpreted functionOne()"); | 2 |
Python | Python | support arbitrary dimensions in stochastic depth | 0537226c75d542225553ca2a7ae3b88fb75b0d7a | <ide><path>official/vision/beta/modeling/layers/nn_layers.py
<ide> def call(self, inputs, training=None):
<ide> batch_size = tf.shape(inputs)[0]
<ide> random_tensor = keep_prob
<ide> random_tensor += tf.random.uniform(
<del> [batch_size, 1, 1, 1], dtype=inputs.dtype)
<add> [batch_size] + [1] * (inputs.shape.rank - 1), dtype=inputs.dtype)
<ide> binary_tensor = tf.floor(random_tensor)
<ide> output = tf.math.divide(inputs, keep_prob) * binary_tensor
<ide> return output | 1 |
Go | Go | add missing file | f73401fb9a0993d12da9ef60f265cd0502bb3808 | <ide><path>rcli/utils.go
<add>package rcli
<add>
<add>import (
<add> "github.com/dotcloud/docker/term"
<add> "os"
<add> "os/signal"
<add>)
<add>
<add>//FIXME: move these function to utils.go (in rcli to avoid import loop)
<add>func SetRawTerminal() (*term.State, error) {
<add> oldState, err := term.MakeRaw(int(os.Stdin.Fd()))
<add> if err != nil {
<add> return nil, err
<add> }
<add> c := make(chan os.Signal, 1)
<add> signal.Notify(c, os.Interrupt)
<add> go func() {
<add> _ = <-c
<add> term.Restore(int(os.Stdin.Fd()), oldState)
<add> os.Exit(0)
<add> }()
<add> return oldState, err
<add>}
<add>
<add>func RestoreTerminal(state *term.State) {
<add> term.Restore(int(os.Stdin.Fd()), state)
<add>} | 1 |
Text | Text | revise mac docker instructions | 9572edc34a65736415050f02df3822edeaa55dbc | <ide><path>docs/installation/mac.md
<ide> and choosing "Open" from the pop-up menu.
<ide>
<ide> * installs binaries for the Docker tools in `/usr/local/bin`
<ide> * makes these binaries available to all users
<del> * updates any existing VirtualBox installation
<add> * installs VirtualBox; or updates any existing installation
<ide>
<ide> Change these defaults by pressing "Customize" or "Change
<ide> Install Location."
<ide> There are two ways to use the installed tools, from the Docker Quickstart Termin
<ide>
<ide> 1. Open the "Applications" folder or the "Launchpad".
<ide>
<del>2. Find the Docker Quickstart Terminal and double-click to launch it.
<add>2. Find the Docker Quickstart Terminal and double-click to launch it.
<ide>
<ide> The application:
<ide>
<ide> * opens a terminal window
<del> * creates a VM called `default` if it doesn't exists, starts the VM if it does
<add> * creates a `default` VM if it doesn't exists, and starts the VM after
<ide> * points the terminal environment to this VM
<ide>
<ide> Once the launch completes, the Docker Quickstart Terminal reports:
<ide> different shell such as C Shell but the commands are the same.
<ide> Starting VM...
<ide> To see how to connect Docker to this machine, run: docker-machine env default
<ide>
<del> This creates a new `default` in VirtualBox.
<add> This creates a new `default` VM in VirtualBox.
<ide>
<ide> 
<ide>
<ide> different shell such as C Shell but the commands are the same.
<ide>
<ide> If you have previously installed the deprecated Boot2Docker application or
<ide> run the Docker Quickstart Terminal, you may have a `dev` VM as well. When you
<del> created `default`, the `docker-machine` command provided instructions
<add> created `default` VM, the `docker-machine` command provided instructions
<ide> for learning how to connect the VM.
<ide>
<ide> 3. Get the environment commands for your new VM.
<ide> different shell such as C Shell but the commands are the same.
<ide> ## Learn about your Toolbox installation
<ide>
<ide> Toolbox installs the Docker Engine binary, the Docker binary on your system. When you
<del>use the Docker Quickstart Terminal or create a `default` manually, Docker
<add>use the Docker Quickstart Terminal or create a `default` VM manually, Docker
<ide> Machine updates the `~/.docker/machine/machines/default` folder to your
<ide> system. This folder contains the configuration for the VM.
<ide>
<del>You can create multiple VMs on your system with Docker Machine. So, you may have
<del>more than one VM folder if you have more than one VM. To remove a VM, use the
<del>`docker-machine rm <machine-name>` command.
<add>You can create multiple VMs on your system with Docker Machine. Therefore, you
<add>may end up with multiple VM folders if you have more than one VM. To remove a
<add>VM, use the `docker-machine rm <machine-name>` command.
<ide>
<ide> ## Migrate from Boot2Docker
<ide> | 1 |
Text | Text | remove comma splice in events.md | fe955074037aa3c9fc4f41a298f176450c42937e | <ide><path>doc/api/events.md
<ide> events. Listeners installed using this symbol are called before the regular
<ide> `'error'` listeners are called.
<ide>
<ide> Installing a listener using this symbol does not change the behavior once an
<del>`'error'` event is emitted, therefore the process will still crash if no
<add>`'error'` event is emitted. Therefore, the process will still crash if no
<ide> regular `'error'` listener is installed.
<ide>
<ide> ## `events.getEventListeners(emitterOrTarget, eventName)` | 1 |
Text | Text | fix some typos | 02091b2c1ec68cfc5b4b88295575cfdfce71fad5 | <ide><path>CHANGELOG.md
<ide> function MyCtrl() {
<ide>
<ide> <pre>
<ide> function MyCtrl($scope) {
<del> $scope.mode = 'some model of any type';
<add> $scope.model = 'some model of any type';
<ide>
<ide> $scope.fnUsedFromTemplate = function() {
<ide> someApiThatTakesCallback(function() {
<ide> behavior and migrate your controllers one at a time: <https://gist.github.com/16
<ide> ([commit](https://github.com/angular/angular.js/commit/7da2bdb82a72dffc8c72c1becf6f62aae52d32ce),
<ide> [commit](https://github.com/angular/angular.js/commit/39b3297fc34b6b15bb3487f619ad1e93c4480741))
<ide> - `$http` should not json-serialize File objects, instead just send them raw
<del> ([commit](https://github.com/angular/angular.js/commit/5b0d0683584e304db30462f3448d9f090120c444)
<add> ([commit](https://github.com/angular/angular.js/commit/5b0d0683584e304db30462f3448d9f090120c444))
<ide> - `$compile` should ignore content of style and script elements
<ide> ([commit](https://github.com/angular/angular.js/commit/4c1c50fd9bfafaa89cdc66dfde818a3f8f4b0c6b),
<ide> [commit](https://github.com/angular/angular.js/commit/d656d11489a0dbce0f549b20006052b215c4b500)) | 1 |
Javascript | Javascript | add filter infra to configtestcases | 2f8e3fcebb56e6364955840283501c6661feec8c | <ide><path>test/ConfigTestCases.test.js
<ide> describe("ConfigTestCases", function() {
<ide> });
<ide> categories.forEach(function(category) {
<ide> describe(category.name, function() {
<del> category.tests.forEach(function(testName) {
<add> category.tests.filter(function(testName) {
<add> var testDirectory = path.join(casesPath, category.name, testName);
<add> var filterPath = path.join(testDirectory, "test.filter.js");
<add> var config = require(path.join(testDirectory, "webpack.config.js"));
<add> if(fs.existsSync(filterPath) && !require(filterPath)(config)) {
<add> describe.skip(testName, function() {
<add> it('filtered');
<add> });
<add> return false;
<add> }
<add> return true;
<add> }).forEach(function(testName) {
<add> var testDirectory = path.join(casesPath, category.name, testName);
<add> var filterPath = path.join(testDirectory, "test.filter.js");
<add> var options = require(path.join(testDirectory, "webpack.config.js"));
<ide> var suite = describe(testName, function() {});
<ide> it(testName + " should compile", function(done) {
<ide> this.timeout(30000);
<del> var testDirectory = path.join(casesPath, category.name, testName);
<ide> var outputDirectory = path.join(__dirname, "js", "config", category.name, testName);
<del> var options = require(path.join(testDirectory, "webpack.config.js"));
<ide> var optionsArr = [].concat(options);
<ide> optionsArr.forEach(function(options, idx) {
<ide> if(!options.context) options.context = testDirectory;
<ide><path>test/configCases/target/node-dynamic-import/test.filter.js
<ide> var supportsES6 = require("../../../helpers/supportsES6");
<ide>
<ide> module.exports = function(config) {
<del> return !config.minimize && supportsES6();
<add> return supportsES6();
<ide> }; | 2 |
Text | Text | update changelog for 1.8.0 | e55d352e942465479fa9f93b566db20a96b4cf15 | <ide><path>CHANGELOG.md
<add>
<add><a name="1.8.0"></a>
<add># 1.8.0 nested-vaccination (2020-06-01)
<add>
<add>## Bug Fixes
<add>- **jqLite:**
<add> - prevent possible XSS due to regex-based HTML replacement
<add> ([2df43c](https://github.com/angular/angular.js/commit/2df43c07779137d1bddf7f3b282a1287a8634acd))
<add>
<add>## Breaking Changes
<add>
<add>### **jqLite** due to:
<add> - **[2df43c](https://github.com/angular/angular.js/commit/2df43c07779137d1bddf7f3b282a1287a8634acd)**: prevent possible XSS due to regex-based HTML replacement
<add>
<add>JqLite no longer turns XHTML-like strings like `<div /><span />` to sibling elements `<div></div><span></span>`
<add>when not in XHTML mode. Instead it will leave them as-is. The browser, in non-XHTML mode, will convert these to:
<add>`<div><span></span></div>`.
<add>
<add>This is a security fix to avoid an XSS vulnerability if a new jqLite element is created from a user-controlled HTML string.
<add>If you must have this functionality and understand the risk involved then it is posible to restore the original behavior by calling
<add>
<add>```js
<add>angular.UNSAFE_restoreLegacyJqLiteXHTMLReplacement();
<add>```
<add>
<add>But you should adjust your code for this change and remove your use of this function as soon as possible.
<add>
<add>Note that this only patches jqLite. If you use jQuery 3.5.0 or newer, please read the [jQuery 3.5 upgrade guide](https://jquery.com/upgrade-guide/3.5/) for more details about the workarounds.
<add>
<add>
<ide> <a name="1.7.9"></a>
<ide> # 1.7.9 pollution-eradication (2019-11-19)
<ide> | 1 |
PHP | PHP | show maintenance message on error page | b3fe47783d2a0bd6557c1744c3d711cd73c7198c | <ide><path>src/Illuminate/Foundation/Exceptions/views/503.blade.php
<ide> </div>
<ide> @endsection
<ide>
<del>@section('message', __('Sorry, we are doing some maintenance. Please check back soon.'))
<add>@section('message', __($exception->getMessage() ?: 'Sorry, we are doing some maintenance. Please check back soon.')) | 1 |
Text | Text | allow valid link tags in curriculum | 37c886e9db77acd83fea5f50a84a3f5a6d4168e8 | <ide><path>curriculum/challenges/english/14-responsive-web-design-22/learn-basic-css-by-building-a-cafe-menu/5f3477cb2e27333b1ab2b955.md
<ide> You should not change your existing `head` element. Make sure you did not delete
<ide> assert($('head').length === 1);
<ide> ```
<ide>
<del>Your `link` element should be a self-closing element.
<add>You should have a one a self-closing `link` element.
<ide>
<ide> ```js
<del>assert(code.match(/<link[\w\W\s]+\/?>/i));
<add>const link = document.querySelectorAll('link');
<add>assert(link.length === 1);
<ide> ```
<ide>
<ide> Your `link` element should be within your `head` element.
<ide><path>curriculum/challenges/english/14-responsive-web-design-22/learn-css-animation-by-building-a-ferris-wheel/6140c7e645d8e905819f1dd4.md
<ide> Your code should have a `link` element.
<ide> assert.match(code, /<link/)
<ide> ```
<ide>
<del>Your `link` element should be a self-closing element.
<add>You should have a one a self-closing `link` element.
<ide>
<ide> ```js
<del>assert(code.match(/<link[\w\W\s]+\/>/i));
<add>assert(document.querySelectorAll('link').length === 1);
<ide> ```
<ide>
<ide> Your `link` element should be within your `head` element.
<ide>
<ide> ```js
<del>assert(code.match(/<head>[\w\W\s]*<link[\w\W\s]*\/>[\w\W\s]*<\/head>/i))
<add>assert.exists(document.querySelector('head > link'));
<ide> ```
<ide>
<ide> Your `link` element should have a `rel` attribute with the value `stylesheet`.
<ide>
<ide> ```js
<del>assert.match(code, /<link[\s\S]*?rel=('|"|`)stylesheet\1/)
<add>const link_element = document.querySelector('link');
<add>const rel = link_element.getAttribute("rel");
<add>assert.equal(rel, "stylesheet");
<ide> ```
<ide>
<ide> Your `link` element should have an `href` attribute with the value `styles.css`.
<ide>
<ide> ```js
<del>assert.match(code, /<link[\s\S]*?href=('|"|`)(\.\/)?styles\.css\1/)
<add>const link = document.querySelector('link');
<add>assert.equal(link.dataset.href, "styles.css");
<ide> ```
<ide>
<ide> # --seed--
<ide><path>curriculum/challenges/english/14-responsive-web-design-22/learn-css-colors-by-building-a-set-of-colored-markers/61696ef7ac756c829f9e4048.md
<ide> Nest a `link` element within the `head`. Give it a `rel` attribute set to `style
<ide>
<ide> # --hints--
<ide>
<del>Your code should have one `link` element.
<add>You should have a one a self-closing `link` element.
<ide>
<ide> ```js
<del>assert(code.match(/<link/i)?.length === 1);
<del>```
<del>
<del>Your `link` element should be a self-closing element.
<del>
<del>```js
<del>assert(code.match(/<\/link>/i) === null);
<add>assert(document.querySelectorAll('link').length === 1);
<ide> ```
<ide>
<ide> Your `link` element should be within your `head` element.
<ide>
<ide> ```js
<del>const head = code.match(/<head>(.|\r|\n)*<\/head>/i)?.[0];
<del>assert(head.match(/<link/i)?.length === 1)
<add>assert.exists(document.querySelector('head > link'));
<ide> ```
<ide>
<ide> Your `link` element should have a `rel` attribute with the value `stylesheet`.
<ide>
<ide> ```js
<del>assert(code.match(/<link[\s\S]*?rel=('|"|`)stylesheet\1/gi)?.length === 1);
<add>const link_element = document.querySelector('link');
<add>const rel = link_element.getAttribute("rel");
<add>assert.equal(rel, "stylesheet");
<ide> ```
<ide>
<del>Your `link` element should have an `href` attribute with the value `styles.css`. Remember, casing matters when you link to an external file.
<add>Your `link` element should have an `href` attribute with the value `styles.css`.
<ide>
<ide> ```js
<del>assert.match(code, /<link[\s\S]*?href=('|"|`)(\.\/)?styles\.css\1/);
<add>const link = document.querySelector('link');
<add>assert.equal(link.dataset.href, "styles.css");
<ide> ```
<ide>
<ide> # --seed--
<ide><path>curriculum/challenges/english/14-responsive-web-design-22/learn-css-grid-by-building-a-magazine/614385513d91ae5c251c2052.md
<ide> Your font stylesheet will load three separate fonts: `Anton`, `Baskervville`, an
<ide>
<ide> # --hints--
<ide>
<del>Your code should have three `link` elements.
<add>Your code should have three self-closing `link` elements.
<ide>
<ide> ```js
<del>assert(code.match(/<link/g)?.length === 3);
<add>assert(document.querySelectorAll('link').length === 3);
<ide> ```
<ide>
<del>Your `link` elements should be self-closing elements.
<add>Your `link` element should be within your `head` element.
<ide>
<ide> ```js
<del>assert(code.match(/<\/link>/i) === null);
<del>```
<del>
<del>Your `link` elements should be within your `head` element.
<del>
<del>```js
<del>const head = code.match(/<head>(.|\r|\n)*<\/head>/i)?.[0];
<del>assert(head.match(/<link/g)?.length === 3)
<add>assert(document.querySelectorAll('head > link').length === 3);
<ide> ```
<ide>
<ide> Your three `link` elements should have a `rel` attribute with the value `stylesheet`.
<ide>
<ide> ```js
<del>assert(code.match(/<link[\s\S]*?rel=('|"|`)stylesheet\1/gi)?.length === 3);
<add>const links = [...document.querySelectorAll('link')];
<add>assert(links.every(link => link.getAttribute('rel') === 'stylesheet'));
<ide> ```
<ide>
<ide> One of your link elements should have the `href` set to `https://fonts.googleapis.com/css?family=Anton|Baskervville|Raleway&display=swap`.
<ide> assert(links.find(link => link.getAttribute('href') === 'https://use.fontawesome
<ide> One of your `link` elements should have an `href` attribute with the value `styles.css`.
<ide>
<ide> ```js
<del>assert.match(code, /<link[\s\S]*?href=('|"|`)(\.\/)?styles\.css\1/)
<add>assert.match(code, /<link[\s\S]*?href\s*=\s*('|"|`)(\.\/)?styles\.css\1/)
<ide> ```
<ide>
<ide> Your code should have a `title` element.
<ide><path>curriculum/challenges/english/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e98cc.md
<ide> const heads = document.querySelectorAll('head');
<ide> assert.equal(heads?.length, 1);
<ide> ```
<ide>
<del>Your `link` element should be a self-closing element.
<add>You should have a one a self-closing `link` element.
<ide>
<ide> ```js
<del>assert(code.match(/<link[\w\W\s]+\/>/i));
<add>assert(document.querySelectorAll('link').length === 1);
<ide> ```
<ide>
<ide> Your `link` element should be within your `head` element.
<ide>
<ide> ```js
<del>assert(code.match(/<head>[\w\W\s]*<link[\w\W\s]*\/>[\w\W\s]*<\/head>/i))
<add>assert.exists(document.querySelector('head > link'));
<ide> ```
<ide>
<ide> Your `link` element should have a `rel` attribute with the value `stylesheet`.
<ide>
<ide> ```js
<del>assert.match(code, /<link[\s\S]*?rel=('|"|`)stylesheet\1/)
<add>const link_element = document.querySelector('link');
<add>const rel = link_element.getAttribute("rel");
<add>assert.equal(rel, "stylesheet");
<ide> ```
<ide>
<ide> Your `link` element should have an `href` attribute with the value `styles.css`.
<ide>
<ide> ```js
<del>assert.match(code, /<link[\s\S]*?href=('|"|`)(\.\/)?styles\.css\1/)
<add>const link = document.querySelector('link');
<add>assert.equal(link.dataset.href, "styles.css");
<ide> ```
<ide>
<ide> # --seed--
<ide><path>curriculum/challenges/english/14-responsive-web-design-22/learn-html-forms-by-building-a-registration-form/60f0286404aefb0562a4fdf9.md
<ide> const heads = document.querySelectorAll('head');
<ide> assert.equal(heads?.length, 1);
<ide> ```
<ide>
<del>Your `link` element should be a self-closing element.
<add>You should have a one a self-closing `link` element.
<ide>
<ide> ```js
<del>assert(code.match(/<link[\w\W\s]+\/>/i));
<add>assert(document.querySelectorAll('link').length === 1);
<ide> ```
<ide>
<ide> Your `link` element should be within your `head` element.
<ide><path>curriculum/challenges/english/14-responsive-web-design-22/learn-intermediate-css-by-building-a-picasso-painting/60b69a66b6ddb80858c5157a.md
<ide> Add a `link` element with a `rel` of `stylesheet` and an `href` of `https://use.
<ide>
<ide> # --hints--
<ide>
<del>You should add another `link` element.
<add>You should have two `link` elements.
<ide>
<ide> ```js
<ide> assert(document.querySelectorAll('link').length === 2);
<ide><path>curriculum/challenges/english/14-responsive-web-design-22/learn-intermediate-css-by-building-a-picasso-painting/60b80da8676fb3227967a731.md
<ide> Your code should have a `link` element.
<ide> assert.match(code, /<link/)
<ide> ```
<ide>
<del>Your `link` element should be a self-closing element.
<add>You should have a one a self-closing `link` element.
<ide>
<ide> ```js
<del>assert(code.match(/<link[\w\W\s]+\/>/i));
<add>assert(document.querySelectorAll('link').length === 1);
<ide> ```
<ide>
<ide> Your `link` element should be within your `head` element.
<ide>
<ide> ```js
<del>assert(code.match(/<head>[\w\W\s]*<link[\w\W\s]*\/>[\w\W\s]*<\/head>/i))
<add>assert.exists(document.querySelector('head > link'));
<ide> ```
<ide>
<ide> Your `link` element should have a `rel` attribute with the value `stylesheet`.
<ide>
<ide> ```js
<del>assert.match(code, /<link[\s\S]*?rel=('|"|`)stylesheet\1/)
<add>const link_element = document.querySelector('link');
<add>const rel = link_element.getAttribute("rel");
<add>assert.equal(rel, "stylesheet");
<ide> ```
<ide>
<ide> Your `link` element should have an `href` attribute with the value `styles.css`.
<ide>
<ide> ```js
<del>assert.match(code, /<link[\s\S]*?href=('|"|`)(\.\/)?styles\.css\1/)
<add>const link = document.querySelector('link');
<add>assert.equal(link.dataset.href, "styles.css");
<ide> ```
<ide>
<ide> # --seed--
<ide><path>curriculum/challenges/english/14-responsive-web-design-22/learn-responsive-web-design-by-building-a-piano/612e83ec2eca1e370f830511.md
<ide> const heads = document.querySelectorAll('head');
<ide> assert.equal(heads?.length, 1);
<ide> ```
<ide>
<del>Your `link` element should be a self-closing element.
<add>You should have a one a self-closing `link` element.
<ide>
<ide> ```js
<del>assert(code.match(/<link[\w\W\s]+\/>/i));
<add>assert(document.querySelectorAll('link').length === 1);
<ide> ```
<ide>
<ide> Your `link` element should be within your `head` element.
<ide>
<ide> ```js
<del>assert(code.match(/<head>[\w\W\s]*<link[\w\W\s]*\/>[\w\W\s]*<\/head>/i))
<add>assert.exists(document.querySelector('head > link'));
<ide> ```
<ide>
<ide> Your `link` element should have a `rel` attribute with the value `stylesheet`.
<ide>
<ide> ```js
<del>assert.match(code, /<link[\s\S]*?rel=('|"|`)stylesheet\1/)
<add>const link_element = document.querySelector('link');
<add>const rel = link_element.getAttribute("rel");
<add>assert.equal(rel, "stylesheet");
<ide> ```
<ide>
<ide> Your `link` element should have an `href` attribute with the value `styles.css`.
<ide>
<ide> ```js
<del>assert.match(code, /<link[\s\S]*?href=('|"|`)(\.\/)?styles\.css\1/)
<add>const link = document.querySelector('link');
<add>assert.equal(link.dataset.href, "styles.css");
<ide> ```
<ide>
<ide> # --seed--
<ide><path>curriculum/challenges/english/14-responsive-web-design-22/learn-typography-by-building-a-nutrition-label/615f34ecc1091b4fd5a8a484.md
<ide> Also add a `link` element to link your `styles.css` file.
<ide>
<ide> # --hints--
<ide>
<del>You should have two `link` elements.
<add>Your code should have two self-closing `link` elements.
<ide>
<ide> ```js
<del>assert(code.match(/<link/g)?.length === 2);
<add>assert(document.querySelectorAll('link').length === 2);
<ide> ```
<ide>
<ide> Both of your `link` elements should have the `rel` attribute set to `stylesheet`.
<ide>
<ide> ```js
<del>assert(code.match(/<link[\s\S]*?rel=('|"|`)stylesheet\1/)?.length === 2);
<add>const links = [...document.querySelectorAll('link')];
<add>assert(links.every(link => link.getAttribute('rel') === 'stylesheet'));
<ide> ```
<ide>
<ide> One of your `link` elements should have an `href` attribute set to `./styles.css`.
<ide>
<ide> ```js
<del>assert(code.match(/<link[\s\S]*?href=('|"|`)(\.\/)?styles\.css\1/g)?.length === 1);
<add>assert(code.match(/<link[\s\S]*?href\s*=\s*('|"|`)(\.\/)?styles\.css\1/g)?.length === 1);
<ide> ```
<ide>
<ide> One of your `link` elements should have an `href` attribute set to `https://fonts.googleapis.com/css?family=Open+Sans:400,700,800`. | 10 |
Javascript | Javascript | make request.abort() destroy the socket | 18d4ee97d812259eb11069614246c9adc5b9f719 | <ide><path>lib/_http_client.js
<ide> ClientRequest.prototype.onSocket = function onSocket(socket) {
<ide> function onSocketNT(req, socket) {
<ide> if (req.aborted) {
<ide> // If we were aborted while waiting for a socket, skip the whole thing.
<del> socket.emit('free');
<add> if (req.socketPath || !req.agent) {
<add> socket.destroy();
<add> } else {
<add> socket.emit('free');
<add> }
<ide> } else {
<ide> tickOnSocket(req, socket);
<ide> }
<ide><path>test/parallel/test-http-abort-queued-2.js
<add>'use strict';
<add>const common = require('../common');
<add>const assert = require('assert');
<add>const http = require('http');
<add>
<add>let socketsCreated = 0;
<add>
<add>class Agent extends http.Agent {
<add> createConnection(options, oncreate) {
<add> const socket = super.createConnection(options, oncreate);
<add> socketsCreated++;
<add> return socket;
<add> }
<add>}
<add>
<add>const server = http.createServer((req, res) => res.end());
<add>
<add>server.listen(0, common.mustCall(() => {
<add> const port = server.address().port;
<add> const agent = new Agent({
<add> keepAlive: true,
<add> maxSockets: 1
<add> });
<add>
<add> http.get({agent, port}, (res) => res.resume());
<add>
<add> const req = http.get({agent, port}, common.fail);
<add> req.abort();
<add>
<add> http.get({agent, port}, common.mustCall((res) => {
<add> res.resume();
<add> assert.strictEqual(socketsCreated, 1);
<add> agent.destroy();
<add> server.close();
<add> }));
<add>}));
<ide><path>test/parallel/test-http-client-abort-no-agent.js
<add>'use strict';
<add>const common = require('../common');
<add>const http = require('http');
<add>const net = require('net');
<add>
<add>const server = http.createServer(common.fail);
<add>
<add>server.listen(0, common.mustCall(() => {
<add> const req = http.get({
<add> createConnection(options, oncreate) {
<add> const socket = net.createConnection(options, oncreate);
<add> socket.once('close', () => server.close());
<add> return socket;
<add> },
<add> port: server.address().port
<add> });
<add>
<add> req.abort();
<add>}));
<ide><path>test/parallel/test-http-client-abort-unix-socket.js
<add>'use strict';
<add>const common = require('../common');
<add>const http = require('http');
<add>
<add>const server = http.createServer(common.fail);
<add>
<add>class Agent extends http.Agent {
<add> createConnection(options, oncreate) {
<add> const socket = super.createConnection(options, oncreate);
<add> socket.once('close', () => server.close());
<add> return socket;
<add> }
<add>}
<add>
<add>common.refreshTmpDir();
<add>
<add>server.listen(common.PIPE, common.mustCall(() => {
<add> const req = http.get({
<add> agent: new Agent(),
<add> socketPath: common.PIPE
<add> });
<add>
<add> req.abort();
<add>})); | 4 |
Text | Text | fix undefined method error for nilclass | 872b3c91b3d6bd5b418463cb92ecc05bce39649d | <ide><path>guides/source/action_controller_overview.md
<ide> the job done:
<ide>
<ide> ```ruby
<ide> def product_params
<del> params.require(:product).permit(:name, { data: params[:product][:data].keys })
<add> params.require(:product).permit(:name, { data: params[:product][:data].try(:keys) })
<ide> end
<ide> ```
<ide> | 1 |
Text | Text | explain kind (changetype) | 957bc8ac50ee4e2498143fca7848b4ccaab6147a | <ide><path>docs/sources/reference/api/docker_remote_api_v1.18.md
<ide> Inspect changes on container `id`'s filesystem
<ide> }
<ide> ]
<ide>
<add>Values for `Kind`:
<add>
<add>- `0`: Modify
<add>- `1`: Add
<add>- `2`: Delete
<add>
<ide> Status Codes:
<ide>
<ide> - **200** – no error | 1 |
Javascript | Javascript | change var to const in test-tls-key-mismatch.js | 99c07bf74272e170f036e653ba15344f615cf2b6 | <ide><path>test/parallel/test-tls-key-mismatch.js
<ide> 'use strict';
<del>var common = require('../common');
<del>var assert = require('assert');
<add>const common = require('../common');
<ide>
<ide> if (!common.hasCrypto) {
<ide> common.skip('missing crypto');
<ide> return;
<ide> }
<del>var tls = require('tls');
<del>var fs = require('fs');
<add>const assert = require('assert');
<add>const tls = require('tls');
<add>const fs = require('fs');
<ide>
<del>var options = {
<add>const options = {
<ide> key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'),
<ide> cert: fs.readFileSync(common.fixturesDir + '/keys/agent2-cert.pem')
<ide> }; | 1 |
Javascript | Javascript | fix race condition in test-worker-process-cwd.js | 195239a5f697214a86ca8b8eeefa1947ce409385 | <ide><path>test/parallel/test-worker-process-cwd.js
<ide> const common = require('../common');
<ide> const assert = require('assert');
<ide> const { Worker, isMainThread, parentPort } = require('worker_threads');
<ide>
<add>// Verify that cwd changes from the main thread are handled correctly in
<add>// workers.
<add>
<ide> // Do not use isMainThread directly, otherwise the test would time out in case
<ide> // it's started inside of another worker thread.
<ide> if (!process.env.HAS_STARTED_WORKER) {
<ide> process.env.HAS_STARTED_WORKER = '1';
<ide> if (!isMainThread) {
<ide> common.skip('This test can only run as main thread');
<ide> }
<add> // Normalize the current working dir to also work with the root folder.
<ide> process.chdir(__dirname);
<add>
<add> assert(!process.cwd.toString().includes('Atomics.load'));
<add>
<add> // 1. Start the first worker.
<ide> const w = new Worker(__filename);
<del> process.chdir('..');
<del> w.on('message', common.mustCall((message) => {
<add> w.once('message', common.mustCall((message) => {
<add> // 5. Change the cwd and send that to the spawned worker.
<ide> assert.strictEqual(message, process.cwd());
<ide> process.chdir('..');
<ide> w.postMessage(process.cwd());
<ide> }));
<ide> } else if (!process.env.SECOND_WORKER) {
<ide> process.env.SECOND_WORKER = '1';
<del> const firstCwd = process.cwd();
<add>
<add> // 2. Save the current cwd and verify that `process.cwd` includes the
<add> // Atomics.load call and spawn a new worker.
<add> const cwd = process.cwd();
<add> assert(process.cwd.toString().includes('Atomics.load'));
<add>
<ide> const w = new Worker(__filename);
<del> w.on('message', common.mustCall((message) => {
<del> assert.strictEqual(message, process.cwd());
<del> parentPort.postMessage(firstCwd);
<del> parentPort.onmessage = common.mustCall((obj) => {
<del> const secondCwd = process.cwd();
<del> assert.strictEqual(secondCwd, obj.data);
<del> assert.notStrictEqual(secondCwd, firstCwd);
<del> w.postMessage(secondCwd);
<del> parentPort.unref();
<del> });
<add> w.once('message', common.mustCall((message) => {
<add> // 4. Verify at the current cwd is identical to the received and the
<add> // original one.
<add> assert.strictEqual(process.cwd(), message);
<add> assert.strictEqual(message, cwd);
<add> parentPort.postMessage(cwd);
<add> }));
<add>
<add> parentPort.once('message', common.mustCall((message) => {
<add> // 6. Verify that the current cwd is identical to the received one but not
<add> // with the original one.
<add> assert.strictEqual(process.cwd(), message);
<add> assert.notStrictEqual(message, cwd);
<add> w.postMessage(message);
<ide> }));
<ide> } else {
<del> const firstCwd = process.cwd();
<del> parentPort.postMessage(firstCwd);
<del> parentPort.onmessage = common.mustCall((obj) => {
<del> const secondCwd = process.cwd();
<del> assert.strictEqual(secondCwd, obj.data);
<del> assert.notStrictEqual(secondCwd, firstCwd);
<del> process.exit();
<del> });
<add> // 3. Save the current cwd, post back to the "main" thread and verify that
<add> // `process.cwd` includes the Atomics.load call.
<add> const cwd = process.cwd();
<add> // Send the current cwd to the parent.
<add> parentPort.postMessage(cwd);
<add> assert(process.cwd.toString().includes('Atomics.load'));
<add>
<add> parentPort.once('message', common.mustCall((message) => {
<add> // 7. Verify that the current cwd is identical to the received one but
<add> // not with the original one.
<add> assert.strictEqual(process.cwd(), message);
<add> assert.notStrictEqual(message, cwd);
<add> }));
<ide> } | 1 |
Text | Text | add an image and caption to the article | aeb84198d07743e62315828ba639184d9cadab1f | <ide><path>guide/english/mathematics/prime-numbers/index.md
<ide> Examples:
<ide>
<ide> The first ten prime numbers are: 2, 3, 5, 7, 11, 13, 17, 19, 23, and 29.
<ide>
<add>
<add>
<add>**This is a chart with the first 100 natural numbers, indicating which are prime and which are composite.**
<add>
<ide> <!-- The article goes here, in GitHub-flavored Markdown. Feel free to add YouTube videos, images, and CodePen/JSBin embeds -->
<ide>
<ide> <!-- Please add any articles you think might be helpful to read before writing the article --> | 1 |
Javascript | Javascript | fix reactdomselection for ie 11 | 18bf0b80bc701fe0b9fb9216ce907baf4fb035ec | <ide><path>src/core/ReactDOMSelection.js
<ide> function setModernOffsets(node, offsets) {
<ide> var length = node[getTextContentAccessor()].length;
<ide> var start = Math.min(offsets.start, length);
<ide> var end = typeof offsets.end === 'undefined' ?
<del> start : Math.min(offsets.end, length);
<add> start : Math.min(offsets.end, length);
<add>
<add> // IE 11 uses modern selection, but doesn't support the extend method.
<add> // Flip backward selections, so we can set with a single range.
<add> if (!selection.extend && start > end) {
<add> var temp = end;
<add> end = start;
<add> start = temp;
<add> }
<ide>
<ide> var startMarker = getNodeForCharacterOffset(node, start);
<ide> var endMarker = getNodeForCharacterOffset(node, end);
<ide> function setModernOffsets(node, offsets) {
<ide> var range = document.createRange();
<ide> range.setStart(startMarker.node, startMarker.offset);
<ide> selection.removeAllRanges();
<del> selection.addRange(range);
<del> selection.extend(endMarker.node, endMarker.offset);
<add>
<add> if (start > end) {
<add> selection.addRange(range);
<add> selection.extend(endMarker.node, endMarker.offset);
<add> } else {
<add> range.setEnd(endMarker.node, endMarker.offset);
<add> selection.addRange(range);
<add> }
<add>
<ide> range.detach();
<ide> }
<ide> } | 1 |
Javascript | Javascript | enable es7 spread transform when using --harmony | 9f4ae415e2bd61e0d168f236c5be911f96f8696b | <ide><path>vendor/fbtransform/visitors.js
<ide> var es6ObjectConciseMethod = require('jstransform/visitors/es6-object-concise-me
<ide> var es6ObjectShortNotation = require('jstransform/visitors/es6-object-short-notation-visitors');
<ide> var es6RestParameters = require('jstransform/visitors/es6-rest-param-visitors');
<ide> var es6Templates = require('jstransform/visitors/es6-template-visitors');
<add>var es7SpreadProperty = require('jstransform/visitors/es7-spread-property-visitors');
<ide> var react = require('./transforms/react');
<ide> var reactDisplayName = require('./transforms/reactDisplayName');
<ide>
<ide> var transformVisitors = {
<ide> 'es6-object-short-notation': es6ObjectShortNotation.visitorList,
<ide> 'es6-rest-params': es6RestParameters.visitorList,
<ide> 'es6-templates': es6Templates.visitorList,
<add> 'es7-spread-property': es7SpreadProperty.visitorList,
<ide> 'react': react.visitorList.concat(reactDisplayName.visitorList)
<ide> };
<ide>
<ide> var transformRunOrder = [
<ide> 'es6-rest-params',
<ide> 'es6-templates',
<ide> 'es6-destructuring',
<add> 'es7-spread-property',
<ide> 'react'
<ide> ];
<ide> | 1 |
Javascript | Javascript | consider opacity when alpha testing | 1b4a6e76cac28743bd3d766f12bc9d594edf5f31 | <ide><path>src/renderers/webgl/WebGLSpriteRenderer.js
<ide> function WebGLSpriteRenderer( renderer, gl, state, textures, capabilities ) {
<ide>
<ide> 'vec4 texture = texture2D( map, vUV );',
<ide>
<del> 'if ( texture.a < alphaTest ) discard;',
<del>
<ide> 'gl_FragColor = vec4( color * texture.xyz, texture.a * opacity );',
<ide>
<add> 'if ( gl_FragColor.a < alphaTest ) discard;',
<add>
<ide> 'if ( fogType > 0 ) {',
<ide>
<ide> 'float fogFactor = 0.0;', | 1 |
Java | Java | fix retry with predicate ignoring backpressure | d000c1035b5a4134b12c7ef5198aa8487451e54e | <ide><path>src/main/java/rx/Observable.java
<ide> public final Observable<T> retry(final long count) {
<ide> * <p>
<ide> * <img width="640" height="315" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/retry.png" alt="">
<ide> * <dl>
<add> * <dt><b>Backpressure Support:</b></dt>
<add> * <dd>This operator honors backpressure.</td>
<ide> * <dt><b>Scheduler:</b></dt>
<ide> * <dd>{@code retry} operates by default on the {@code trampoline} {@link Scheduler}.</dd>
<ide> * </dl>
<ide><path>src/main/java/rx/internal/operators/OperatorRetryWithPredicate.java
<ide> package rx.internal.operators;
<ide>
<ide> import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
<add>
<ide> import rx.Observable;
<add>import rx.Producer;
<ide> import rx.Scheduler;
<ide> import rx.Subscriber;
<ide> import rx.functions.Action0;
<ide> import rx.functions.Func2;
<add>import rx.internal.producers.ProducerArbiter;
<ide> import rx.schedulers.Schedulers;
<ide> import rx.subscriptions.SerialSubscription;
<ide>
<ide> public Subscriber<? super Observable<T>> call(final Subscriber<? super T> child)
<ide> final SerialSubscription serialSubscription = new SerialSubscription();
<ide> // add serialSubscription so it gets unsubscribed if child is unsubscribed
<ide> child.add(serialSubscription);
<del>
<del> return new SourceSubscriber<T>(child, predicate, inner, serialSubscription);
<add> ProducerArbiter pa = new ProducerArbiter();
<add> child.setProducer(pa);
<add> return new SourceSubscriber<T>(child, predicate, inner, serialSubscription, pa);
<ide> }
<ide>
<ide> static final class SourceSubscriber<T> extends Subscriber<Observable<T>> {
<ide> final Subscriber<? super T> child;
<ide> final Func2<Integer, Throwable, Boolean> predicate;
<ide> final Scheduler.Worker inner;
<ide> final SerialSubscription serialSubscription;
<add> final ProducerArbiter pa;
<ide>
<ide> volatile int attempts;
<ide> @SuppressWarnings("rawtypes")
<ide> static final AtomicIntegerFieldUpdater<SourceSubscriber> ATTEMPTS_UPDATER
<ide> = AtomicIntegerFieldUpdater.newUpdater(SourceSubscriber.class, "attempts");
<ide>
<del> public SourceSubscriber(Subscriber<? super T> child, final Func2<Integer, Throwable, Boolean> predicate, Scheduler.Worker inner,
<del> SerialSubscription serialSubscription) {
<add> public SourceSubscriber(Subscriber<? super T> child,
<add> final Func2<Integer, Throwable, Boolean> predicate,
<add> Scheduler.Worker inner,
<add> SerialSubscription serialSubscription,
<add> ProducerArbiter pa) {
<ide> this.child = child;
<ide> this.predicate = predicate;
<ide> this.inner = inner;
<ide> this.serialSubscription = serialSubscription;
<add> this.pa = pa;
<ide> }
<ide>
<ide>
<ide> @Override
<del> public void onCompleted() {
<del> // ignore as we expect a single nested Observable<T>
<del> }
<add> public void onCompleted() {
<add> // ignore as we expect a single nested Observable<T>
<add> }
<ide>
<del> @Override
<del> public void onError(Throwable e) {
<del> child.onError(e);
<del> }
<add> @Override
<add> public void onError(Throwable e) {
<add> child.onError(e);
<add> }
<ide>
<del> @Override
<del> public void onNext(final Observable<T> o) {
<del> inner.schedule(new Action0() {
<add> @Override
<add> public void onNext(final Observable<T> o) {
<add> inner.schedule(new Action0() {
<ide>
<del> @Override
<del> public void call() {
<del> final Action0 _self = this;
<del> ATTEMPTS_UPDATER.incrementAndGet(SourceSubscriber.this);
<add> @Override
<add> public void call() {
<add> final Action0 _self = this;
<add> ATTEMPTS_UPDATER.incrementAndGet(SourceSubscriber.this);
<ide>
<del> // new subscription each time so if it unsubscribes itself it does not prevent retries
<del> // by unsubscribing the child subscription
<del> Subscriber<T> subscriber = new Subscriber<T>() {
<del> boolean done;
<del> @Override
<del> public void onCompleted() {
<del> if (!done) {
<del> done = true;
<del> child.onCompleted();
<del> }
<add> // new subscription each time so if it unsubscribes itself it does not prevent retries
<add> // by unsubscribing the child subscription
<add> Subscriber<T> subscriber = new Subscriber<T>() {
<add> boolean done;
<add> @Override
<add> public void onCompleted() {
<add> if (!done) {
<add> done = true;
<add> child.onCompleted();
<ide> }
<add> }
<ide>
<del> @Override
<del> public void onError(Throwable e) {
<del> if (!done) {
<del> done = true;
<del> if (predicate.call(attempts, e) && !inner.isUnsubscribed()) {
<del> // retry again
<del> inner.schedule(_self);
<del> } else {
<del> // give up and pass the failure
<del> child.onError(e);
<del> }
<add> @Override
<add> public void onError(Throwable e) {
<add> if (!done) {
<add> done = true;
<add> if (predicate.call(attempts, e) && !inner.isUnsubscribed()) {
<add> // retry again
<add> inner.schedule(_self);
<add> } else {
<add> // give up and pass the failure
<add> child.onError(e);
<ide> }
<ide> }
<add> }
<ide>
<del> @Override
<del> public void onNext(T v) {
<del> if (!done) {
<del> child.onNext(v);
<del> }
<add> @Override
<add> public void onNext(T v) {
<add> if (!done) {
<add> child.onNext(v);
<add> pa.produced(1);
<ide> }
<add> }
<ide>
<del> };
<del> // register this Subscription (and unsubscribe previous if exists)
<del> serialSubscription.set(subscriber);
<del> o.unsafeSubscribe(subscriber);
<del> }
<del> });
<del> }
<add> @Override
<add> public void setProducer(Producer p) {
<add> pa.setProducer(p);
<add> }
<add> };
<add> // register this Subscription (and unsubscribe previous if exists)
<add> serialSubscription.set(subscriber);
<add> o.unsafeSubscribe(subscriber);
<add> }
<add> });
<add> }
<ide> }
<ide> }
<ide><path>src/test/java/rx/internal/operators/OperatorRetryWithPredicateTest.java
<ide> import static org.mockito.Mockito.*;
<ide>
<ide> import java.io.IOException;
<add>import java.util.ArrayList;
<ide> import java.util.Arrays;
<ide> import java.util.Collections;
<ide> import java.util.List;
<ide> import java.util.concurrent.CopyOnWriteArrayList;
<ide> import java.util.concurrent.TimeUnit;
<del>import java.util.concurrent.atomic.*;
<add>import java.util.concurrent.atomic.AtomicBoolean;
<add>import java.util.concurrent.atomic.AtomicInteger;
<ide>
<ide> import org.junit.Test;
<ide> import org.mockito.InOrder;
<ide>
<del>import rx.*;
<add>import rx.Observable;
<ide> import rx.Observable.OnSubscribe;
<add>import rx.Observer;
<add>import rx.Subscriber;
<add>import rx.Subscription;
<ide> import rx.exceptions.TestException;
<del>import rx.functions.*;
<add>import rx.functions.Action1;
<add>import rx.functions.Func1;
<add>import rx.functions.Func2;
<ide> import rx.observers.TestSubscriber;
<ide> import rx.subjects.PublishSubject;
<ide>
<ide> public void call(Long t) {
<ide> }});
<ide> assertEquals(Arrays.asList(1L,1L,2L,3L), list);
<ide> }
<add> @Test
<add> public void testBackpressure() {
<add> final List<Long> requests = new ArrayList<Long>();
<add>
<add> Observable<Integer> source = Observable
<add> .just(1)
<add> .concatWith(Observable.<Integer>error(new TestException()))
<add> .doOnRequest(new Action1<Long>() {
<add> @Override
<add> public void call(Long t) {
<add> requests.add(t);
<add> }
<add> });
<add>
<add> TestSubscriber<Integer> ts = TestSubscriber.create(3);
<add> source
<add> .retry(new Func2<Integer, Throwable, Boolean>() {
<add> @Override
<add> public Boolean call(Integer t1, Throwable t2) {
<add> return t1 < 3;
<add> }
<add> }).subscribe(ts);
<add>
<add> assertEquals(Arrays.asList(3L, 2L, 1L), requests);
<add> ts.assertValues(1, 1, 1);
<add> ts.assertNotCompleted();
<add> ts.assertNoErrors();
<add> }
<ide> } | 3 |
PHP | PHP | fix brittle test | 76674b8074b8e69a84022522e5678e0940af8895 | <ide><path>tests/Database/DatabaseEloquentRelationTest.php
<ide> public function testTouchMethodUpdatesRelatedTimestamps()
<ide> $relation = new HasOne($builder, $parent, 'foreign_key', 'id');
<ide> $related->shouldReceive('getTable')->andReturn('table');
<ide> $related->shouldReceive('getUpdatedAtColumn')->andReturn('updated_at');
<del> $related->shouldReceive('freshTimestampString')->andReturn(Carbon\Carbon::now());
<del> $builder->shouldReceive('update')->once()->with(['updated_at' => Carbon\Carbon::now()]);
<add> $now = Carbon\Carbon::now();
<add> $related->shouldReceive('freshTimestampString')->andReturn($now);
<add> $builder->shouldReceive('update')->once()->with(['updated_at' => $now]);
<ide>
<ide> $relation->touch();
<ide> } | 1 |
Ruby | Ruby | remove unused try require | 73e46ac1363d376f0bf745f85e91439ae09da815 | <ide><path>activesupport/lib/active_support/values/time_zone.rb
<ide> require 'tzinfo'
<ide> require 'concurrent/map'
<ide> require 'active_support/core_ext/object/blank'
<del>require 'active_support/core_ext/object/try'
<ide>
<ide> module ActiveSupport
<ide> # The TimeZone class serves as a wrapper around TZInfo::Timezone instances. | 1 |
Javascript | Javascript | introduce engine_parent symbol | aa79ca71fe04776e1c9f4220f49bf35faf38743a | <ide><path>packages/ember-application/lib/system/engine-parent.js
<add>/**
<add>@module ember
<add>@submodule ember-application
<add>*/
<add>
<add>import symbol from 'ember-metal/symbol';
<add>
<add>export const ENGINE_PARENT = symbol('ENGINE_PARENT');
<add>
<add>/**
<add> `getEngineParent` retrieves an engine instance's parent instance.
<add>
<add> @method getEngineParent
<add> @param {EngineInstance} engine An engine instance.
<add> @return {EngineInstance} The parent engine instance.
<add> @for Ember
<add> @public
<add>*/
<add>export function getEngineParent(engine) {
<add> return engine[ENGINE_PARENT];
<add>}
<add>
<add>/**
<add> `setEngineParent` sets an engine instance's parent instance.
<add>
<add> @method setEngineParent
<add> @param {EngineInstance} engine An engine instance.
<add> @param {EngineInstance} parent The parent engine instance.
<add> @private
<add>*/
<add>export function setEngineParent(engine, parent) {
<add> engine[ENGINE_PARENT] = parent;
<add>}
<ide><path>packages/ember-application/tests/system/engine_parent_test.js
<add>import { getEngineParent, setEngineParent, ENGINE_PARENT } from 'ember-application/system/engine-parent';
<add>
<add>QUnit.module('EngineParent', {});
<add>
<add>QUnit.test('An engine\'s parent can be set with `setEngineParent` and retrieved with `getEngineParent`', function() {
<add> let engine = {};
<add> let parent = {};
<add>
<add> strictEqual(getEngineParent(engine), undefined, 'parent has not been set');
<add>
<add> setEngineParent(engine, parent);
<add>
<add> strictEqual(getEngineParent(engine), parent, 'parent has been set');
<add>
<add> strictEqual(engine[ENGINE_PARENT], parent, 'parent has been set to the ENGINE_PARENT symbol');
<add>}); | 2 |
Javascript | Javascript | cover stdout/stderr usage in triggerreport() | 86aed6d332f196b57395c345c3d30a70be8bafad | <ide><path>test/report/test-report-triggerreport.js
<ide> const common = require('../common');
<ide> common.skipIfReportDisabled();
<ide> const assert = require('assert');
<add>const { spawnSync } = require('child_process');
<ide> const fs = require('fs');
<ide> const path = require('path');
<ide> const helper = require('../common/report');
<ide> function validate() {
<ide> process.report.triggerReport('file', error);
<ide> }, { code: 'ERR_INVALID_ARG_TYPE' });
<ide> });
<add>
<add>{
<add> // Test the special "stdout" filename.
<add> const args = ['--experimental-report', '-e',
<add> 'process.report.triggerReport("stdout")'];
<add> const child = spawnSync(process.execPath, args, { cwd: tmpdir.path });
<add> assert.strictEqual(child.status, 0);
<add> assert.strictEqual(child.signal, null);
<add> assert.strictEqual(helper.findReports(child.pid, tmpdir.path).length, 0);
<add> helper.validateContent(child.stdout.toString());
<add>}
<add>
<add>{
<add> // Test the special "stderr" filename.
<add> const args = ['--experimental-report', '-e',
<add> 'process.report.triggerReport("stderr")'];
<add> const child = spawnSync(process.execPath, args, { cwd: tmpdir.path });
<add> assert.strictEqual(child.status, 0);
<add> assert.strictEqual(child.signal, null);
<add> assert.strictEqual(child.stdout.toString().trim(), '');
<add> assert.strictEqual(helper.findReports(child.pid, tmpdir.path).length, 0);
<add> const report = child.stderr.toString().split('Node.js report completed')[0];
<add> helper.validateContent(report);
<add>} | 1 |
Go | Go | adjust overlay driver for netlink api change | 00456020f5c39e5f9ce77b5ba5eabddcc0981b3d | <ide><path>libnetwork/drivers/overlay/ov_network.go
<ide> func (n *network) initSandbox() error {
<ide>
<ide> func (n *network) watchMiss(nlSock *nl.NetlinkSocket) {
<ide> for {
<del> msgs, err := nlSock.Recieve()
<add> msgs, err := nlSock.Receive()
<ide> if err != nil {
<ide> logrus.Errorf("Failed to receive from netlink: %v ", err)
<ide> continue | 1 |
PHP | PHP | apply fixes from styleci | 1d8a3d59055b7f21bc4d13d7d40eed914b716ebc | <ide><path>tests/Integration/Database/EloquentMorphManyTest.php
<ide> public function comments()
<ide> }
<ide> }
<ide>
<del>
<ide> class Comment extends Model
<ide> {
<ide> public $table = 'comments'; | 1 |
PHP | PHP | remove spaces from declare | 7827d916ea4d9507640ede47e8c4bd9923f88491 | <ide><path>src/Auth/AbstractPasswordHasher.php
<ide> <?php
<del>declare(strict_types = 1);
<add>declare(strict_types=1);
<ide> /**
<ide> * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
<ide> * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
<ide><path>src/Auth/BaseAuthenticate.php
<ide> <?php
<del>declare(strict_types = 1);
<add>declare(strict_types=1);
<ide> /**
<ide> * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
<ide> * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
<ide><path>src/Auth/BaseAuthorize.php
<ide> <?php
<del>declare(strict_types = 1);
<add>declare(strict_types=1);
<ide> /**
<ide> * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
<ide> * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
<ide><path>src/Auth/BasicAuthenticate.php
<ide> <?php
<del>declare(strict_types = 1);
<add>declare(strict_types=1);
<ide> /**
<ide> * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
<ide> * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
<ide><path>src/Auth/ControllerAuthorize.php
<ide> <?php
<del>declare(strict_types = 1);
<add>declare(strict_types=1);
<ide> /**
<ide> * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
<ide> * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
<ide><path>src/Auth/DefaultPasswordHasher.php
<ide> <?php
<del>declare(strict_types = 1);
<add>declare(strict_types=1);
<ide> /**
<ide> * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
<ide> * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
<ide><path>src/Auth/DigestAuthenticate.php
<ide> <?php
<del>declare(strict_types = 1);
<add>declare(strict_types=1);
<ide> /**
<ide> * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
<ide> * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
<ide><path>src/Auth/FallbackPasswordHasher.php
<ide> <?php
<del>declare(strict_types = 1);
<add>declare(strict_types=1);
<ide> /**
<ide> * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
<ide> * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
<ide><path>src/Auth/FormAuthenticate.php
<ide> <?php
<del>declare(strict_types = 1);
<add>declare(strict_types=1);
<ide> /**
<ide> *
<ide> * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
<ide><path>src/Auth/PasswordHasherFactory.php
<ide> <?php
<del>declare(strict_types = 1);
<add>declare(strict_types=1);
<ide> /**
<ide> * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
<ide> * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
<ide><path>src/Auth/Storage/MemoryStorage.php
<ide> <?php
<del>declare(strict_types = 1);
<add>declare(strict_types=1);
<ide> /**
<ide> * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
<ide> * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
<ide><path>src/Auth/Storage/SessionStorage.php
<ide> <?php
<del>declare(strict_types = 1);
<add>declare(strict_types=1);
<ide> /**
<ide> * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
<ide> * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
<ide><path>src/Auth/Storage/StorageInterface.php
<ide> <?php
<del>declare(strict_types = 1);
<add>declare(strict_types=1);
<ide> /**
<ide> * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
<ide> * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
<ide><path>src/Auth/WeakPasswordHasher.php
<ide> <?php
<del>declare(strict_types = 1);
<add>declare(strict_types=1);
<ide> /**
<ide> * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
<ide> * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
<ide><path>tests/TestCase/Auth/BasicAuthenticateTest.php
<ide> <?php
<del>declare(strict_types = 1);
<add>declare(strict_types=1);
<ide> /**
<ide> * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
<ide> * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
<ide><path>tests/TestCase/Auth/ControllerAuthorizeTest.php
<ide> <?php
<del>declare(strict_types = 1);
<add>declare(strict_types=1);
<ide> /**
<ide> * ControllerAuthorizeTest file
<ide> *
<ide><path>tests/TestCase/Auth/DefaultPasswordHasherTest.php
<ide> <?php
<del>declare(strict_types = 1);
<add>declare(strict_types=1);
<ide> /**
<ide> * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
<ide> * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
<ide><path>tests/TestCase/Auth/DigestAuthenticateTest.php
<ide> <?php
<del>declare(strict_types = 1);
<add>declare(strict_types=1);
<ide> /**
<ide> * DigestAuthenticateTest file
<ide> *
<ide><path>tests/TestCase/Auth/FallbackPasswordHasherTest.php
<ide> <?php
<del>declare(strict_types = 1);
<add>declare(strict_types=1);
<ide> /**
<ide> * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
<ide> * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
<ide><path>tests/TestCase/Auth/FormAuthenticateTest.php
<ide> <?php
<del>declare(strict_types = 1);
<add>declare(strict_types=1);
<ide> /**
<ide> * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
<ide> * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
<ide><path>tests/TestCase/Auth/PasswordHasherFactoryTest.php
<ide> <?php
<del>declare(strict_types = 1);
<add>declare(strict_types=1);
<ide> /**
<ide> * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
<ide> * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
<ide><path>tests/TestCase/Auth/Storage/MemoryStorageTest.php
<ide> <?php
<del>declare(strict_types = 1);
<add>declare(strict_types=1);
<ide> /**
<ide> * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
<ide> * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
<ide><path>tests/TestCase/Auth/Storage/SessionStorageTest.php
<ide> <?php
<del>declare(strict_types = 1);
<add>declare(strict_types=1);
<ide> /**
<ide> * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
<ide> * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
<ide><path>tests/TestCase/Auth/WeakPasswordHasherTest.php
<ide> <?php
<del>declare(strict_types = 1);
<add>declare(strict_types=1);
<ide> /**
<ide> * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
<ide> * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org) | 24 |
PHP | PHP | remove the mutator methods | 886d8693c4085f6e70289ed9add4c99c8bba4637 | <ide><path>src/Error/Debugger.php
<ide> public function outputError(array $data): void
<ide>
<ide> $outputFormat = $this->_outputFormat;
<ide> if (isset($this->renderers[$outputFormat])) {
<add> /** @var array $trace */
<ide> $trace = static::trace(['start' => $data['start'], 'format' => 'points']);
<ide> $error = new PhpError($data['code'], $data['description'], $data['file'], $data['line'], $trace);
<ide> $renderer = new $this->renderers[$outputFormat]();
<ide><path>src/Error/ErrorTrap.php
<ide> class ErrorTrap
<ide> */
<ide> protected $callbacks = [];
<ide>
<del> /**
<del> * Whether or not this error trap has been registered
<del> * as the default error handler. Even when true, this
<del> * error handler may no longer be the active error handler.
<del> *
<del> * @var bool
<del> */
<del> protected $registered = false;
<del>
<ide> /**
<ide> * Constructor
<ide> *
<ide> class ErrorTrap
<ide> public function __construct(array $options = [])
<ide> {
<ide> $this->setConfig($options);
<del> $this->setErrorRenderer($this->chooseErrorRenderer());
<del> $this->setLoggerClass($this->_getConfig('logger'));
<del> $this->setLevel($this->_getConfig('errorLevel'));
<add> if ($this->_getConfig('errorRenderer') === null) {
<add> $this->setConfig('errorRenderer', $this->chooseErrorRenderer());
<add> }
<ide> }
<ide>
<ide> /**
<ide> protected function chooseErrorRenderer(): string
<ide> */
<ide> public function register(): void
<ide> {
<del> $this->registered = true;
<del>
<ide> $level = $this->_config['errorLevel'] ?? -1;
<ide> error_reporting($level);
<ide> set_error_handler([$this, 'handleError'], $level);
<ide> public function handleError(
<ide> return false;
<ide> }
<ide> $debug = Configure::read('debug');
<add> /** @var array $trace */
<ide> $trace = Debugger::trace(['start' => 1, 'format' => 'points']);
<ide> $error = new PhpError($code, $description, $file, $line, $trace);
<ide>
<ide> public function handleError(
<ide> public function renderer(): ErrorRendererInterface
<ide> {
<ide> $class = $this->_getConfig('errorRenderer');
<add> if (!$class) {
<add> $class = $this->chooseErrorRenderer();
<add> }
<add> if (!in_array(ErrorRendererInterface::class, class_implements($class))) {
<add> throw new InvalidArgumentException(
<add> "Cannot use {$class} as an error renderer. It must implement \Cake\Error\ErrorRendererInterface."
<add> );
<add> }
<ide>
<ide> /** @var \Cake\Error\ErrorRendererInterface $instance */
<ide> $instance = new $class($this->_config);
<ide> public function renderer(): ErrorRendererInterface
<ide> public function logger(): ErrorLoggerInterface
<ide> {
<ide> $class = $this->_getConfig('logger');
<del>
<del> /** @var \Cake\Error\ErrorLoggerInterface $instance */
<del> $instance = new $class($this->_config);
<del>
<del> return $instance;
<del> }
<del>
<del> /**
<del> * Change the error renderer
<del> *
<del> * @param class-string<\Cake\Error\ErrorRendererInterface> $class The class to use as a renderer.
<del> * @return $this
<del> */
<del> public function setErrorRenderer(string $class)
<del> {
<del> if (!in_array(ErrorRendererInterface::class, class_implements($class))) {
<del> throw new InvalidArgumentException(
<del> "Cannot use {$class} as an error renderer. It must implement \Cake\Error\ErrorRendererInterface."
<del> );
<add> if (!$class) {
<add> $class = $this->_defaultConfig['logger'];
<ide> }
<del> $this->setConfig('errorRenderer', $class);
<del>
<del> return $this;
<del> }
<del>
<del> /**
<del> * Set the PHP error reporting level
<del> *
<del> * @param int $level The PHP error reporting value to use.
<del> * @return $this
<del> */
<del> public function setLevel(int $level)
<del> {
<del> if ($this->registered) {
<del> throw new LogicException('Cannot change level after an ErrorTrap has been registered.');
<del> }
<del> $this->setConfig('level', $level);
<del>
<del> return $this;
<del> }
<del>
<del> /**
<del> * Set the Error logging implementation
<del> *
<del> * When the logger is constructed it will be passed
<del> * the current options array.
<del> *
<del> * @param class-string<\Cake\Error\ErrorLoggerInterface> $class The logging class to use.
<del> * @return $this
<del> */
<del> public function setLoggerClass(string $class)
<del> {
<ide> if (!in_array(ErrorLoggerInterface::class, class_implements($class))) {
<ide> throw new InvalidArgumentException(
<ide> "Cannot use {$class} as an error renderer. It must implement \Cake\Error\ErrorLoggerInterface."
<ide> );
<ide> }
<del> $this->setConfig('logger', $class);
<ide>
<del> return $this;
<add> /** @var \Cake\Error\ErrorLoggerInterface $instance */
<add> $instance = new $class($this->_config);
<add>
<add> return $instance;
<ide> }
<ide>
<ide> /**
<ide><path>tests/TestCase/Error/ErrorTrapTest.php
<ide> public function setUp(): void
<ide> Log::drop('test_error');
<ide> }
<ide>
<del> public function testSetErrorRendererInvalid()
<add> public function testConfigRendererInvalid()
<ide> {
<del> $trap = new ErrorTrap();
<add> $trap = new ErrorTrap(['errorRenderer' => stdClass::class]);
<ide> $this->expectException(InvalidArgumentException::class);
<del> $trap->setErrorRenderer(stdClass::class);
<add> $trap->renderer();
<ide> }
<ide>
<del> public function testErrorRendererFallback()
<add> public function testConfigErrorRendererFallback()
<ide> {
<ide> $trap = new ErrorTrap(['errorRenderer' => null]);
<ide> $this->assertInstanceOf(ConsoleRenderer::class, $trap->renderer());
<ide> }
<ide>
<del> public function testSetErrorRenderer()
<add> public function testConfigErrorRenderer()
<ide> {
<del> $trap = new ErrorTrap();
<del> $trap->setErrorRenderer(HtmlRenderer::class);
<add> $trap = new ErrorTrap(['errorRenderer' => HtmlRenderer::class]);
<ide> $this->assertInstanceOf(HtmlRenderer::class, $trap->renderer());
<ide> }
<ide>
<del> public function testSetLoggerClassInvalid()
<add> public function testConfigRendererHandleUnsafeOverwrite()
<ide> {
<ide> $trap = new ErrorTrap();
<add> $trap->setConfig('errorRenderer', null);
<add> $this->assertInstanceOf(ConsoleRenderer::class, $trap->renderer());
<add> }
<add>
<add> public function testLoggerConfigInvalid()
<add> {
<add> $trap = new ErrorTrap(['logger' => stdClass::class]);
<ide> $this->expectException(InvalidArgumentException::class);
<del> $trap->setLoggerClass(stdClass::class);
<add> $trap->logger();
<ide> }
<ide>
<del> public function testSetLoggerClass()
<add> public function testLoggerConfig()
<add> {
<add> $trap = new ErrorTrap(['logger' => ErrorLogger::class]);
<add> $this->assertInstanceOf(ErrorLogger::class, $trap->logger());
<add> }
<add>
<add> public function testLoggerHandleUnsafeOverwrite()
<ide> {
<ide> $trap = new ErrorTrap();
<del> $trap->setLoggerClass(ErrorLogger::class);
<add> $trap->setConfig('logger', null);
<ide> $this->assertInstanceOf(ErrorLogger::class, $trap->logger());
<ide> }
<ide>
<ide> public function testRegisterAndRendering()
<ide> {
<del> $trap = new ErrorTrap();
<del> $trap->setErrorRenderer(TextRenderer::class);
<add> $trap = new ErrorTrap(['errorRenderer' => TextRenderer::class]);
<ide> $trap->register();
<ide> ob_start();
<ide> trigger_error('Oh no it was bad', E_USER_NOTICE);
<ide> public function testRegisterAndLogging()
<ide> Log::setConfig('test_error', [
<ide> 'className' => 'Array',
<ide> ]);
<del> $trap = new ErrorTrap();
<add> $trap = new ErrorTrap([
<add> 'errorRenderer' => TextRenderer::class,
<add> ]);
<ide> $trap->register();
<del> $trap->setErrorRenderer(TextRenderer::class);
<ide>
<ide> ob_start();
<ide> trigger_error('Oh no it was bad', E_USER_NOTICE);
<ide> public function testRegisterNoOutputDebug()
<ide> 'className' => 'Array',
<ide> ]);
<ide> Configure::write('debug', false);
<del> $trap = new ErrorTrap();
<add> $trap = new ErrorTrap(['errorRenderer' => TextRenderer::class]);
<ide> $trap->register();
<del> $trap->setErrorRenderer(TextRenderer::class);
<ide>
<ide> ob_start();
<ide> trigger_error('Oh no it was bad', E_USER_NOTICE);
<ide> public function testRegisterNoOutputDebug()
<ide>
<ide> public function testAddCallback()
<ide> {
<del> $trap = new ErrorTrap();
<add> $trap = new ErrorTrap(['errorRenderer' => TextRenderer::class]);
<ide> $trap->register();
<del> $trap->setErrorRenderer(TextRenderer::class);
<ide> $trap->addCallback(function (PhpError $error) {
<ide> $this->assertEquals(E_USER_NOTICE, $error->getCode());
<ide> $this->assertStringContainsString('Oh no it was bad', $error->getMessage()); | 3 |
Ruby | Ruby | add optional post_install method to formula | 462a41887823bbf72996c2ce324c5db30f77e89a | <ide><path>Library/Homebrew/formula.rb
<ide> def cached_download
<ide> # are supported.
<ide> def pour_bottle?; true end
<ide>
<add> # Can be overridden to run commands on both source and bottle installation.
<add> def post_install; end
<add>
<ide> # tell the user about any caveats regarding this package, return a string
<ide> def caveats; nil end
<ide>
<ide><path>Library/Homebrew/formula_installer.rb
<ide> def install
<ide> clean
<ide> end
<ide>
<add> f.post_install
<add>
<ide> opoo "Nothing was installed to #{f.prefix}" unless f.installed?
<ide> end
<ide> | 2 |
Python | Python | raise error instead of returning | 042a3a7517cdea7c63152d7ae44d45518dce0589 | <ide><path>airflow/hooks/S3_hook.py
<ide> def load_file(self, filename,
<ide> :param bucket_name: Name of the bucket in which to store the file
<ide> :type bucket_name: str
<ide> :param replace: A flag to decide whether or not to overwrite the key
<del> if it already exists
<add> if it already exists. If replace is False and the key exists, an
<add> error will be raised.
<ide> :type replace: bool
<ide> """
<ide> if not bucket_name:
<ide> def load_file(self, filename,
<ide> key_obj = bucket.new_key(key_name=key)
<ide> else:
<ide> if not replace:
<del> logging.info("The key {key} already exists.".format(**locals()))
<del> return
<add> raise ValueError("The key {key} already exists.".format(
<add> **locals()))
<ide> key_obj = bucket.get_key(key)
<ide> key_size = key_obj.set_contents_from_filename(filename,
<ide> replace=replace) | 1 |
Javascript | Javascript | increase dgram ref()/unref() coverage | b471392f8c6eb8dff24439ded1e51ce6e6710157 | <ide><path>test/parallel/test-dgram-ref.js
<ide> 'use strict';
<del>require('../common');
<add>const common = require('../common');
<ide> const dgram = require('dgram');
<ide>
<ide> // should not hang, see #1282
<ide> dgram.createSocket('udp4');
<ide> dgram.createSocket('udp6');
<add>
<add>{
<add> // Test the case of ref()'ing a socket with no handle.
<add> const s = dgram.createSocket('udp4');
<add>
<add> s.close(common.mustCall(() => s.ref()));
<add>}
<ide><path>test/parallel/test-dgram-unref.js
<ide> const common = require('../common');
<ide> const dgram = require('dgram');
<ide>
<del>const s = dgram.createSocket('udp4');
<del>s.bind();
<del>s.unref();
<add>{
<add> // Test the case of unref()'ing a socket with a handle.
<add> const s = dgram.createSocket('udp4');
<add> s.bind();
<add> s.unref();
<add>}
<add>
<add>{
<add> // Test the case of unref()'ing a socket with no handle.
<add> const s = dgram.createSocket('udp4');
<add>
<add> s.close(common.mustCall(() => s.unref()));
<add>}
<ide>
<ide> setTimeout(common.mustNotCall(), 1000).unref(); | 2 |
Python | Python | correct a bug with docker module and server mode | 33ea6415dea509f52659f5bbf80c32701e5925f7 | <ide><path>glances/plugins/glances_docker.py
<ide> def update(self):
<ide> self.reset()
<ide>
<ide> # The Docker-py lib is mandatory
<del> if not docker_tag or self.args.disable_docker:
<add> if not docker_tag or (self.args is not None and self.args.disable_docker):
<ide> return self.stats
<ide>
<ide> if self.get_input() == 'local': | 1 |
Javascript | Javascript | fix plnkropener to use $oninit | 5b477614ff92dcdf5eff62e2143b7fb43aab5653 | <ide><path>docs/app/src/examples.js
<ide> angular.module('examples', [])
<ide>
<ide> };
<ide>
<del> // Initialize the example data, so it's ready when clicking the open button.
<del> // Otherwise pop-up blockers will prevent a new window from opening
<del> ctrl.prepareExampleData(ctrl.example.path);
<del>
<add> ctrl.$onInit = function() {
<add> // Initialize the example data, so it's ready when clicking the open button.
<add> // Otherwise pop-up blockers will prevent a new window from opening
<add> ctrl.prepareExampleData(ctrl.example.path);
<add> };
<ide> }]
<ide> };
<ide> }]) | 1 |
Go | Go | add a benchmark for logger.copier | af439c7a8da878450d0e5583935a1c4208fa92ad | <ide><path>daemon/logger/copier_test.go
<ide> package logger
<ide> import (
<ide> "bytes"
<ide> "encoding/json"
<add> "fmt"
<ide> "io"
<add> "os"
<ide> "sync"
<ide> "testing"
<ide> "time"
<ide> func TestCopierSlow(t *testing.T) {
<ide> case <-wait:
<ide> }
<ide> }
<add>
<add>type BenchmarkLoggerDummy struct {
<add>}
<add>
<add>func (l *BenchmarkLoggerDummy) Log(m *Message) error { return nil }
<add>
<add>func (l *BenchmarkLoggerDummy) Close() error { return nil }
<add>
<add>func (l *BenchmarkLoggerDummy) Name() string { return "dummy" }
<add>
<add>func BenchmarkCopier64(b *testing.B) {
<add> benchmarkCopier(b, 1<<6)
<add>}
<add>func BenchmarkCopier128(b *testing.B) {
<add> benchmarkCopier(b, 1<<7)
<add>}
<add>func BenchmarkCopier256(b *testing.B) {
<add> benchmarkCopier(b, 1<<8)
<add>}
<add>func BenchmarkCopier512(b *testing.B) {
<add> benchmarkCopier(b, 1<<9)
<add>}
<add>func BenchmarkCopier1K(b *testing.B) {
<add> benchmarkCopier(b, 1<<10)
<add>}
<add>func BenchmarkCopier2K(b *testing.B) {
<add> benchmarkCopier(b, 1<<11)
<add>}
<add>func BenchmarkCopier4K(b *testing.B) {
<add> benchmarkCopier(b, 1<<12)
<add>}
<add>func BenchmarkCopier8K(b *testing.B) {
<add> benchmarkCopier(b, 1<<13)
<add>}
<add>func BenchmarkCopier16K(b *testing.B) {
<add> benchmarkCopier(b, 1<<14)
<add>}
<add>func BenchmarkCopier32K(b *testing.B) {
<add> benchmarkCopier(b, 1<<15)
<add>}
<add>func BenchmarkCopier64K(b *testing.B) {
<add> benchmarkCopier(b, 1<<16)
<add>}
<add>func BenchmarkCopier128K(b *testing.B) {
<add> benchmarkCopier(b, 1<<17)
<add>}
<add>func BenchmarkCopier256K(b *testing.B) {
<add> benchmarkCopier(b, 1<<18)
<add>}
<add>
<add>func piped(b *testing.B, iterations int, delay time.Duration, buf []byte) io.Reader {
<add> r, w, err := os.Pipe()
<add> if err != nil {
<add> b.Fatal(err)
<add> return nil
<add> }
<add> go func() {
<add> for i := 0; i < iterations; i++ {
<add> time.Sleep(delay)
<add> if n, err := w.Write(buf); err != nil || n != len(buf) {
<add> if err != nil {
<add> b.Fatal(err)
<add> }
<add> b.Fatal(fmt.Errorf("short write"))
<add> }
<add> }
<add> w.Close()
<add> }()
<add> return r
<add>}
<add>
<add>func benchmarkCopier(b *testing.B, length int) {
<add> b.StopTimer()
<add> buf := []byte{'A'}
<add> for len(buf) < length {
<add> buf = append(buf, buf...)
<add> }
<add> buf = append(buf[:length-1], []byte{'\n'}...)
<add> b.StartTimer()
<add> for i := 0; i < b.N; i++ {
<add> c := NewCopier(
<add> map[string]io.Reader{
<add> "buffer": piped(b, 10, time.Nanosecond, buf),
<add> },
<add> &BenchmarkLoggerDummy{})
<add> c.Run()
<add> c.Wait()
<add> c.Close()
<add> }
<add>} | 1 |
Ruby | Ruby | add argument serializer `timewithzoneserializer` | d2c094aa5081677bf537a1553d0a756fcafcfb4e | <ide><path>activejob/lib/active_job/serializers.rb
<ide> module Serializers
<ide> autoload :ObjectSerializer
<ide> autoload :SymbolSerializer
<ide> autoload :DurationSerializer
<add> autoload :DateTimeSerializer
<ide> autoload :DateSerializer
<add> autoload :TimeWithZoneSerializer
<ide> autoload :TimeSerializer
<del> autoload :DateTimeSerializer
<ide>
<ide> mattr_accessor :_additional_serializers
<ide> self._additional_serializers = Set.new
<ide> def add_serializers(*new_serializers)
<ide> DurationSerializer,
<ide> DateTimeSerializer,
<ide> DateSerializer,
<add> TimeWithZoneSerializer,
<ide> TimeSerializer
<ide> end
<ide> end
<ide><path>activejob/lib/active_job/serializers/time_with_zone_serializer.rb
<add># frozen_string_literal: true
<add>
<add>module ActiveJob
<add> module Serializers
<add> class TimeWithZoneSerializer < ObjectSerializer # :nodoc:
<add> def serialize(time)
<add> super("value" => time.iso8601)
<add> end
<add>
<add> def deserialize(hash)
<add> Time.iso8601(hash["value"]).in_time_zone
<add> end
<add>
<add> private
<add>
<add> def klass
<add> ActiveSupport::TimeWithZone
<add> end
<add> end
<add> end
<add>end
<ide><path>activejob/test/cases/argument_serialization_test.rb
<ide> class ArgumentSerializationTest < ActiveSupport::TestCase
<ide> assert_instance_of ActiveSupport::HashWithIndifferentAccess, perform_round_trip([indifferent_access]).first
<ide> end
<ide>
<add> test "should maintain time with zone" do
<add> Time.use_zone "Alaska" do
<add> time_with_zone = Time.new(2002, 10, 31, 2, 2, 2).in_time_zone
<add> assert_instance_of ActiveSupport::TimeWithZone, perform_round_trip([time_with_zone]).first
<add> assert_arguments_unchanged time_with_zone
<add> end
<add> end
<add>
<ide> test "should disallow non-string/symbol hash keys" do
<ide> assert_raises ActiveJob::SerializationError do
<ide> ActiveJob::Arguments.serialize [ { 1 => 2 } ] | 3 |
Python | Python | remove unneeded parentheses from python file | 317858ac76d9dc81a11bc6626eb949d231eb6f0a | <ide><path>airflow/cli/cli_parser.py
<ide> def positive_int(value):
<ide> "-o",
<ide> "--output",
<ide> ),
<del> help=("Output format. Allowed values: json, yaml, table (default: table)"),
<add> help="Output format. Allowed values: json, yaml, table (default: table)",
<ide> metavar="(table, json, yaml)",
<ide> choices=("table", "json", "yaml"),
<ide> default="table", | 1 |
Go | Go | address some linter warnings | acd0aa7d382cc3bb87d542adf6845bd14d57d53a | <ide><path>api/server/router/image/image.go
<ide> type imageRouter struct {
<ide>
<ide> // NewRouter initializes a new image router
<ide> func NewRouter(backend Backend, referenceBackend reference.Store, imageStore image.Store, layerStore layer.Store) router.Router {
<del> r := &imageRouter{
<add> ir := &imageRouter{
<ide> backend: backend,
<ide> referenceBackend: referenceBackend,
<ide> imageStore: imageStore,
<ide> layerStore: layerStore,
<ide> }
<del> r.initRoutes()
<del> return r
<add> ir.initRoutes()
<add> return ir
<ide> }
<ide>
<ide> // Routes returns the available routes to the image controller
<del>func (r *imageRouter) Routes() []router.Route {
<del> return r.routes
<add>func (ir *imageRouter) Routes() []router.Route {
<add> return ir.routes
<ide> }
<ide>
<ide> // initRoutes initializes the routes in the image router
<del>func (r *imageRouter) initRoutes() {
<del> r.routes = []router.Route{
<add>func (ir *imageRouter) initRoutes() {
<add> ir.routes = []router.Route{
<ide> // GET
<del> router.NewGetRoute("/images/json", r.getImagesJSON),
<del> router.NewGetRoute("/images/search", r.getImagesSearch),
<del> router.NewGetRoute("/images/get", r.getImagesGet),
<del> router.NewGetRoute("/images/{name:.*}/get", r.getImagesGet),
<del> router.NewGetRoute("/images/{name:.*}/history", r.getImagesHistory),
<del> router.NewGetRoute("/images/{name:.*}/json", r.getImagesByName),
<add> router.NewGetRoute("/images/json", ir.getImagesJSON),
<add> router.NewGetRoute("/images/search", ir.getImagesSearch),
<add> router.NewGetRoute("/images/get", ir.getImagesGet),
<add> router.NewGetRoute("/images/{name:.*}/get", ir.getImagesGet),
<add> router.NewGetRoute("/images/{name:.*}/history", ir.getImagesHistory),
<add> router.NewGetRoute("/images/{name:.*}/json", ir.getImagesByName),
<ide> // POST
<del> router.NewPostRoute("/images/load", r.postImagesLoad),
<del> router.NewPostRoute("/images/create", r.postImagesCreate),
<del> router.NewPostRoute("/images/{name:.*}/push", r.postImagesPush),
<del> router.NewPostRoute("/images/{name:.*}/tag", r.postImagesTag),
<del> router.NewPostRoute("/images/prune", r.postImagesPrune),
<add> router.NewPostRoute("/images/load", ir.postImagesLoad),
<add> router.NewPostRoute("/images/create", ir.postImagesCreate),
<add> router.NewPostRoute("/images/{name:.*}/push", ir.postImagesPush),
<add> router.NewPostRoute("/images/{name:.*}/tag", ir.postImagesTag),
<add> router.NewPostRoute("/images/prune", ir.postImagesPrune),
<ide> // DELETE
<del> router.NewDeleteRoute("/images/{name:.*}", r.deleteImages),
<add> router.NewDeleteRoute("/images/{name:.*}", ir.deleteImages),
<ide> }
<ide> }
<ide><path>api/server/router/image/image_routes.go
<ide> import (
<ide> )
<ide>
<ide> // Creates an image from Pull or from Import
<del>func (s *imageRouter) postImagesCreate(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
<del>
<add>func (ir *imageRouter) postImagesCreate(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
<ide> if err := httputils.ParseForm(r); err != nil {
<ide> return err
<ide> }
<ide>
<ide> var (
<del> image = r.Form.Get("fromImage")
<add> img = r.Form.Get("fromImage")
<ide> repo = r.Form.Get("repo")
<ide> tag = r.Form.Get("tag")
<ide> message = r.Form.Get("message")
<ide> func (s *imageRouter) postImagesCreate(ctx context.Context, w http.ResponseWrite
<ide> }
<ide> }
<ide>
<del> if image != "" { // pull
<add> if img != "" { // pull
<ide> metaHeaders := map[string][]string{}
<ide> for k, v := range r.Header {
<ide> if strings.HasPrefix(k, "X-Meta-") {
<ide> func (s *imageRouter) postImagesCreate(ctx context.Context, w http.ResponseWrite
<ide> // For a pull it is not an error if no auth was given. Ignore invalid
<ide> // AuthConfig to increase compatibility with the existing API.
<ide> authConfig, _ := registry.DecodeAuthConfig(r.Header.Get(registry.AuthHeader))
<del> progressErr = s.backend.PullImage(ctx, image, tag, platform, metaHeaders, authConfig, output)
<add> progressErr = ir.backend.PullImage(ctx, img, tag, platform, metaHeaders, authConfig, output)
<ide> } else { // import
<ide> src := r.Form.Get("fromSrc")
<del> progressErr = s.backend.ImportImage(src, repo, platform, tag, message, r.Body, output, r.Form["changes"])
<add> progressErr = ir.backend.ImportImage(src, repo, platform, tag, message, r.Body, output, r.Form["changes"])
<ide> }
<ide> if progressErr != nil {
<ide> if !output.Flushed() {
<ide> func (s *imageRouter) postImagesCreate(ctx context.Context, w http.ResponseWrite
<ide> return nil
<ide> }
<ide>
<del>func (s *imageRouter) postImagesPush(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
<add>func (ir *imageRouter) postImagesPush(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
<ide> metaHeaders := map[string][]string{}
<ide> for k, v := range r.Header {
<ide> if strings.HasPrefix(k, "X-Meta-") {
<ide> func (s *imageRouter) postImagesPush(ctx context.Context, w http.ResponseWriter,
<ide>
<ide> img := vars["name"]
<ide> tag := r.Form.Get("tag")
<del> if err := s.backend.PushImage(ctx, img, tag, metaHeaders, authConfig, output); err != nil {
<add> if err := ir.backend.PushImage(ctx, img, tag, metaHeaders, authConfig, output); err != nil {
<ide> if !output.Flushed() {
<ide> return err
<ide> }
<ide> func (s *imageRouter) postImagesPush(ctx context.Context, w http.ResponseWriter,
<ide> return nil
<ide> }
<ide>
<del>func (s *imageRouter) getImagesGet(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
<add>func (ir *imageRouter) getImagesGet(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
<ide> if err := httputils.ParseForm(r); err != nil {
<ide> return err
<ide> }
<ide> func (s *imageRouter) getImagesGet(ctx context.Context, w http.ResponseWriter, r
<ide> names = r.Form["names"]
<ide> }
<ide>
<del> if err := s.backend.ExportImage(ctx, names, output); err != nil {
<add> if err := ir.backend.ExportImage(ctx, names, output); err != nil {
<ide> if !output.Flushed() {
<ide> return err
<ide> }
<ide> func (s *imageRouter) getImagesGet(ctx context.Context, w http.ResponseWriter, r
<ide> return nil
<ide> }
<ide>
<del>func (s *imageRouter) postImagesLoad(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
<add>func (ir *imageRouter) postImagesLoad(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
<ide> if err := httputils.ParseForm(r); err != nil {
<ide> return err
<ide> }
<ide> func (s *imageRouter) postImagesLoad(ctx context.Context, w http.ResponseWriter,
<ide>
<ide> output := ioutils.NewWriteFlusher(w)
<ide> defer output.Close()
<del> if err := s.backend.LoadImage(ctx, r.Body, output, quiet); err != nil {
<add> if err := ir.backend.LoadImage(ctx, r.Body, output, quiet); err != nil {
<ide> _, _ = output.Write(streamformatter.FormatError(err))
<ide> }
<ide> return nil
<ide> func (missingImageError) Error() string {
<ide>
<ide> func (missingImageError) InvalidParameter() {}
<ide>
<del>func (s *imageRouter) deleteImages(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
<add>func (ir *imageRouter) deleteImages(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
<ide> if err := httputils.ParseForm(r); err != nil {
<ide> return err
<ide> }
<ide> func (s *imageRouter) deleteImages(ctx context.Context, w http.ResponseWriter, r
<ide> force := httputils.BoolValue(r, "force")
<ide> prune := !httputils.BoolValue(r, "noprune")
<ide>
<del> list, err := s.backend.ImageDelete(ctx, name, force, prune)
<add> list, err := ir.backend.ImageDelete(ctx, name, force, prune)
<ide> if err != nil {
<ide> return err
<ide> }
<ide>
<ide> return httputils.WriteJSON(w, http.StatusOK, list)
<ide> }
<ide>
<del>func (s *imageRouter) getImagesByName(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
<del> image, err := s.backend.GetImage(vars["name"], nil)
<add>func (ir *imageRouter) getImagesByName(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
<add> img, err := ir.backend.GetImage(vars["name"], nil)
<ide> if err != nil {
<ide> return err
<ide> }
<ide>
<del> imageInspect, err := s.toImageInspect(image)
<add> imageInspect, err := ir.toImageInspect(img)
<ide> if err != nil {
<ide> return err
<ide> }
<ide>
<ide> return httputils.WriteJSON(w, http.StatusOK, imageInspect)
<ide> }
<ide>
<del>func (s *imageRouter) toImageInspect(img *image.Image) (*types.ImageInspect, error) {
<del> refs := s.referenceBackend.References(img.ID().Digest())
<del> repoTags := []string{}
<del> repoDigests := []string{}
<add>func (ir *imageRouter) toImageInspect(img *image.Image) (*types.ImageInspect, error) {
<add> refs := ir.referenceBackend.References(img.ID().Digest())
<add> var repoTags, repoDigests []string
<ide> for _, ref := range refs {
<ide> switch ref.(type) {
<ide> case reference.NamedTagged:
<ide> func (s *imageRouter) toImageInspect(img *image.Image) (*types.ImageInspect, err
<ide>
<ide> var size int64
<ide> var layerMetadata map[string]string
<del> layerID := img.RootFS.ChainID()
<del> if layerID != "" {
<del> l, err := s.layerStore.Get(layerID)
<add> if layerID := img.RootFS.ChainID(); layerID != "" {
<add> l, err := ir.layerStore.Get(layerID)
<ide> if err != nil {
<ide> return nil, err
<ide> }
<del> defer layer.ReleaseAndLog(s.layerStore, l)
<add> defer layer.ReleaseAndLog(ir.layerStore, l)
<ide> size = l.Size()
<ide> layerMetadata, err = l.Metadata()
<ide> if err != nil {
<ide> func (s *imageRouter) toImageInspect(img *image.Image) (*types.ImageInspect, err
<ide> comment = img.History[len(img.History)-1].Comment
<ide> }
<ide>
<del> lastUpdated, err := s.imageStore.GetLastUpdated(img.ID())
<add> lastUpdated, err := ir.imageStore.GetLastUpdated(img.ID())
<ide> if err != nil {
<ide> return nil, err
<ide> }
<ide> func (s *imageRouter) toImageInspect(img *image.Image) (*types.ImageInspect, err
<ide> Size: size,
<ide> VirtualSize: size, // TODO: field unused, deprecate
<ide> GraphDriver: types.GraphDriverData{
<del> Name: s.layerStore.DriverName(),
<add> Name: ir.layerStore.DriverName(),
<ide> Data: layerMetadata,
<ide> },
<ide> RootFS: rootFSToAPIType(img.RootFS),
<ide> func rootFSToAPIType(rootfs *image.RootFS) types.RootFS {
<ide> }
<ide> }
<ide>
<del>func (s *imageRouter) getImagesJSON(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
<add>func (ir *imageRouter) getImagesJSON(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
<ide> if err := httputils.ParseForm(r); err != nil {
<ide> return err
<ide> }
<ide> func (s *imageRouter) getImagesJSON(ctx context.Context, w http.ResponseWriter,
<ide> sharedSize = httputils.BoolValue(r, "shared-size")
<ide> }
<ide>
<del> images, err := s.backend.Images(ctx, types.ImageListOptions{
<add> images, err := ir.backend.Images(ctx, types.ImageListOptions{
<ide> All: httputils.BoolValue(r, "all"),
<ide> Filters: imageFilters,
<ide> SharedSize: sharedSize,
<ide> func (s *imageRouter) getImagesJSON(ctx context.Context, w http.ResponseWriter,
<ide> return httputils.WriteJSON(w, http.StatusOK, images)
<ide> }
<ide>
<del>func (s *imageRouter) getImagesHistory(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
<del> name := vars["name"]
<del> history, err := s.backend.ImageHistory(name)
<add>func (ir *imageRouter) getImagesHistory(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
<add> history, err := ir.backend.ImageHistory(vars["name"])
<ide> if err != nil {
<ide> return err
<ide> }
<ide>
<ide> return httputils.WriteJSON(w, http.StatusOK, history)
<ide> }
<ide>
<del>func (s *imageRouter) postImagesTag(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
<add>func (ir *imageRouter) postImagesTag(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
<ide> if err := httputils.ParseForm(r); err != nil {
<ide> return err
<ide> }
<del> if _, err := s.backend.TagImage(vars["name"], r.Form.Get("repo"), r.Form.Get("tag")); err != nil {
<add> if _, err := ir.backend.TagImage(vars["name"], r.Form.Get("repo"), r.Form.Get("tag")); err != nil {
<ide> return err
<ide> }
<ide> w.WriteHeader(http.StatusCreated)
<ide> return nil
<ide> }
<ide>
<del>func (s *imageRouter) getImagesSearch(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
<add>func (ir *imageRouter) getImagesSearch(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
<ide> if err := httputils.ParseForm(r); err != nil {
<ide> return err
<ide> }
<ide> func (s *imageRouter) getImagesSearch(ctx context.Context, w http.ResponseWriter
<ide> // For a search it is not an error if no auth was given. Ignore invalid
<ide> // AuthConfig to increase compatibility with the existing API.
<ide> authConfig, _ := registry.DecodeAuthConfig(r.Header.Get(registry.AuthHeader))
<del> query, err := s.backend.SearchRegistryForImages(ctx, searchFilters, r.Form.Get("term"), limit, authConfig, headers)
<add> query, err := ir.backend.SearchRegistryForImages(ctx, searchFilters, r.Form.Get("term"), limit, authConfig, headers)
<ide> if err != nil {
<ide> return err
<ide> }
<ide> return httputils.WriteJSON(w, http.StatusOK, query.Results)
<ide> }
<ide>
<del>func (s *imageRouter) postImagesPrune(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
<add>func (ir *imageRouter) postImagesPrune(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
<ide> if err := httputils.ParseForm(r); err != nil {
<ide> return err
<ide> }
<ide> func (s *imageRouter) postImagesPrune(ctx context.Context, w http.ResponseWriter
<ide> return err
<ide> }
<ide>
<del> pruneReport, err := s.backend.ImagesPrune(ctx, pruneFilters)
<add> pruneReport, err := ir.backend.ImagesPrune(ctx, pruneFilters)
<ide> if err != nil {
<ide> return err
<ide> } | 2 |
Javascript | Javascript | fix lint in local-cli | 24d2bbfbab174aa528aa73cccbbefb67f95c2451 | <ide><path>local-cli/__mocks__/beeper.js
<add>/**
<add> * Copyright (c) 2015-present, Facebook, Inc.
<add> * All rights reserved.
<add> *
<add> * This source code is licensed under the BSD-style license found in the
<add> * LICENSE file in the root directory of this source tree. An additional grant
<add> * of patent rights can be found in the PATENTS file in the same directory.
<add> */
<add> 'use strict';
<add>
<ide> // [email protected] has a return statement outside of a function
<ide> // and therefore doesn't parse. Let's mock it so that we can
<ide> // run the tests.
<del>
<ide> module.exports = function () {};
<ide><path>local-cli/__tests__/generators-test.js
<ide> jest.autoMockOff();
<ide> var path = require('path');
<ide> var fs = require('fs');
<ide>
<add>// eslint-disable-next-line improperly-disabled-jasmine-tests
<ide> xdescribe('React Yeoman Generators', function() {
<ide> describe('react:react', function() {
<ide> var assert;
<ide> xdescribe('React Yeoman Generators', function() {
<ide> jest.runAllTicks();
<ide> jest.runOnlyPendingTimers();
<ide> return generated;
<del> }, "generation", 750);
<add> }, 'generation', 750);
<ide> });
<ide>
<ide> it('creates files', function() {
<ide> xdescribe('React Yeoman Generators', function() {
<ide> var stat = fs.statSync('android');
<ide>
<ide> expect(stat.isDirectory()).toBe(true);
<del> })
<add> });
<ide> });
<ide>
<ide> describe('react:android', function () {
<ide> xdescribe('React Yeoman Generators', function() {
<ide> jest.runAllTicks();
<ide> jest.runOnlyPendingTimers();
<ide> return generated;
<del> }, "generation", 750);
<add> }, 'generation', 750);
<ide> });
<ide>
<ide> it('creates files', function () {
<ide> xdescribe('React Yeoman Generators', function() {
<ide> jest.runAllTicks();
<ide> jest.runOnlyPendingTimers();
<ide> return generated;
<del> }, "generation", 750);
<add> }, 'generation', 750);
<ide> });
<ide>
<ide> it('creates files', function() {
<ide><path>local-cli/android/android.js
<ide> */
<ide> 'use strict';
<ide>
<del>var generate = require('../generate/generate');
<ide> var fs = require('fs');
<add>var generate = require('../generate/generate');
<ide>
<ide> function android(argv, config, args) {
<ide> return generate([
<ide> module.exports = {
<ide> try {
<ide> return JSON.parse(
<ide> fs.readFileSync('package.json', 'utf8')
<del> ).name
<add> ).name;
<ide> } catch (e) {
<del> return 'unknown-app-name'
<add> return 'unknown-app-name';
<ide> }
<ide> },
<ide> }],
<ide><path>local-cli/bundle/buildBundle.js
<ide> * LICENSE file in the root directory of this source tree. An additional grant
<ide> * of patent rights can be found in the PATENTS file in the same directory.
<ide> */
<add>'use strict';
<ide>
<ide> const log = require('../util/log').out('bundle');
<ide> const Promise = require('promise');
<ide><path>local-cli/bundle/bundle.js
<ide> * LICENSE file in the root directory of this source tree. An additional grant
<ide> * of patent rights can be found in the PATENTS file in the same directory.
<ide> */
<add>'use strict';
<ide>
<ide> const buildBundle = require('./buildBundle');
<del>const outputBundle = require('./output/bundle');
<ide> const bundleCommandLineArgs = require('./bundleCommandLineArgs');
<add>const outputBundle = require('./output/bundle');
<ide>
<ide> /**
<ide> * Builds the bundle starting to look for dependencies at the given entry path.
<ide><path>local-cli/bundle/getAssetDestPathAndroid.js
<ide> */
<ide> 'use strict';
<ide>
<del>const path = require('path');
<ide> const assetPathUtils = require('./assetPathUtils');
<add>const path = require('path');
<ide>
<ide> function getAssetDestPathAndroid(asset, scale) {
<ide> const androidFolder = assetPathUtils.getAndroidDrawableFolderName(asset, scale);
<ide><path>local-cli/bundle/output/bundle.js
<ide> 'use strict';
<ide>
<ide> const Promise = require('promise');
<add>
<ide> const meta = require('./meta');
<ide> const writeFile = require('./writeFile');
<ide>
<ide><path>local-cli/bundle/output/unbundle/as-assets.js
<ide> */
<ide> 'use strict';
<ide>
<del>const mkdirp = require('mkdirp');
<del>const path = require('path');
<add>const MAGIC_UNBUNDLE_NUMBER = require('./magic-number');
<ide> const Promise = require('promise');
<ide>
<ide> const buildSourceMapWithMetaData = require('./build-unbundle-sourcemap-with-metadata');
<add>const mkdirp = require('mkdirp');
<add>const path = require('path');
<ide> const writeFile = require('../writeFile');
<ide> const writeSourceMap = require('./write-sourcemap');
<del>const MAGIC_UNBUNDLE_NUMBER = require('./magic-number');
<add>
<ide> const {joinModules} = require('./util');
<ide>
<ide> const MAGIC_UNBUNDLE_FILENAME = 'UNBUNDLE'; // must not start with a dot, as that won't go into the apk
<ide><path>local-cli/bundle/output/unbundle/as-indexed-file.js
<ide> */
<ide> 'use strict';
<ide>
<add>const MAGIC_UNBUNDLE_FILE_HEADER = require('./magic-number');
<add>const Promise = require('promise');
<add>
<ide> const buildSourceMapWithMetaData = require('./build-unbundle-sourcemap-with-metadata');
<ide> const fs = require('fs');
<del>const Promise = require('promise');
<ide> const writeSourceMap = require('./write-sourcemap');
<del>const {joinModules} = require('./util');
<ide>
<del>const MAGIC_UNBUNDLE_FILE_HEADER = require('./magic-number');
<add>const {joinModules} = require('./util');
<ide> const SIZEOF_UINT32 = 4;
<ide>
<ide> /**
<ide><path>local-cli/bundle/output/unbundle/index.js
<ide> */
<ide> 'use strict';
<ide>
<del>const asIndexedFile = require('./as-indexed-file');
<ide> const asAssets = require('./as-assets');
<add>const asIndexedFile = require('./as-indexed-file');
<ide>
<ide> function buildBundle(packagerClient, requestOptions) {
<ide> return packagerClient.buildBundle({
<ide><path>local-cli/bundle/output/unbundle/write-sourcemap.js
<ide> 'use strict';
<ide>
<ide> const Promise = require('promise');
<add>
<ide> const writeFile = require('../writeFile');
<ide>
<ide> function writeSourcemap(fileName, contents, log) {
<ide><path>local-cli/bundle/output/writeFile.js
<ide> */
<ide> 'use strict';
<ide>
<del>const fs = require('fs');
<ide> const Promise = require('promise');
<ide>
<add>const fs = require('fs');
<add>
<ide> function writeFile(file, data, encoding) {
<ide> return new Promise((resolve, reject) => {
<ide> fs.writeFile(
<ide><path>local-cli/bundle/signedsource.js
<ide> var TOKEN = '<<SignedSource::*O*zOeWoEQle#+L!plEphiEmie@IsG>>',
<ide> OLDTOKEN = '<<SignedSource::*O*zOeWoEQle#+L!plEphiEmie@I>>',
<ide> TOKENS = [TOKEN, OLDTOKEN],
<del> PATTERN = new RegExp('@'+'generated (?:SignedSource<<([a-f0-9]{32})>>)');
<add> PATTERN = new RegExp('@' + 'generated (?:SignedSource<<([a-f0-9]{32})>>)');
<ide>
<ide> exports.SIGN_OK = {message:'ok'};
<ide> exports.SIGN_UNSIGNED = new Error('unsigned');
<ide> exports.SIGN_INVALID = new Error('invalid');
<ide>
<ide> // Thrown by sign(). Primarily for unit tests.
<ide> exports.TokenNotFoundError = new Error(
<del> 'Code signing placeholder not found (expected to find \''+TOKEN+'\')');
<add> 'Code signing placeholder not found (expected to find \'' + TOKEN + '\')');
<ide>
<ide> var md5_hash_hex;
<ide>
<ide> // MD5 hash function for Node.js. To port this to other platforms, provide an
<ide> // alternate code path for defining the md5_hash_hex function.
<ide> var crypto = require('crypto');
<add>// eslint-disable-next-line no-shadow
<ide> md5_hash_hex = function md5_hash_hex(data, input_encoding) {
<ide> var md5sum = crypto.createHash('md5');
<ide> md5sum.update(data, input_encoding);
<ide> md5_hash_hex = function md5_hash_hex(data, input_encoding) {
<ide> //
<ide> // @return str to be embedded in to-be-signed file
<ide> function signing_token() {
<del> return '@'+'generated '+TOKEN;
<add> return '@' + 'generated ' + TOKEN;
<ide> }
<ide> exports.signing_token = signing_token;
<ide>
<ide> exports.is_signed = is_signed;
<ide> function sign(file_data) {
<ide> var first_time = file_data.indexOf(TOKEN) !== -1;
<ide> if (!first_time) {
<del> if (is_signed(file_data))
<add> if (is_signed(file_data)) {
<ide> file_data = file_data.replace(PATTERN, signing_token());
<del> else
<add> } else {
<ide> throw exports.TokenNotFoundError;
<add> }
<ide> }
<ide> var signature = md5_hash_hex(file_data, 'utf8');
<del> var signed_data = file_data.replace(TOKEN, 'SignedSource<<'+signature+'>>');
<add> var signed_data = file_data.replace(TOKEN, 'SignedSource<<' + signature + '>>');
<ide> return { first_time: first_time, signed_data: signed_data };
<ide> }
<ide> exports.sign = sign;
<ide> exports.sign = sign;
<ide> // it contains an invalid signature.
<ide> function verify_signature(file_data) {
<ide> var match = PATTERN.exec(file_data);
<del> if (!match)
<add> if (!match) {
<ide> return exports.SIGN_UNSIGNED;
<add> }
<ide> // Replace the signature with the TOKEN, then hash and see if it matches
<ide> // the value in the file. For backwards compatibility, also try with
<ide> // OLDTOKEN if that doesn't match.
<ide> var k, token, with_token, actual_md5, expected_md5 = match[1];
<ide> for (k in TOKENS) {
<ide> token = TOKENS[k];
<del> with_token = file_data.replace(PATTERN, '@'+'generated '+token);
<add> with_token = file_data.replace(PATTERN, '@' + 'generated ' + token);
<ide> actual_md5 = md5_hash_hex(with_token, 'utf8');
<del> if (expected_md5 === actual_md5)
<add> if (expected_md5 === actual_md5) {
<ide> return exports.SIGN_OK;
<add> }
<ide> }
<ide> return exports.SIGN_INVALID;
<ide> }
<ide><path>local-cli/bundle/unbundle.js
<ide> * LICENSE file in the root directory of this source tree. An additional grant
<ide> * of patent rights can be found in the PATENTS file in the same directory.
<ide> */
<add>'use strict';
<ide>
<ide> const bundleWithOutput = require('./bundle').withOutput;
<ide> const bundleCommandLineArgs = require('./bundleCommandLineArgs');
<ide><path>local-cli/core/config/android/findAndroidAppFolder.js
<add>/**
<add> * Copyright (c) 2015-present, Facebook, Inc.
<add> * All rights reserved.
<add> *
<add> * This source code is licensed under the BSD-style license found in the
<add> * LICENSE file in the root directory of this source tree. An additional grant
<add> * of patent rights can be found in the PATENTS file in the same directory.
<add> */
<add>'use strict';
<add>
<ide> const fs = require('fs');
<ide> const path = require('path');
<ide>
<ide><path>local-cli/core/config/android/findManifest.js
<add>/**
<add> * Copyright (c) 2015-present, Facebook, Inc.
<add> * All rights reserved.
<add> *
<add> * This source code is licensed under the BSD-style license found in the
<add> * LICENSE file in the root directory of this source tree. An additional grant
<add> * of patent rights can be found in the PATENTS file in the same directory.
<add> */
<add>'use strict';
<add>
<ide> const glob = require('glob');
<ide> const path = require('path');
<ide>
<ide><path>local-cli/core/config/android/findPackageClassName.js
<add>/**
<add> * Copyright (c) 2015-present, Facebook, Inc.
<add> * All rights reserved.
<add> *
<add> * This source code is licensed under the BSD-style license found in the
<add> * LICENSE file in the root directory of this source tree. An additional grant
<add> * of patent rights can be found in the PATENTS file in the same directory.
<add> */
<add>'use strict';
<add>
<ide> const fs = require('fs');
<del>const path = require('path');
<ide> const glob = require('glob');
<add>const path = require('path');
<ide>
<ide> /**
<ide> * Gets package's class name (class that implements ReactPackage)
<ide><path>local-cli/core/config/android/index.js
<del>const path = require('path');
<del>const fs = require('fs');
<del>const glob = require('glob');
<add>/**
<add> * Copyright (c) 2015-present, Facebook, Inc.
<add> * All rights reserved.
<add> *
<add> * This source code is licensed under the BSD-style license found in the
<add> * LICENSE file in the root directory of this source tree. An additional grant
<add> * of patent rights can be found in the PATENTS file in the same directory.
<add> */
<add>'use strict';
<add>
<ide> const findAndroidAppFolder = require('./findAndroidAppFolder');
<ide> const findManifest = require('./findManifest');
<del>const readManifest = require('./readManifest');
<ide> const findPackageClassName = require('./findPackageClassName');
<add>const path = require('path');
<add>const readManifest = require('./readManifest');
<ide>
<ide> const getPackageName = (manifest) => manifest.attr.package;
<ide>
<ide><path>local-cli/core/config/android/readManifest.js
<add>/**
<add> * Copyright (c) 2015-present, Facebook, Inc.
<add> * All rights reserved.
<add> *
<add> * This source code is licensed under the BSD-style license found in the
<add> * LICENSE file in the root directory of this source tree. An additional grant
<add> * of patent rights can be found in the PATENTS file in the same directory.
<add> */
<add>'use strict';
<add>
<ide> const fs = require('fs');
<ide> const xml = require('xmldoc');
<ide>
<ide><path>local-cli/core/config/findAssets.js
<add>/**
<add> * Copyright (c) 2015-present, Facebook, Inc.
<add> * All rights reserved.
<add> *
<add> * This source code is licensed under the BSD-style license found in the
<add> * LICENSE file in the root directory of this source tree. An additional grant
<add> * of patent rights can be found in the PATENTS file in the same directory.
<add> */
<add>'use strict';
<add>
<ide> const glob = require('glob');
<ide> const path = require('path');
<ide>
<ide> const findAssetsInFolder = (folder) =>
<ide> module.exports = function findAssets(folder, assets) {
<ide> return (assets || [])
<ide> .map(assetsFolder => path.join(folder, assetsFolder))
<del> .reduce((assets, assetsFolder) =>
<del> assets.concat(findAssetsInFolder(assetsFolder)),
<add> .reduce((_assets, assetsFolder) =>
<add> _assets.concat(findAssetsInFolder(assetsFolder)),
<ide> []
<ide> );
<ide> };
<ide><path>local-cli/core/config/index.js
<del>const path = require('path');
<add>/**
<add> * Copyright (c) 2015-present, Facebook, Inc.
<add> * All rights reserved.
<add> *
<add> * This source code is licensed under the BSD-style license found in the
<add> * LICENSE file in the root directory of this source tree. An additional grant
<add> * of patent rights can be found in the PATENTS file in the same directory.
<add> */
<add>'use strict';
<ide>
<ide> const android = require('./android');
<del>const ios = require('./ios');
<ide> const findAssets = require('./findAssets');
<add>const ios = require('./ios');
<add>const path = require('path');
<ide> const wrapCommands = require('./wrapCommands');
<ide>
<ide> const getRNPMConfig = (folder) =>
<ide><path>local-cli/core/config/ios/findProject.js
<add>/**
<add> * Copyright (c) 2015-present, Facebook, Inc.
<add> * All rights reserved.
<add> *
<add> * This source code is licensed under the BSD-style license found in the
<add> * LICENSE file in the root directory of this source tree. An additional grant
<add> * of patent rights can be found in the PATENTS file in the same directory.
<add> */
<add>'use strict';
<add>
<ide> const glob = require('glob');
<ide> const path = require('path');
<ide>
<ide> module.exports = function findProject(folder) {
<ide> return path.dirname(project) === IOS_BASE || !TEST_PROJECTS.test(project);
<ide> })
<ide> .sort((projectA, projectB) => {
<del> return path.dirname(projectA) === IOS_BASE? -1 : 1;
<add> return path.dirname(projectA) === IOS_BASE ? -1 : 1;
<ide> });
<ide>
<ide> if (projects.length === 0) {
<ide><path>local-cli/core/config/ios/index.js
<del>const path = require('path');
<add>/**
<add> * Copyright (c) 2015-present, Facebook, Inc.
<add> * All rights reserved.
<add> *
<add> * This source code is licensed under the BSD-style license found in the
<add> * LICENSE file in the root directory of this source tree. An additional grant
<add> * of patent rights can be found in the PATENTS file in the same directory.
<add> */
<add>'use strict';
<add>
<ide> const findProject = require('./findProject');
<add>const path = require('path');
<ide>
<ide> /**
<ide> * For libraries specified without an extension, add '.tbd' for those that
<ide><path>local-cli/core/config/wrapCommands.js
<add>/**
<add> * Copyright (c) 2015-present, Facebook, Inc.
<add> * All rights reserved.
<add> *
<add> * This source code is licensed under the BSD-style license found in the
<add> * LICENSE file in the root directory of this source tree. An additional grant
<add> * of patent rights can be found in the PATENTS file in the same directory.
<add> */
<add>'use strict';
<add>
<ide> const makeCommand = require('../makeCommand');
<ide>
<ide> module.exports = function wrapCommands(commands) {
<ide> const mappedCommands = {};
<del> Object.keys(commands || []).forEach((k) =>
<del> mappedCommands[k] = makeCommand(commands[k])
<del> );
<add> Object.keys(commands || []).forEach((k) => {
<add> mappedCommands[k] = makeCommand(commands[k]);
<add> });
<ide> return mappedCommands;
<ide> };
<ide><path>local-cli/core/findPlugins.js
<add>/**
<add> * Copyright (c) 2015-present, Facebook, Inc.
<add> * All rights reserved.
<add> *
<add> * This source code is licensed under the BSD-style license found in the
<add> * LICENSE file in the root directory of this source tree. An additional grant
<add> * of patent rights can be found in the PATENTS file in the same directory.
<add> */
<add>'use strict';
<add>
<ide> const path = require('path');
<ide> const union = require('lodash').union;
<ide> const uniq = require('lodash').uniq;
<ide><path>local-cli/core/getCommands.js
<del>const path = require('path');
<add>/**
<add> * Copyright (c) 2015-present, Facebook, Inc.
<add> * All rights reserved.
<add> *
<add> * This source code is licensed under the BSD-style license found in the
<add> * LICENSE file in the root directory of this source tree. An additional grant
<add> * of patent rights can be found in the PATENTS file in the same directory.
<add> */
<add>'use strict';
<add>
<ide> const findPlugins = require('./findPlugins');
<add>const path = require('path');
<ide> const flatten = require('lodash').flatten;
<ide>
<ide> const attachPackage = (command, pkg) => Array.isArray(command)
<ide><path>local-cli/core/makeCommand.js
<add>/**
<add> * Copyright (c) 2015-present, Facebook, Inc.
<add> * All rights reserved.
<add> *
<add> * This source code is licensed under the BSD-style license found in the
<add> * LICENSE file in the root directory of this source tree. An additional grant
<add> * of patent rights can be found in the PATENTS file in the same directory.
<add> */
<add>'use strict';
<add>
<ide> const spawn = require('child_process').spawn;
<ide>
<ide> module.exports = function makeCommand(command) {
<ide><path>local-cli/generate-android.js
<ide> */
<ide> 'use strict';
<ide>
<del>var fs = require('fs');
<ide> var path = require('path');
<ide> var yeoman = require('yeoman-environment');
<ide>
<ide><path>local-cli/generator-utils.js
<ide> */
<ide> 'use strict';
<ide>
<del>var path = require('path');
<ide> var fs = require('fs');
<add>var path = require('path');
<ide>
<ide> function copyAndReplace(src, dest, replacements) {
<ide> if (fs.lstatSync(src).isDirectory()) {
<ide><path>local-cli/server/server.js
<ide> 'use strict';
<ide>
<ide> const chalk = require('chalk');
<add>const findSymlinksPaths = require('./findSymlinksPaths');
<ide> const formatBanner = require('./formatBanner');
<ide> const path = require('path');
<ide> const runServer = require('./runServer');
<del>const findSymlinksPaths = require('./findSymlinksPaths');
<ide> const NODE_MODULES = path.resolve(__dirname, '..', '..', '..');
<ide>
<ide> /** | 30 |
Text | Text | fix broken links | f502e17cc78d714048579dac329334c854de77a4 | <ide><path>docs/Testing.md
<ide> next: runningondevice
<ide>
<ide> The React Native repo has several tests you can run to verify you haven't caused a regression with your PR. These tests are run with the [Travis](http://docs.travis-ci.com/) continuous integration system, and will automatically post the results to your PR. You can also run them locally with cmd+U in the IntegrationTest and UIExplorer apps in Xcode. You can run the jest tests via `npm test` on the command line.
<ide>
<del>If you make a change that affects a snapshot test in a PR, such as adding a new example case to one of the examples that is snapshotted, you'll need to re-record the snapshotshot reference image. To do this, simply change to `_runner.recordMode = YES;` in UIExplorerIntegrationTests.m [here](https://github.com/facebook/react-native/blob/master/Examples/UIExplorer/UIExplorerIntegrationTests/UIExplorerIntegrationTests.m#L46), re-run the failing tests, then flip record back to `NO` and submit/update your PR and wait to see if the travis build passes.
<add>If you make a change that affects a snapshot test in a PR, such as adding a new example case to one of the examples that is snapshotted, you'll need to re-record the snapshotshot reference image. To do this, simply change to `_runner.recordMode = YES;` in [UIExplorer/IntegrationTests.m](https://github.com/facebook/react-native/blob/master/Examples/UIExplorer/UIExplorerIntegrationTests/IntegrationTests.m#L46), re-run the failing tests, then flip record back to `NO` and submit/update your PR and wait to see if the Travis build passes.
<ide>
<ide> We don't have perfect test coverage of course, especially for complex end-to-end interactions with the user, so many changes will still require significant manual verification, but we would love it if you want to help us increase our test coverage and add more tests and test cases!
<ide>
<ide> Note: you may have to install/upgrade/link io.js and other parts of your environ
<ide>
<ide> ## Integration Tests
<ide>
<del>React Native provides facilities to make it easier to test integrated components that require both native and JS components to communicate across the bridge. The two main components are `RCTTestRunner` and `RCTTestModule`. `RCTTestRunner` sets up the ReactNative environment and provides facilities to run the tests as `XCTestCase`s in Xcode (`runTest:module` is the simplest method). `RCTTestModule` is exported to JS as `NativeModules.TestModule`. The tests themselves are written in JS, and must call `TestModule.markTestCompleted()` when they are done, otherwise the test will timeout and fail. Test failures are primarily indicated by throwing a JS exception. It is also possible to test error conditions with `runTest:module:initialProps:expectErrorRegex:` or `runTest:module:initialProps:expectErrorBlock:` which will expect an error to be thrown and verify the error matches the provided criteria. See [`IntegrationTestHarnessTest.js`](https://github.com/facebook/react-native/blob/master/Examples/UIExplorer/UIExplorerIntegrationTests/js/IntegrationTestHarnessTest.js), [`IntegrationTestsTests.m`](https://github.com/facebook/react-native/blob/master/Examples/UIExplorer/UIExplorerIntegrationTests/IntegrationTestsTests.m), and [IntegrationTestsApp.js](https://github.com/facebook/react-native/blob/master/Examples/UIExplorer/UIExplorerIntegrationTests/js/IntegrationTestsApp.js) for example usage and integration points.
<add>React Native provides facilities to make it easier to test integrated components that require both native and JS components to communicate across the bridge. The two main components are `RCTTestRunner` and `RCTTestModule`. `RCTTestRunner` sets up the ReactNative environment and provides facilities to run the tests as `XCTestCase`s in Xcode (`runTest:module` is the simplest method). `RCTTestModule` is exported to JS as `NativeModules.TestModule`. The tests themselves are written in JS, and must call `TestModule.markTestCompleted()` when they are done, otherwise the test will timeout and fail. Test failures are primarily indicated by throwing a JS exception. It is also possible to test error conditions with `runTest:module:initialProps:expectErrorRegex:` or `runTest:module:initialProps:expectErrorBlock:` which will expect an error to be thrown and verify the error matches the provided criteria. See [`IntegrationTestHarnessTest.js`](https://github.com/facebook/react-native/blob/master/Examples/UIExplorer/UIExplorerIntegrationTests/js/IntegrationTestHarnessTest.js), [`IntegrationTests.m`](https://github.com/facebook/react-native/blob/master/Examples/UIExplorer/UIExplorerIntegrationTests/IntegrationTests.m), and [IntegrationTestsApp.js](https://github.com/facebook/react-native/blob/master/Examples/UIExplorer/UIExplorerIntegrationTests/js/IntegrationTestsApp.js) for example usage and integration points.
<ide>
<ide> ## Snapshot Tests
<ide> | 1 |
Java | Java | improve mountingmanager debug logging | 0c3988356e6a134400c11d9a4180af11814f5642 | <ide><path>ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountingManager.java
<ide> private static void logViewHierarchy(ViewGroup parent) {
<ide> for (int i = 0; i < parent.getChildCount(); i++) {
<ide> FLog.e(
<ide> TAG,
<del> " <View tag="
<add> " <View idx="
<add> + i
<add> + " tag="
<ide> + parent.getChildAt(i).getId()
<ide> + " toString="
<ide> + parent.getChildAt(i).toString()
<ide> private void dropView(@NonNull View view) {
<ide> }
<ide>
<ide> @UiThread
<del> public void addViewAt(int parentTag, int tag, int index) {
<add> public void addViewAt(final int parentTag, final int tag, final int index) {
<ide> UiThreadUtil.assertOnUiThread();
<ide> ViewState parentViewState = getViewState(parentTag);
<ide> if (!(parentViewState.mView instanceof ViewGroup)) {
<ide> public void addViewAt(int parentTag, int tag, int index) {
<ide>
<ide> // Display children after inserting
<ide> if (SHOW_CHANGED_VIEW_HIERARCHIES) {
<del> FLog.e(TAG, "addViewAt: [" + tag + "] -> [" + parentTag + "] idx: " + index + " AFTER");
<del> logViewHierarchy(parentView);
<add> UiThreadUtil.runOnUiThread(
<add> new Runnable() {
<add> @Override
<add> public void run() {
<add> FLog.e(
<add> TAG, "addViewAt: [" + tag + "] -> [" + parentTag + "] idx: " + index + " AFTER");
<add> logViewHierarchy(parentView);
<add> }
<add> });
<ide> }
<ide> }
<ide>
<ide> public void sendAccessibilityEvent(int reactTag, int eventType) {
<ide> }
<ide>
<ide> @UiThread
<del> public void removeViewAt(int tag, int parentTag, int index) {
<add> public void removeViewAt(final int tag, final int parentTag, final int index) {
<ide> UiThreadUtil.assertOnUiThread();
<ide> ViewState viewState = getNullableViewState(parentTag);
<ide>
<ide> public void removeViewAt(int tag, int parentTag, int index) {
<ide>
<ide> // Display children after deleting any
<ide> if (SHOW_CHANGED_VIEW_HIERARCHIES) {
<del> FLog.e(TAG, "removeViewAt: [" + parentTag + "] idx: " + index + " AFTER");
<del> logViewHierarchy(parentView);
<add> UiThreadUtil.runOnUiThread(
<add> new Runnable() {
<add> @Override
<add> public void run() {
<add> FLog.e(TAG, "removeViewAt: [" + parentTag + "] idx: " + index + " AFTER");
<add> logViewHierarchy(parentView);
<add> }
<add> });
<ide> }
<ide> }
<ide> | 1 |
PHP | PHP | add getcookies() method to response | d6a720b2c0d21afffb644933aa7a406eccd63772 | <ide><path>src/Http/Response.php
<ide> public function __toString()
<ide> * @param array|null $options Either null to get all cookies, string for a specific cookie
<ide> * or array to set cookie.
<ide> * @return mixed
<del> * @deprecated 3.4.0 Use getCookie() and withCookie() instead.
<add> * @deprecated 3.4.0 Use getCookie(), getCookies() and withCookie() instead.
<ide> */
<ide> public function cookie($options = null)
<ide> {
<ide> public function getCookie($name)
<ide> return null;
<ide> }
<ide>
<add> /**
<add> * Get all cookies in the response.
<add> *
<add> * Returns an associative array of cookie name => cookie data.
<add> *
<add> * @return array
<add> */
<add> public function getCookies()
<add> {
<add> return $this->_cookies;
<add> }
<add>
<ide> /**
<ide> * Setup access for origin and methods on cross origin requests
<ide> *
<ide><path>tests/TestCase/Network/ResponseTest.php
<ide> public function testWithCookieArray()
<ide> $this->assertEquals($expected, $new->getCookie('testing'));
<ide> }
<ide>
<add> /**
<add> * Test getCookies() and array data.
<add> *
<add> * @return void
<add> */
<add> public function testGetCookies()
<add> {
<add> $response = new Response();
<add> $cookie = [
<add> 'name' => 'ignored key',
<add> 'value' => '[a,b,c]',
<add> 'expire' => 1000,
<add> 'path' => '/test',
<add> 'secure' => true
<add> ];
<add> $new = $response->withCookie('testing', 'a')
<add> ->withCookie('test2', ['value' => 'b', 'path' => '/test', 'secure' => true]);
<add> $expected = [
<add> 'testing' => [
<add> 'name' => 'testing',
<add> 'value' => 'a',
<add> 'expire' => null,
<add> 'path' => '/',
<add> 'domain' => '',
<add> 'secure' => false,
<add> 'httpOnly' => false
<add> ],
<add> 'test2' => [
<add> 'name' => 'test2',
<add> 'value' => 'b',
<add> 'expire' => null,
<add> 'path' => '/test',
<add> 'domain' => '',
<add> 'secure' => true,
<add> 'httpOnly' => false
<add> ]
<add> ];
<add> $this->assertEquals($expected, $new->getCookies());
<add> }
<add>
<ide> /**
<ide> * Test CORS
<ide> * | 2 |
Javascript | Javascript | fix a typo in api.js | 049beac3466df8cb9bac8110c516af37c8e7b46b | <ide><path>src/display/api.js
<ide> var PDFWorker = (function PDFWorkerClosure() {
<ide>
<ide> _initialize: function PDFWorker_initialize() {
<ide> // If worker support isn't disabled explicit and the browser has worker
<del> // support, create a new web worker and test if it/the browser fullfills
<add> // support, create a new web worker and test if it/the browser fulfills
<ide> // all requirements to run parts of pdf.js in a web worker.
<ide> // Right now, the requirement is, that an Uint8Array is still an
<ide> // Uint8Array as it arrives on the worker. (Chrome added this with v.15.) | 1 |
Python | Python | use simple suggester for spancat initialization | 09734c56fcbc76881b7d5bba18d1c9792a84abed | <ide><path>spacy/pipeline/spancat.py
<ide> def initialize(
<ide> self._require_labels()
<ide> if subbatch:
<ide> docs = [eg.x for eg in subbatch]
<del> spans = self.suggester(docs)
<add> spans = build_ngram_suggester(sizes=[1])(docs)
<ide> Y = self.model.ops.alloc2f(spans.dataXd.shape[0], len(self.labels))
<ide> self.model.initialize(X=(docs, spans), Y=Y)
<ide> else: | 1 |
Javascript | Javascript | show pending exception error in napi tests | 0c16b1804302046082ce5322b65e09a30172d606 | <ide><path>test/addons-napi/test_exception/test.js
<ide> const theError = new Error('Some error');
<ide>
<ide> // Test that the exception thrown above was marked as pending
<ide> // before it was handled on the JS side
<del> assert.strictEqual(test_exception.wasPending(), true,
<del> 'VM was marked as having an exception pending' +
<del> ' when it was allowed through');
<add> const exception_pending = test_exception.wasPending();
<add> assert.strictEqual(exception_pending, true,
<add> 'Exception not pending as expected,' +
<add> ` .wasPending() returned ${exception_pending}`);
<ide>
<ide> // Test that the native side does not capture a non-existing exception
<ide> returnedError = test_exception.returnException(common.mustCall());
<ide> const theError = new Error('Some error');
<ide> ` ${caughtError} was passed`);
<ide>
<ide> // Test that the exception state remains clear when no exception is thrown
<del> assert.strictEqual(test_exception.wasPending(), false,
<del> 'VM was not marked as having an exception pending' +
<del> ' when none was allowed through');
<add> const exception_pending = test_exception.wasPending();
<add> assert.strictEqual(exception_pending, false,
<add> 'Exception state did not remain clear as expected,' +
<add> ` .wasPending() returned ${exception_pending}`);
<ide> } | 1 |
Javascript | Javascript | switch assertequal arguments | 3545a3f83bb380474fcf69467b327cc8ea6d6873 | <ide><path>test/parallel/test-net-binary.js
<ide> echoServer.on('listening', function() {
<ide> });
<ide>
<ide> process.on('exit', function() {
<del> assert.strictEqual(2 * 256, recv.length);
<add> assert.strictEqual(recv.length, 2 * 256);
<ide>
<ide> const a = recv.split('');
<ide> | 1 |
Javascript | Javascript | reset enabled attributes list | 1729be414207740b8563d5212ee41f042dee4b26 | <ide><path>src/renderers/WebGLRenderer.js
<ide> THREE.WebGLRenderer = function ( parameters ) {
<ide>
<ide> _lightsNeedUpdate = true;
<ide>
<add> for ( var i = 0; i < _enabledAttributes.length; i ++ ) {
<add> _enabledAttributes[ i ] = 0;
<add> }
<ide> };
<ide>
<ide> setDefaultGLState(); | 1 |
Text | Text | fix spelling errors | ca8a157ad9988dca83c3fa52f165ec88bab18803 | <ide><path>guide/english/vue/index.md
<ide> title: Vue
<ide> ## Introduction
<ide>
<ide> Vue.js is a progressive framework for building user interfaces.
<del>Its core is focused on only the "view" layer and can be easily intergrated with existing libraries and projects.
<add>Its core is focused on only the "view" layer and can be easily integrated with existing libraries and projects.
<ide> But on the other hand, Vue.js can also be leveraged to create powerful single page applications by integrating with extensions
<ide> such as `vue-router` for page routing and `vuex` for state management.
<ide>
<del>It's main attributes are the following:
<add>Its main attributes are the following:
<ide> * It's approachable: if you know basic HTML, CSS & JavaScript - then you'll be writing apps in Vue.js in no time!
<ide> * It's versatile: you can use it as a simple library or a fully featured framework
<ide> * It's performant: it's extremely performant out of the box with very little to almost no optimization required.
<ide>
<ide> ### More Information
<ide>
<del>- [Vuejs Homepage](https://vuejs.org/)
<add>- [Vue.js Homepage](https://vuejs.org/)
<ide> - [GitHub Repo](https://github.com/vuejs/vue/)
<ide> - [Vue-Router](https://router.vuejs.org/)
<ide> - [Vuex](https://vuex.vuejs.org/) | 1 |
Python | Python | remove unused name kwarg in ec2 create_node | d8db8f61eb3b3d043c2df275dcf8a07f3187705d | <ide><path>libcloud/drivers/ec2.py
<ide> def create_node(self, **kwargs):
<ide> @keyword ex_userdata: User data
<ide> @type ex_userdata: C{str}
<ide> """
<del> name = kwargs["name"]
<ide> image = kwargs["image"]
<ide> size = kwargs["size"]
<ide> params = { | 1 |
PHP | PHP | improve equality check in consoleinputargument | 14651da764dd74a42623b2af8465cad80b4bce8e | <ide><path>src/Console/ConsoleInputArgument.php
<ide> public function name(): string
<ide> */
<ide> public function isEqualTo(ConsoleInputArgument $argument): bool
<ide> {
<del> return $this->usage() === $argument->usage();
<add> return $this->name() === $argument->name() &&
<add> $this->usage() === $argument->usage();
<ide> }
<ide>
<ide> /**
<ide><path>tests/TestCase/Console/ConsoleOptionParserTest.php
<ide> public function testOptionWithValueStartingWithMinus(): void
<ide> /**
<ide> * test positional argument parsing.
<ide> */
<del> public function testPositionalArgument(): void
<add> public function testAddArgument(): void
<ide> {
<ide> $parser = new ConsoleOptionParser('test', false);
<ide> $result = $parser->addArgument('name', ['help' => 'An argument']);
<ide> $this->assertEquals($parser, $result, 'Should return this');
<ide> }
<ide>
<add> /**
<add> * Add arguments that were once considered the same
<add> */
<add> public function testAddArgumentDuplicate(): void
<add> {
<add> $parser = new ConsoleOptionParser('test', false);
<add> $parser
<add> ->addArgument('first', ['help' => 'An argument', 'choices' => [1, 2]])
<add> ->addArgument('second', ['help' => 'An argument', 'choices' => [1, 2]]);
<add> $args = $parser->arguments();
<add> $this->assertCount(2, $args);
<add> $this->assertEquals('first', $args[0]->name());
<add> $this->assertEquals('second', $args[1]->name());
<add> }
<add>
<ide> /**
<ide> * test addOption with an object.
<ide> */ | 2 |
Ruby | Ruby | escape literal dot in regular expression | fe24f5880dfe0054b93f506cb3d4dcdaf9623993 | <ide><path>actionview/lib/action_view/helpers/asset_tag_helper.rb
<ide> def resolve_asset_source(asset_type, source, skip_pipeline)
<ide>
<ide> def extract_dimensions(size)
<ide> size = size.to_s
<del> if /\A(\d+|\d+.\d+)x(\d+|\d+.\d+)\z/.match?(size)
<add> if /\A\d+(?:\.\d+)?x\d+(?:\.\d+)?\z/.match?(size)
<ide> size.split("x")
<del> elsif /\A(\d+|\d+.\d+)\z/.match?(size)
<add> elsif /\A\d+(?:\.\d+)?\z/.match?(size)
<ide> [size, size]
<ide> end
<ide> end
<ide><path>actionview/test/template/asset_tag_helper_test.rb
<ide> def content_security_policy_nonce
<ide> %(image_tag("platinum.png", :size => "4.9x20")) => %(<img height="20" src="/images/platinum.png" width="4.9" />),
<ide> %(image_tag("platinum.png", "size" => "4.9x20")) => %(<img height="20" src="/images/platinum.png" width="4.9" />),
<ide> %(image_tag("error.png", "size" => "45 x 70")) => %(<img src="/images/error.png" />),
<add> %(image_tag("error.png", "size" => "1,024x768")) => %(<img src="/images/error.png" />),
<add> %(image_tag("error.png", "size" => "768x1,024")) => %(<img src="/images/error.png" />),
<ide> %(image_tag("error.png", "size" => "x")) => %(<img src="/images/error.png" />),
<ide> %(image_tag("google.com.png")) => %(<img src="/images/google.com.png" />),
<ide> %(image_tag("slash..png")) => %(<img src="/images/slash..png" />),
<ide> def content_security_policy_nonce
<ide> %(video_tag("error.avi", "size" => "100")) => %(<video height="100" src="/videos/error.avi" width="100"></video>),
<ide> %(video_tag("error.avi", "size" => 100)) => %(<video height="100" src="/videos/error.avi" width="100"></video>),
<ide> %(video_tag("error.avi", "size" => "100 x 100")) => %(<video src="/videos/error.avi"></video>),
<add> %(video_tag("error.avi", "size" => "1,024x768")) => %(<video src="/videos/error.avi"></video>),
<add> %(video_tag("error.avi", "size" => "768x1,024")) => %(<video src="/videos/error.avi"></video>),
<ide> %(video_tag("error.avi", "size" => "x")) => %(<video src="/videos/error.avi"></video>),
<ide> %(video_tag("http://media.rubyonrails.org/video/rails_blog_2.mov")) => %(<video src="http://media.rubyonrails.org/video/rails_blog_2.mov"></video>),
<ide> %(video_tag("//media.rubyonrails.org/video/rails_blog_2.mov")) => %(<video src="//media.rubyonrails.org/video/rails_blog_2.mov"></video>), | 2 |
Ruby | Ruby | use instance_eval, reduce method calls | 83ecd03e7d3472c16decbf1b9939da53347b36a3 | <ide><path>activerecord/lib/active_record/base.rb
<ide> def relation #:nodoc:
<ide> # single-table inheritance model that makes it possible to create
<ide> # objects of different types from the same table.
<ide> def instantiate(record)
<del> object = find_sti_class(record[inheritance_column]).allocate
<del>
<del> object.instance_variable_set(:@attributes, record)
<del> object.instance_variable_set(:@attributes_cache, {})
<del> object.instance_variable_set(:@new_record, false)
<del> object.instance_variable_set(:@readonly, false)
<del> object.instance_variable_set(:@destroyed, false)
<del> object.instance_variable_set(:@marked_for_destruction, false)
<del> object.instance_variable_set(:@previously_changed, {})
<del> object.instance_variable_set(:@changed_attributes, {})
<del>
<del> object.send(:_run_find_callbacks)
<del> object.send(:_run_initialize_callbacks)
<del>
<del> object
<add> find_sti_class(record[inheritance_column]).allocate.instance_eval do
<add> @attributes, @attributes_cache, @previously_changed, @changed_attributes = record, {}, {}, {}
<add> @new_record = @readonly = @destroyed = @marked_for_destruction = false
<add> _run_find_callbacks
<add> _run_initialize_callbacks
<add> self
<add> end
<ide> end
<ide>
<ide> def find_sti_class(type_name) | 1 |
Ruby | Ruby | use sandbox.formula? method | c6151951d6b685936adb8819db3957b12c95f5c9 | <ide><path>Library/Homebrew/cmd/postinstall.rb
<ide> def run_post_install(formula)
<ide> args << "--devel"
<ide> end
<ide>
<del> if Sandbox.available? && ARGV.sandbox?
<del> Sandbox.print_sandbox_message
<del> end
<add> Sandbox.print_sandbox_message if Sandbox.formula?(formula)
<ide>
<ide> Utils.safe_fork do
<del> if Sandbox.available? && ARGV.sandbox?
<add> if Sandbox.formula?(formula)
<ide> sandbox = Sandbox.new
<ide> formula.logs.mkpath
<ide> sandbox.record_log(formula.logs/"sandbox.postinstall.log") | 1 |
Mixed | PHP | fix paths in test/init.php | 57ecda858f62fb03f8439c177622582fff3f6784 | <ide><path>CONTRIBUTING.md
<add># How to contribute
<add>
<add>CakePHP loves to welcome your contributions. There are several ways to help out:
<add>* Create a ticket in Lighthouse, if you have found a bug
<add>* Write testcases for open bug tickets
<add>* Write patches for open bug/feature tickets, preferably with testcases included
<add>* Contribute to the [documentation](https://github.com/cakephp/docs)
<add>
<add>There are a few guidelines that we need contributors to follow so that we have a
<add>chance of keeping on top of things.
<add>
<add>## Getting Started
<add>
<add>* Make sure you have a [GitHub account](https://github.com/signup/free)
<add>* Submit a ticket for your issue, assuming one does not already exist.
<add> * Clearly describe the issue including steps to reproduce when it is a bug.
<add> * Make sure you fill in the earliest version that you know has the issue.
<add>* Fork the repository on GitHub.
<add>
<add>## Making Changes
<add>
<add>* Create a topic branch from where you want to base your work.
<add> * This is usually the master branch
<add> * Only target release branches if you are certain your fix must be on that
<add> branch
<add> * To quickly create a topic branch based on master; `git branch
<add> master/my_contribution master` then checkout the new branch with `git
<add> checkout master/my_contribution`. Better avoid working directly on the
<add> `master` branch, to avoid conflicts if you pull in updates from origin.
<add>* Make commits of logical units.
<add>* Check for unnecessary whitespace with `git diff --check` before committing.
<add>* Use descriptive commit messages and reference the #ticket number
<add>* Core testcases should continue to pass. You can run tests locally or enable
<add> [travis-ci](https://travis-ci.org/) for your fork, so all tests and codesniffs
<add> will be executed.
<add>* Your work should apply the CakePHP coding standards.
<add>
<add>## Which branch to base the work
<add>
<add>* Bugfix branches will be based on master.
<add>* New features that are backwards compatible will be based on next minor release
<add> branch.
<add>* New features or other non-BC changes will go in the next major release branch.
<add>
<add>## Submitting Changes
<add>
<add>* Push your changes to a topic branch in your fork of the repository.
<add>* Submit a pull request to the repository in the cakephp organization, with the
<add> correct target branch.
<add>
<add>## Testcases and codesniffer
<add>
<add>CakePHP tests requires [PHPUnit](http://www.phpunit.de/manual/current/en/installation.html)
<add>3.5 or higher. To run the testcases locally use the following command:
<add>
<add> ./lib/Cake/Console/cake test core AllTests --stderr
<add>
<add>To run the sniffs for CakePHP coding standards
<add>
<add> phpcs -p --extensions=php --standard=CakePHP ./lib/Cake
<add>
<add>Check the [cakephp-codesniffer](https://github.com/cakephp/cakephp-codesniffer)
<add>repository to setup the CakePHP standard. The README contains installation info
<add>for the sniff and phpcs.
<add>
<add>
<add># Additional Resources
<add>
<add>* [CakePHP coding standards](http://book.cakephp.org/2.0/en/contributing/cakephp-coding-conventions.html)
<add>* [Bug tracker](https://cakephp.lighthouseapp.com/projects/42648-cakephp)
<add>* [General GitHub documentation](https://help.github.com/)
<add>* [GitHub pull request documentation](https://help.github.com/send-pull-requests/)
<add>* #cakephp IRC channel on freenode.org
<ide><path>Cake/Test/init.php
<ide> use Cake\Log\Log;
<ide>
<ide> define('DS', DIRECTORY_SEPARATOR);
<del>define('ROOT', dirname(dirname(dirname(__DIR__))));
<add>define('ROOT', dirname(dirname(__DIR__)));
<ide> define('APP_DIR', 'App');
<ide> define('WEBROOT_DIR', 'webroot');
<ide>
<ide> define('TMP', sys_get_temp_dir() . DS);
<ide> define('LOGS', TMP . 'logs' . DS);
<ide> define('CACHE', TMP . 'cache' . DS);
<ide>
<del>define('CAKE_CORE_INCLUDE_PATH', ROOT . DS . 'lib');
<add>define('CAKE_CORE_INCLUDE_PATH', ROOT);
<ide> define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS);
<ide> define('CAKE', CORE_PATH . 'Cake' . DS);
<ide> define('CORE_TEST_CASES', CAKE . 'Test' . DS . 'TestCase'); | 2 |
Text | Text | add description of abstract class | e612f499c22a631756f5f58e266412e42288fe80 | <ide><path>guide/english/csharp/abstract-class/index.md
<add>---
<add>title : Abstract class
<add>---
<add>
<add>## Abstract class
<add>Abstract class is a class that has certain restrictions, it can't be instantiated directly. It's used as a base class for other types. An abstract class may contain abstract members (methods, properties, indexers and events). Abstract members can't be implemented in the abstract class and hence they must be overridden in a derived class.
<add>
<add>```csharp
<add>public abstract class Animal
<add>{
<add> public abstract void Walk();
<add>}
<add>
<add>public class Dog : Animal
<add>{
<add> public override void Walk()
<add> {
<add> Console.Log("Walking...");
<add> }
<add>}
<add>```
<add>
<add>As you see Animal abstract class contains abstract method that isn't implemented. Dog class inherits from Animal class so it must provide an implementation for all abstract members of that class.
<add>
<add>Abstract class may contain abstract members but it's not mandatory. Beyond abstract members it may also contain virtual members that can be overridden in a child class but it's not mandatory. If class contains virtual members then they unlike abstract members must be implemented (not only defined) in that class. Beyond virtual and abstract members abstract class may also contains non-virtual and non-abstract members that are derived and can't be overridden.
<add>
<add>```csharp
<add>public abstract class Animal
<add>{
<add> public abstract void Walk(); // abstract member - must be overridden
<add>
<add> public virtual void Run() // virtual member - may be overridden but doesn't need to
<add> {
<add> Console.WriteLine("Running...");
<add> }
<add>
<add> public void Wait() // non-abstract and non-virtual member - can't be overridden, may only be hidden
<add> {
<add> Console.WriteLine("Waiting...");
<add> }
<add>}
<add>
<add>public class Dog : Animal
<add>{
<add> public override void Walk() // it's mandatory to override abstract member
<add> {
<add> Console.WriteLine("Dog is walking...");
<add> }
<add>
<add> public override void Run() // it's optional to override virtual member
<add> {
<add> Console.WriteLine("Dog is running...");
<add> }
<add>}
<add>```
<add>
<add>We can't create object of Animal class because it's abstract but we can create object of Dog class that derives from Animal class:
<add>
<add>```csharp
<add>Dog dog = new Dog();
<add>dog.Walk(); // displays "Dog is walking..."
<add>dog.Run(); // displays "Dog is running..."
<add>dog.Wait(); // displays "Waiting..."
<add>``` | 1 |
Python | Python | add regression test for #825 | 84089298c0b55977cbf0c1ad79ec1f57b87b67a1 | <ide><path>numpy/core/tests/test_regression.py
<ide> def test_char_array_creation(self, level=rlevel):
<ide> b = np.array(['1','2','3'])
<ide> assert_equal(a,b)
<ide>
<add> def test_unaligned_unicode_access(self, level=rlevel) :
<add> """Ticket #825"""
<add> for i in range(1,9) :
<add> msg = 'unicode offset: %d chars'%i
<add> t = np.dtype([('a','S%d'%i),('b','U2')])
<add> x = np.array([('a',u'b')], dtype=t)
<add> assert_equal(str(x), "[('a', u'b')]", err_msg=msg)
<add>
<ide>
<ide> if __name__ == "__main__":
<ide> run_module_suite() | 1 |
Ruby | Ruby | convert `brew create` test to spec | 7f8cd184936e3419a5bf960121f76098505d6811 | <ide><path>Library/Homebrew/test/create_test.rb
<del>require "testing_env"
<del>
<del>class IntegrationCommandTestCreate < IntegrationCommandTestCase
<del> def test_create
<del> url = "file://#{TEST_FIXTURE_DIR}/tarballs/testball-0.1.tbz"
<del> cmd("create", url, "HOMEBREW_EDITOR" => "/bin/cat")
<del>
<del> formula_file = CoreTap.new.formula_dir/"testball.rb"
<del> assert formula_file.exist?, "The formula source should have been created"
<del> assert_match %Q(sha256 "#{TESTBALL_SHA256}"), formula_file.read
<del> end
<del>end
<ide><path>Library/Homebrew/test/dev-cmd/create_spec.rb
<add>describe "brew create", :integration_test do
<add> let(:url) { "file://#{TEST_FIXTURE_DIR}/tarballs/testball-0.1.tbz" }
<add> let(:formula_file) { CoreTap.new.formula_dir/"testball.rb" }
<add>
<add> it "creates a new Formula file for a given URL" do
<add> shutup do
<add> brew "create", url, "HOMEBREW_EDITOR" => "/bin/cat"
<add> end
<add>
<add> expect(formula_file).to exist
<add> expect(formula_file.read).to match(%Q(sha256 "#{TESTBALL_SHA256}"))
<add> end
<add>end | 2 |
PHP | PHP | remove useless check on $glue argument | 347ea002c07ee25f599ae525c8c972307f33cea2 | <ide><path>src/Illuminate/Support/Collection.php
<ide> public function has($key)
<ide> */
<ide> public function implode($value, $glue = null)
<ide> {
<del> if (is_null($glue)) return implode($this->lists($value));
<del>
<ide> return implode($glue, $this->lists($value));
<ide> }
<ide>
<ide><path>tests/Support/SupportCollectionTest.php
<ide> public function testImplode()
<ide> {
<ide> $data = new Collection(array(array('name' => 'taylor', 'email' => 'foo'), array('name' => 'dayle', 'email' => 'bar')));
<ide> $this->assertEquals('foobar', $data->implode('email'));
<add> $this->assertEquals('foobar', $data->implode('email', ''));
<add> $this->assertEquals('foobar', $data->implode('email', null));
<ide> $this->assertEquals('foo,bar', $data->implode('email', ','));
<ide> }
<ide> | 2 |
Java | Java | fix broken links to themeresolver in javadoc | 91bca55cbf6e764841ad2abcfd6a1b9690b2e4c0 | <ide><path>spring-webmvc/src/main/java/org/springframework/web/servlet/support/RequestContext.java
<ide> /*
<del> * Copyright 2002-2019 the original author or authors.
<add> * Copyright 2002-2022 the original author or authors.
<ide> *
<ide> * Licensed under the Apache License, Version 2.0 (the "License");
<ide> * you may not use this file except in compliance with the License.
<ide> protected org.springframework.ui.context.Theme getFallbackTheme() {
<ide>
<ide> /**
<ide> * Change the current theme to the specified one,
<del> * storing the new theme name through the configured {@link ThemeResolver}.
<add> * storing the new theme name through the configured
<add> * {@link org.springframework.web.servlet.ThemeResolver ThemeResolver}.
<ide> * @param theme the new theme
<del> * @see ThemeResolver#setThemeName
<add> * @see org.springframework.web.servlet.ThemeResolver#setThemeName
<ide> * @deprecated as of 6.0, with no direct replacement
<ide> */
<ide> @Deprecated
<ide> public void changeTheme(@Nullable org.springframework.ui.context.Theme theme) {
<ide>
<ide> /**
<ide> * Change the current theme to the specified theme by name,
<del> * storing the new theme name through the configured {@link ThemeResolver}.
<add> * storing the new theme name through the configured
<add> * {@link org.springframework.web.servlet.ThemeResolver ThemeResolver}.
<ide> * @param themeName the name of the new theme
<del> * @see ThemeResolver#setThemeName
<add> * @see org.springframework.web.servlet.ThemeResolver#setThemeName
<ide> */
<ide> @Deprecated
<ide> public void changeTheme(String themeName) { | 1 |
Javascript | Javascript | remove risky usages of "===" | 87066fa1ab893751e2842ab89d4b41c7bcc1fd6d | <ide><path>src/behavior/zoom.js
<ide> d3.behavior.zoom = function() {
<ide> }
<ide>
<ide> zoom.on = function(type, listener) {
<del> if (type === "zoom") listeners.push(listener);
<add> if (type == "zoom") listeners.push(listener);
<ide> return zoom;
<ide> };
<ide>
<ide><path>src/chart/bullet.js
<ide> d3.chart.bullet = function() {
<ide> bullet.orient = function(x) {
<ide> if (!arguments.length) return orient;
<ide> orient = x;
<del> reverse = orient === "right" || orient === "bottom";
<add> reverse = orient == "right" || orient == "bottom";
<ide> return bullet;
<ide> };
<ide> | 2 |
Javascript | Javascript | clarify some of the writing | 2adad3ab81a037f26220d72400487802dff737e0 | <ide><path>src/ng/directive/ngBind.js
<ide> * Typically, you don't use `ngBind` directly, but instead you use the double curly markup like
<ide> * `{{ expression }}` which is similar but less verbose.
<ide> *
<del> * One scenario in which the use of `ngBind` is preferred over `{{ expression }}` binding is when
<del> * it's desirable to put bindings into template that is momentarily displayed by the browser in its
<del> * raw state before Angular compiles it. Since `ngBind` is an element attribute, it makes the
<del> * bindings invisible to the user while the page is loading.
<add> * It is preferrable to use `ngBind` instead of `{{ expression }}` when a template is momentarily
<add> * displayed by the browser in its raw state before Angular compiles it. Since `ngBind` is an
<add> * element attribute, it makes the bindings invisible to the user while the page is loading.
<ide> *
<ide> * An alternative solution to this problem would be using the
<ide> * {@link ng.directive:ngCloak ngCloak} directive.
<ide> var ngBindDirective = ngDirective(function(scope, element, attr) {
<ide> *
<ide> * @description
<ide> * The `ngBindTemplate` directive specifies that the element
<del> * text should be replaced with the template in ngBindTemplate.
<del> * Unlike ngBind the ngBindTemplate can contain multiple `{{` `}}`
<del> * expressions. (This is required since some HTML elements
<del> * can not have SPAN elements such as TITLE, or OPTION to name a few.)
<add> * text content should be replaced with the interpolation of the template
<add> * in the `ngBindTemplate` attribute.
<add> * Unlike `ngBind`, the `ngBindTemplate` can contain multiple `{{` `}}`
<add> * expressions. This directive is needed since some HTML elements
<add> * (such as TITLE and OPTION) cannot contain SPAN elements.
<ide> *
<ide> * @element ANY
<ide> * @param {string} ngBindTemplate template of form | 1 |
Python | Python | commit some more fixes from the doc wiki | 821afc8f1376a634612e182903c06a0c9c556d94 | <ide><path>numpy/add_newdocs.py
<ide> out : dtype
<ide> The promoted data type.
<ide>
<add> See Also
<add> --------
<add> issctype, issubsctype, issubdtype, obj2sctype, sctype2char,
<add> maximum_sctype, min_scalar_type
<add>
<ide> Examples
<ide> --------
<ide> >>> np.promote_types('f4', 'f8')
<ide> Traceback (most recent call last):
<ide> File "<stdin>", line 1, in <module>
<ide> TypeError: invalid type promotion
<add>
<ide> """)
<ide>
<ide> add_newdoc('numpy.core.multiarray', 'min_scalar_type',
<ide> out : dtype
<ide> The minimal data type.
<ide>
<add>
<add> See Also
<add> --------
<add> issctype, issubsctype, issubdtype, obj2sctype, sctype2char,
<add> maximum_sctype, promote_types
<add>
<ide> Examples
<ide> --------
<ide> >>> np.min_scalar_type(10)
<ide> """))
<ide>
<ide>
<add>add_newdoc('numpy.core.multiarray', 'ndarray', ('dot',
<add> """
<add> a.dot(b, out=None)
<add>
<add> Dot product of two arrays.
<add>
<add> Refer to `numpy.dot` for full documentation.
<add>
<add> See Also
<add> --------
<add> numpy.dot : equivalent function
<add>
<add> Examples
<add> --------
<add> >>> a = np.eye(2)
<add> >>> b = np.ones((2, 2)) * 2
<add> >>> a.dot(b)
<add> array([[ 2., 2.],
<add> [ 2., 2.]])
<add>
<add> This array method can be conveniently chained:
<add>
<add> >>> a.dot(b).dot(b)
<add> array([[ 8., 8.],
<add> [ 8., 8.]])
<add>
<add> """))
<add>
<add>
<ide> add_newdoc('numpy.core.multiarray', 'ndarray', ('dump',
<ide> """a.dump(file)
<ide>
<ide> version of an array of dimensions ``dims``. Before version 1.6.0,
<ide> this function accepted just one index value.
<ide> dims : tuple of ints
<del> The shape of the array to use for unravelling ``indices``.
<add> The shape of the array to use for unraveling ``indices``.
<ide> order : {'C', 'F'}, optional
<ide> .. versionadded:: 1.6.0
<add>
<ide> Determines whether the indices should be viewed as indexing in
<ide> C (row-major) order or FORTRAN (column-major) order.
<ide>
<ide>
<ide> >>> np.unravel_index(1621, (6,7,8,9))
<ide> (3, 1, 4, 1)
<add>
<ide> """)
<ide>
<ide> add_newdoc('numpy.lib._compiled_base', 'add_docstring',
<ide><path>numpy/core/numerictypes.py
<ide> def issctype(rep):
<ide> >>> np.issctype(1.1)
<ide> False
<ide>
<add> Strings are also a scalar type:
<add>
<add> >>> np.issctype(np.dtype('str'))
<add> True
<add>
<ide> """
<ide> if not isinstance(rep, (type, dtype)):
<ide> return False
<ide><path>numpy/lib/function_base.py
<ide> def percentile(a, q, axis=None, out=None, overwrite_input=False):
<ide> a : array_like
<ide> Input array or object that can be converted to an array.
<ide> q : float in range of [0,100] (or sequence of floats)
<del> percentile to compute which must be between 0 and 100 inclusive
<del> axis : {None, int}, optional
<del> Axis along which the percentiles are computed. The default (axis=None)
<add> Percentile to compute which must be between 0 and 100 inclusive.
<add> axis : int, optional
<add> Axis along which the percentiles are computed. The default (None)
<ide> is to compute the median along a flattened version of the array.
<ide> out : ndarray, optional
<ide> Alternative output array in which to place the result. It must
<ide> have the same shape and buffer length as the expected output,
<ide> but the type (of the output) will be cast if necessary.
<del> overwrite_input : {False, True}, optional
<del> If True, then allow use of memory of input array (a) for
<add> overwrite_input : bool, optional
<add> If True, then allow use of memory of input array `a` for
<ide> calculations. The input array will be modified by the call to
<ide> median. This will save memory when you do not need to preserve
<ide> the contents of the input array. Treat the input as undefined,
<del> but it will probably be fully or partially sorted. Default is
<del> False. Note that, if `overwrite_input` is True and the input
<del> is not already an ndarray, an error will be raised.
<add> but it will probably be fully or partially sorted.
<add> Default is False. Note that, if `overwrite_input` is True and the
<add> input is not already an array, an error will be raised.
<ide>
<ide> Returns
<ide> -------
<ide> def percentile(a, q, axis=None, out=None, overwrite_input=False):
<ide> Notes
<ide> -----
<ide> Given a vector V of length N, the qth percentile of V is the qth ranked
<del> value in a sorted copy of V. A weighted average of the two nearest neighbors
<del> is used if the normalized ranking does not match q exactly.
<del> The same as the median if q is 0.5; the same as the min if q is 0;
<del> and the same as the max if q is 1
<add> value in a sorted copy of V. A weighted average of the two nearest
<add> neighbors is used if the normalized ranking does not match q exactly.
<add> The same as the median if ``q=0.5``, the same as the minimum if ``q=0``
<add> and the same as the maximum if ``q=1``.
<ide>
<ide> Examples
<ide> --------
<ide> def percentile(a, q, axis=None, out=None, overwrite_input=False):
<ide> array([ 6.5, 4.5, 2.5])
<ide> >>> np.percentile(a, 0.5, axis=1)
<ide> array([ 7., 2.])
<add>
<ide> >>> m = np.percentile(a, 0.5, axis=0)
<ide> >>> out = np.zeros_like(m)
<ide> >>> np.percentile(a, 0.5, axis=0, out=m)
<ide> array([ 6.5, 4.5, 2.5])
<ide> >>> m
<ide> array([ 6.5, 4.5, 2.5])
<add>
<ide> >>> b = a.copy()
<ide> >>> np.percentile(b, 0.5, axis=1, overwrite_input=True)
<ide> array([ 7., 2.])
<ide><path>numpy/lib/npyio.py
<ide> def savez_compressed(file, *args, **kwds):
<ide>
<ide> Parameters
<ide> ----------
<del> file : string
<add> file : str
<ide> File name of .npz file.
<ide> args : Arguments
<ide> Function arguments.
<ide><path>numpy/linalg/linalg.py
<ide> def slogdet(a):
<ide>
<ide> Parameters
<ide> ----------
<del> a : array_like, shape (M, M)
<del> Input array.
<add> a : array_like
<add> Input array, has to be a square 2-D array.
<ide>
<ide> Returns
<ide> -------
<ide> def slogdet(a):
<ide> The natural log of the absolute value of the determinant.
<ide>
<ide> If the determinant is zero, then `sign` will be 0 and `logdet` will be
<del> -Inf. In all cases, the determinant is equal to `sign * np.exp(logdet)`.
<add> -Inf. In all cases, the determinant is equal to ``sign * np.exp(logdet)``.
<add>
<add> See Also
<add> --------
<add> det
<ide>
<ide> Notes
<ide> -----
<ide> The determinant is computed via LU factorization using the LAPACK
<ide> routine z/dgetrf.
<ide>
<del> .. versionadded:: 2.0.0.
<add> .. versionadded:: 1.6.0.
<ide>
<ide> Examples
<ide> --------
<del> The determinant of a 2-D array [[a, b], [c, d]] is ad - bc:
<add> The determinant of a 2-D array ``[[a, b], [c, d]]`` is ``ad - bc``:
<ide>
<ide> >>> a = np.array([[1, 2], [3, 4]])
<ide> >>> (sign, logdet) = np.linalg.slogdet(a)
<ide> def slogdet(a):
<ide> >>> np.linalg.slogdet(np.eye(500) * 0.1)
<ide> (1, -1151.2925464970228)
<ide>
<del> See Also
<del> --------
<del> det
<del>
<ide> """
<ide> a = asarray(a)
<ide> _assertRank2(a) | 5 |
Mixed | Javascript | add abortsignal support to watch | 664cce92ec09363d5a37c9f2a360ee0810fe30e3 | <ide><path>doc/api/fs.md
<ide> this API: [`fs.utimes()`][].
<ide> <!-- YAML
<ide> added: v0.5.10
<ide> changes:
<add> - version: REPLACEME
<add> pr-url: https://github.com/nodejs/node/pull/37190
<add> description: Added support for closing the watcher with an AbortSignal.
<ide> - version: v7.6.0
<ide> pr-url: https://github.com/nodejs/node/pull/10739
<ide> description: The `filename` parameter can be a WHATWG `URL` object using
<ide> changes:
<ide> `false`.
<ide> * `encoding` {string} Specifies the character encoding to be used for the
<ide> filename passed to the listener. **Default:** `'utf8'`.
<add> * `signal` {AbortSignal} allows closing the watcher with an AbortSignal.
<ide> * `listener` {Function|undefined} **Default:** `undefined`
<ide> * `eventType` {string}
<ide> * `filename` {string|Buffer}
<ide> The listener callback is attached to the `'change'` event fired by
<ide> [`fs.FSWatcher`][], but it is not the same thing as the `'change'` value of
<ide> `eventType`.
<ide>
<add>If a `signal` is passed, aborting the corresponding AbortController will close
<add>the returned [`fs.FSWatcher`][].
<add>
<ide> ### Caveats
<ide>
<ide> <!--type=misc-->
<ide><path>lib/fs.js
<ide> function watch(filename, options, listener) {
<ide> if (listener) {
<ide> watcher.addListener('change', listener);
<ide> }
<add> if (options.signal) {
<add> if (options.signal.aborted) {
<add> process.nextTick(() => watcher.close());
<add> } else {
<add> const listener = () => watcher.close();
<add> options.signal.addEventListener('abort', listener);
<add> watcher.once('close', () => {
<add> options.signal.removeEventListener('abort', listener);
<add> });
<add> }
<add> }
<ide>
<ide> return watcher;
<ide> }
<ide><path>test/parallel/test-fs-watch-abort-signal.js
<add>// Flags: --expose-internals
<add>'use strict';
<add>
<add>// Verify that AbortSignal integration works for fs.watch
<add>
<add>const common = require('../common');
<add>
<add>if (common.isIBMi)
<add> common.skip('IBMi does not support `fs.watch()`');
<add>
<add>const fs = require('fs');
<add>const fixtures = require('../common/fixtures');
<add>
<add>
<add>{
<add> // Signal aborted after creating the watcher
<add> const file = fixtures.path('empty.js');
<add> const ac = new AbortController();
<add> const { signal } = ac;
<add> const watcher = fs.watch(file, { signal });
<add> watcher.once('close', common.mustCall());
<add> setImmediate(() => ac.abort());
<add>}
<add>{
<add> // Signal aborted before creating the watcher
<add> const file = fixtures.path('empty.js');
<add> const ac = new AbortController();
<add> const { signal } = ac;
<add> ac.abort();
<add> const watcher = fs.watch(file, { signal });
<add> watcher.once('close', common.mustCall());
<add>} | 3 |
Javascript | Javascript | fix breakages when upgrading to babel 6 | b907f40957bbd822cfab3a56d82363ffd58d2e78 | <ide><path>Libraries/Animated/src/Easing.js
<ide> */
<ide> 'use strict';
<ide>
<del>var bezier = require('bezier');
<add>var _bezier = require('bezier');
<ide>
<ide> /**
<ide> * This class implements common easing functions. The math is pretty obscure,
<ide> class Easing {
<ide> epsilon = (1000 / 60 / duration) / 4;
<ide> }
<ide>
<del> return bezier(x1, y1, x2, y2, epsilon);
<add> return _bezier(x1, y1, x2, y2, epsilon);
<ide> }
<ide>
<ide> static in(
<ide><path>local-cli/bundle/__tests__/saveBundleAndMap-test.js
<ide> */
<ide> 'use strict';
<ide>
<del>jest
<del> .dontMock('../saveBundleAndMap')
<del> .dontMock('os-tmpdir')
<del> .dontMock('temp');
<add>jest.autoMockOff();
<ide>
<ide> jest.mock('fs');
<add>jest.mock('../sign');
<ide>
<ide> const saveBundleAndMap = require('../saveBundleAndMap');
<ide> const fs = require('fs');
<ide><path>packager/react-packager/src/Bundler/index.js
<ide> class Bundler {
<ide> dev: isDev,
<ide> platform,
<ide> }) {
<del> const bundle = new Bundle(sourceMapUrl);
<add> // Const cannot have the same name as the method (babel/babel#2834)
<add> const bbundle = new Bundle(sourceMapUrl);
<ide> const findEventId = Activity.startEvent('find dependencies');
<ide> let transformEventId;
<ide>
<ide> class Bundler {
<ide> });
<ide> }
<ide>
<del> bundle.setMainModuleId(response.mainModuleId);
<add> bbundle.setMainModuleId(response.mainModuleId);
<ide> return Promise.all(
<ide> response.dependencies.map(
<ide> module => this._transformModule(
<del> bundle,
<add> bbundle,
<ide> response,
<ide> module,
<ide> platform
<ide> class Bundler {
<ide> Activity.endEvent(transformEventId);
<ide>
<ide> transformedModules.forEach(function(moduleTransport) {
<del> bundle.addModule(moduleTransport);
<add> bbundle.addModule(moduleTransport);
<ide> });
<ide>
<del> bundle.finalize({runBeforeMainModule, runMainModule});
<del> return bundle;
<add> bbundle.finalize({runBeforeMainModule, runMainModule});
<add> return bbundle;
<ide> });
<ide> }
<ide>
<ide><path>packager/react-packager/src/Cache/__tests__/Cache-test.js
<ide> jest
<ide> .dontMock('../../lib/getCacheFilePath');
<ide>
<ide> jest
<del> .mock('os')
<del> .mock('fs');
<add> .mock('fs')
<add> .setMock('os', {
<add> tmpDir() { return 'tmpDir'; }
<add> });
<ide>
<ide> var Promise = require('promise');
<ide> var fs = require('fs');
<del>var os = require('os');
<ide> var _ = require('underscore');
<ide>
<ide> var Cache = require('../');
<ide>
<ide> describe('JSTransformer Cache', () => {
<del> beforeEach(() => {
<del> os.tmpDir.mockImpl(() => 'tmpDir');
<del> });
<del>
<ide> describe('getting/setting', () => {
<ide> pit('calls loader callback for uncached file', () => {
<ide> fs.stat.mockImpl((file, callback) => {
<ide><path>packager/react-packager/src/transforms/babel-plugin-system-import/__tests__/babel-plugin-system-import-test.js
<ide> describe('System.import', () => {
<ide>
<ide> function transform(source) {
<ide> return babel.transform(source, {
<del> plugins: [require('../')],
<del> blacklist: ['strict'],
<del> extra: { bundlesLayout: layout },
<add> plugins: [
<add> [require('../'), { bundlesLayout: layout }]
<add> ],
<ide> }).code;
<ide> }
<ide>
<ide><path>packager/transformer.js
<ide> function transform(src, filename, options) {
<ide> 'transform-flow-strip-types',
<ide> 'transform-object-assign',
<ide> 'transform-object-rest-spread',
<add> 'transform-object-assign',
<ide> 'transform-react-display-name',
<ide> 'transform-react-jsx',
<ide> 'transform-regenerator', | 6 |
PHP | PHP | remove dependency on configure from cache | 1c3d82ef831dde184d91531bee936055edc0c328 | <ide><path>App/Config/cache.php
<ide> */
<ide> namespace App\Config;
<ide>
<del>use Cake\Core\Configure;
<add>use Cake\Cache\Cache;
<ide>
<ide> /**
<ide> * Turn off all caching application-wide.
<ide> */
<ide> //Configure::write('Cache.check', true);
<ide>
<add>/**
<add> * Enable cache view prefixes.
<add> *
<add> * If set it will be prepended to the cache name for view file caching. This is
<add> * helpful if you deploy the same application via multiple subdomains and languages,
<add> * for instance. Each version can then have its own view cache namespace.
<add> * Note: The final cache file name will then be `prefix_cachefilename`.
<add> */
<add> //Configure::write('Cache.viewPrefix', 'prefix');
<add>
<ide> // In development mode, caches should expire quickly.
<ide> $duration = '+999 days';
<ide> if (Configure::read('debug') >= 1) {
<ide> // Prefix each application on the same server with a different string, to avoid Memcache and APC conflicts.
<ide> $prefix = 'myapp_';
<ide>
<add>
<add>$cacheConfigs = [];
<add>
<ide> /**
<ide> * Configure the cache used for general framework caching. Path information,
<ide> * object listings, and translation cache files are stored with this configuration.
<ide> */
<del>Configure::write('Cache._cake_core_', [
<add>$cacheConfigs['_cake_core_'] = [
<ide> 'engine' => $engine,
<ide> 'prefix' => $prefix . 'cake_core_',
<ide> 'path' => CACHE . 'persistent' . DS,
<ide> 'serialize' => ($engine === 'File'),
<ide> 'duration' => $duration
<del>]);
<add>];
<add>
<ide>
<ide> /**
<ide> * Configure the cache for model and datasource caches. This cache configuration
<ide> * is used to store schema descriptions, and table listings in connections.
<ide> */
<del>Configure::write('Cache._cake_model_', [
<add>$cacheConfigs['_cake_model_'] = [
<ide> 'engine' => $engine,
<ide> 'prefix' => $prefix . 'cake_model_',
<ide> 'path' => CACHE . 'models' . DS,
<ide> 'serialize' => ($engine === 'File'),
<ide> 'duration' => $duration
<del>]);
<add>];
<ide>
<ide> /**
<ide> * Cache Engine Configuration
<ide> * 'persistent' => true, // [optional] set this to false for non-persistent connections
<ide> * ));
<ide> */
<del>Configure::write('Cache.default', array('engine' => 'File'));
<add>$cacheConfigs['default'] = [
<add> 'engine' => 'File'
<add>];
<ide>
<del>/**
<del> * Enable cache view prefixes.
<del> *
<del> * If set it will be prepended to the cache name for view file caching. This is
<del> * helpful if you deploy the same application via multiple subdomains and languages,
<del> * for instance. Each version can then have its own view cache namespace.
<del> * Note: The final cache file name will then be `prefix_cachefilename`.
<del> */
<del> //Configure::write('Cache.viewPrefix', 'prefix');
<add>Cache::config($cacheConfigs);
<ide><path>lib/Cake/Cache/Cache.php
<ide> * A sample configuration would be:
<ide> *
<ide> * {{{
<del> * Configure::write('Cache.shared', array(
<add> * Cache::config('shared', array(
<ide> * 'engine' => 'Cake\Cache\Engine\ApcEngine',
<ide> * 'prefix' => 'my_app_'
<ide> * ));
<ide> class Cache {
<ide>
<ide> /**
<del> * Cache configuration stack
<add> * Configuraiton backup.
<add> *
<add> * Keeps the permanent/default settings for each cache engine.
<add> * These settings are used to reset the engines after temporary modification.
<add> *
<add> * @var array
<add> */
<add> protected static $_restore = array();
<add>
<add>/**
<add> * Cache configuration.
<add> *
<ide> * Keeps the permanent/default settings for each cache engine.
<ide> * These settings are used to reset the engines after temporary modification.
<ide> *
<ide> class Cache {
<ide> protected static $_reset = false;
<ide>
<ide> /**
<del> * Engine instances keyed by configuration name.
<add> * Cache Registry used for creating and using cache adapters.
<ide> *
<del> * @var array
<add> * @var Cake\Cache\CacheRegistry
<ide> */
<del> protected static $_engines = array();
<add> protected static $_registry;
<ide>
<ide> /**
<del> * Deprecated method. Will be removed in 3.0.0
<add> * This method can be used to define cache adapters for an application
<add> * during the bootstrapping process. You can use this method to add new cache adapters
<add> * at runtime as well. New cache configurations will be constructed upon the next write.
<add> *
<add> * To change an adapter's configuration at runtime, first drop the adapter and then
<add> * reconfigure it.
<ide> *
<del> * @deprecated
<add> * Adapters will not be constructed until the first operation is done.
<add> *
<add> * @param string|array $key The name of the cache config, or an array of multiple configs.
<add> * @param array $config An array of name => config data for adapter.
<add> * @return void
<ide> */
<del> public static function config($name = null, $settings = array()) {
<del> trigger_error(
<del> __d('cake_dev', 'You must use Configure::write() to define cache configuration. Or use engine() to inject new adapter.'),
<del> E_USER_WARNING
<del> );
<add> public static function config($key, $config = null) {
<add> if ($config !== null && is_string($key)) {
<add> static::$_config[$key] = $config;
<add> return;
<add> }
<add> static::$_config = array_merge(static::$_config, $key);
<ide> }
<ide>
<ide> /**
<ide> public static function config($name = null, $settings = array()) {
<ide> * @throws Cake\Error\Exception
<ide> */
<ide> protected static function _buildEngine($name) {
<del> $config = Configure::read('Cache.' . $name);
<del> if (empty($config['engine'])) {
<del> return false;
<del> }
<del> $cacheClass = App::classname($config['engine'], 'Cache/Engine', 'Engine');
<del> if (!$cacheClass) {
<del> throw new Error\Exception(
<del> __d('cake_dev', 'Cache engine %s is not available.', $name)
<del> );
<del> }
<del> if (!is_subclass_of($cacheClass, 'Cake\Cache\CacheEngine')) {
<del> throw new Error\Exception(__d('cake_dev', 'Cache engines must use Cake\Cache\CacheEngine as a base class.'));
<del> }
<del> $engine = new $cacheClass();
<del> if (!$engine->init($config)) {
<del> throw new Error\Exception(
<del> __d('cake_dev', 'Cache engine %s is not properly configured.', $name)
<del> );
<add> if (empty(static::$_registry)) {
<add> static::$_registry = new CacheRegistry();
<ide> }
<del> if ($engine->settings['probability'] && time() % $engine->settings['probability'] === 0) {
<del> $engine->gc();
<add> if (empty(static::$_config[$name]['engine'])) {
<add> return false;
<ide> }
<del> static::$_engines[$name] = $engine;
<add> $config = static::$_config[$name];
<add> $config['className'] = $config['engine'];
<add>
<add> static::$_registry->load($name, $config);
<ide>
<ide> if (!empty($config['groups'])) {
<ide> foreach ($config['groups'] as $group) {
<ide> static::$_groups[$group][] = $name;
<del> sort(static::$_groups[$group]);
<ide> static::$_groups[$group] = array_unique(static::$_groups[$group]);
<add> sort(static::$_groups[$group]);
<ide> }
<ide> }
<ide>
<ide> return true;
<ide> }
<ide>
<ide> /**
<del> * Returns an array containing the connected Cache engines.
<del> * This will not return engines that are configured, but have not
<del> * been used yet.
<add> * Returns an array containing the configured Cache engines.
<ide> *
<del> * @return array Array of connected Cache config names.
<add> * @return array Array of configured Cache config names.
<ide> */
<ide> public static function configured() {
<del> return array_keys(static::$_engines);
<add> return array_keys(static::$_config);
<ide> }
<ide>
<ide> /**
<ide> public static function configured() {
<ide> * @return boolean success of the removal, returns false when the config does not exist.
<ide> */
<ide> public static function drop($config) {
<del> if (isset(static::$_engines[$config])) {
<del> unset(static::$_engines[$config]);
<del> unset(static::$_config[$config]);
<del> return true;
<add> if (!isset(static::$_registry->{$config})) {
<add> return false;
<ide> }
<del> return false;
<add> static::$_registry->unload($config);
<add> unset(static::$_config[$config], static::$_restore[$config]);
<add> return true;
<ide> }
<ide>
<ide> /**
<ide> * Fetch the engine attached to a specific configuration name.
<del> * If the engine does not exist, configuration data will be read from
<del> * `Configure`.
<ide> *
<ide> * If the cache engine & configuration are missing an error will be
<ide> * triggered.
<ide> *
<del> * @param string $config The configuration name you want an engine.
<del> * @param Cake\Cache\CacheEngine $engine An engine instance if you are manually
<del> * injecting a cache engine.
<add> * @param string $config The configuration name you want an engine for.
<ide> * @return Cake\Cache\Engine
<ide> */
<del> public static function engine($config, CacheEngine $engine = null) {
<add> public static function engine($config) {
<ide> if (Configure::read('Cache.disable')) {
<ide> return false;
<ide> }
<del> if (isset(static::$_engines[$config])) {
<del> return static::$_engines[$config];
<add> if (isset(static::$_registry->{$config})) {
<add> return static::$_registry->{$config};
<ide> }
<del> if (!$engine && !static::_buildEngine($config, $engine)) {
<add> if (!static::_buildEngine($config)) {
<ide> $message = __d(
<ide> 'cake_dev',
<del> 'The "%s" cache configuration does not exist, nor could configuration be found at "Cache.%s".',
<del> $config,
<add> 'The "%s" cache configuration does not exist.',
<ide> $config
<ide> );
<ide> trigger_error($message, E_USER_WARNING);
<ide> }
<del> if ($engine) {
<del> static::$_engines[$config] = $engine;
<del> }
<del> return static::$_engines[$config];
<add> return static::$_registry->{$config};
<ide> }
<ide>
<ide> /**
<ide> public static function set($settings = array(), $value = null, $config = 'defaul
<ide> return false;
<ide> }
<ide>
<del> if (empty(static::$_config[$config])) {
<del> static::$_config[$config] = $engine->settings();
<add> if (empty(static::$_restore[$config])) {
<add> static::$_restore[$config] = $engine->settings();
<ide> }
<ide>
<ide> if (!empty($settings)) {
<ide> public static function set($settings = array(), $value = null, $config = 'defaul
<ide> * @return void
<ide> */
<ide> protected static function _modifySettings($engine, $config, $settings) {
<del> $restore = static::$_config[$config];
<add> $restore = static::$_restore[$config];
<ide> if (empty($settings)) {
<ide> static::$_reset = false;
<ide> $settings = $restore;
<del> unset(static::$_config[$config]);
<add> unset(static::$_restore[$config]);
<ide> } else {
<ide> $settings = array_merge($restore, $settings);
<ide> if (isset($settings['duration']) && !is_numeric($settings['duration'])) {
<ide><path>lib/Cake/Cache/CacheRegistry.php
<add><?php
<add>/**
<add> * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
<add> * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
<add> *
<add> * Licensed under The MIT License
<add> * For full copyright and license information, please see the LICENSE.txt
<add> * Redistributions of files must retain the above copyright notice.
<add> *
<add> * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
<add> * @link http://cakephp.org CakePHP(tm) Project
<add> * @license http://www.opensource.org/licenses/mit-license.php MIT License
<add> */
<add>namespace Cake\Cache;
<add>
<add>use Cake\Core\App;
<add>use Cake\Error;
<add>use Cake\Utility\ObjectRegistry;
<add>
<add>/**
<add> * An object registry for cache engines.
<add> *
<add> * Used by Cake\Cache\Cache to load and manage cache engines.
<add> *
<add> * @since CakePHP 3.0
<add> */
<add>class CacheRegistry extends ObjectRegistry {
<add>
<add>/**
<add> * Resolve a cache engine classname.
<add> *
<add> * Part of the template method for Cake\Utility\ObjectRegistry::load()
<add> *
<add> * @param string $class Partial classname to resolve.
<add> * @return string|false Either the correct classname or false.
<add> */
<add> protected function _resolveClassName($class) {
<add> if (is_object($class)) {
<add> return $class;
<add> }
<add> return App::classname($class, 'Cache/Engine', 'Engine');
<add> }
<add>
<add>/**
<add> * Throws an exception when a cache engine is missing.
<add> *
<add> * Part of the template method for Cake\Utility\ObjectRegistry::load()
<add> *
<add> * @param string $class The classname that is missing.
<add> * @param string $plugin The plugin the cache is missing in.
<add> * @throws Cake\Error\Exception
<add> */
<add> protected function _throwMissingClassError($class, $plugin) {
<add> throw new Error\Exception(__d('cake_dev', 'Cache engine %s is not available.', $class));
<add> }
<add>
<add>/**
<add> * Create the cache engine instance.
<add> *
<add> * Part of the template method for Cake\Utility\ObjectRegistry::load()
<add> * @param string|CacheEngine $class The classname or object to make.
<add> * @param array $settings An array of settings to use for the cache engine.
<add> * @return CacheEngine The constructed CacheEngine class.
<add> * @throws Cake\Error\Exception when an object doesn't implement
<add> * the correct interface.
<add> */
<add> protected function _create($class, $settings) {
<add> if (is_object($class)) {
<add> $instance = $class;
<add> }
<add> unset($settings['engine'], $settings['className']);
<add> if (!isset($instance)) {
<add> $instance = new $class($settings);
<add> }
<add> if (!($instance instanceof CacheEngine)) {
<add> throw new Error\Exception(__d(
<add> 'cake_dev',
<add> 'Cache engines must use Cake\Cache\CacheEngine as a base class.'
<add> ));
<add> }
<add> if (!$instance->init($settings)) {
<add> throw new Error\Exception(
<add> __d('cake_dev', 'Cache engine %s is not properly configured.', $class)
<add> );
<add> }
<add> if ($instance->settings['probability'] && time() % $instance->settings['probability'] === 0) {
<add> $instance->gc();
<add> }
<add> return $instance;
<add> }
<add>
<add>/**
<add> * Remove a single adapter from the registry.
<add> *
<add> * @param string $name The adapter name.
<add> * @return void
<add> */
<add> public function unload($name) {
<add> unset($this->_loaded[$name]);
<add> }
<add>
<add>
<add>}
<ide><path>lib/Cake/Test/TestCase/Cache/CacheTest.php
<ide> public function setUp() {
<ide> parent::setUp();
<ide> Configure::write('Cache.disable', false);
<ide>
<del> Configure::write('Cache.default', [
<add> Cache::drop('tests');
<add> Cache::config('default', [
<ide> 'engine' => 'File',
<ide> 'path' => TMP . 'tests'
<ide> ]);
<ide> public function testEngine() {
<ide> 'path' => TMP . 'tests',
<ide> 'prefix' => 'cake_test_'
<ide> ];
<del> Configure::write('Cache.test_config', $settings);
<del> $engine = Cache::engine('test_config');
<add> Cache::config('tests', $settings);
<add> $engine = Cache::engine('tests');
<ide> $this->assertInstanceOf('Cake\Cache\Engine\FileEngine', $engine);
<ide> }
<ide>
<ide> public function testEngine() {
<ide> */
<ide> public function testConfigInvalidEngine() {
<ide> $settings = array('engine' => 'Imaginary');
<del> Configure::write('Cache.imaginary', $settings);
<del> Cache::engine('imaginary');
<add> Cache::config('tests', $settings);
<add> Cache::engine('tests');
<ide> }
<ide>
<ide> /**
<ide> public function testConfigInvalidEngine() {
<ide> */
<ide> public function testNonFatalErrorsWithCachedisable() {
<ide> Configure::write('Cache.disable', true);
<del> Configure::write('Cache.test', [
<add> Cache::config('tests', [
<ide> 'engine' => 'File',
<ide> 'path' => TMP, 'prefix' => 'error_test_'
<ide> ]);
<ide>
<del> Cache::write('no_save', 'Noooo!', 'test');
<del> Cache::read('no_save', 'test');
<del> Cache::delete('no_save', 'test');
<add> Cache::write('no_save', 'Noooo!', 'tests');
<add> Cache::read('no_save', 'tests');
<add> Cache::delete('no_save', 'tests');
<ide> Cache::set('duration', '+10 minutes');
<del>
<del> Configure::write('Cache.disable', false);
<ide> }
<ide>
<ide> /**
<ide> public function testConfigWithLibAndPluginEngines() {
<ide> Plugin::load('TestPlugin');
<ide>
<ide> $settings = ['engine' => 'TestAppCache', 'path' => TMP, 'prefix' => 'cake_test_'];
<del> Configure::write('Cache.libEngine', $settings);
<add> Cache::config('libEngine', $settings);
<ide> $engine = Cache::engine('libEngine');
<ide> $this->assertInstanceOf('\TestApp\Cache\Engine\TestAppCacheEngine', $engine);
<ide>
<ide> $settings = ['engine' => 'TestPlugin.TestPluginCache', 'path' => TMP, 'prefix' => 'cake_test_'];
<del> $result = Configure::write('Cache.pluginLibEngine', $settings);
<add> $result = Cache::config('pluginLibEngine', $settings);
<ide> $engine = Cache::engine('pluginLibEngine');
<ide> $this->assertInstanceOf('\TestPlugin\Cache\Engine\TestPluginCacheEngine', $engine);
<ide>
<ide> public function testConfigWithLibAndPluginEngines() {
<ide> */
<ide> public function testInvalidConfig() {
<ide> // In debug mode it would auto create the folder.
<del> $debug = Configure::read('debug');
<ide> Configure::write('debug', 0);
<ide>
<del> Cache::config('invalid', array(
<add> Cache::config('tests', array(
<ide> 'engine' => 'File',
<ide> 'duration' => '+1 year',
<ide> 'prefix' => 'testing_invalid_',
<ide> 'path' => 'data/',
<ide> 'serialize' => true,
<del> 'random' => 'wii'
<ide> ));
<del> Cache::read('Test', 'invalid');
<del>
<del> Configure::write('debug', $debug);
<add> Cache::read('Test', 'tests');
<ide> }
<ide>
<ide> /**
<ide> public function testDecrementNonExistingConfig() {
<ide> */
<ide> public function testAttemptingToConfigureANonCacheEngineClass() {
<ide> $this->getMock('\StdClass', array(), array(), 'RubbishEngine');
<del> Configure::write('Cache.wrong', array(
<add> Cache::config('tests', array(
<ide> 'engine' => '\RubbishEngine'
<ide> ));
<del> Cache::engine('wrong');
<add> Cache::engine('tests');
<ide> }
<ide>
<ide> /**
<ide> public function testAttemptingToConfigureANonCacheEngineClass() {
<ide> */
<ide> public function testSetEngineValid() {
<ide> $engine = $this->getMockForAbstractClass('\Cake\Cache\CacheEngine');
<del> Cache::engine('test', $engine);
<add> Cache::config('test', ['engine' => $engine]);
<ide> $this->assertSame($engine, Cache::engine('test'));
<ide> }
<ide>
<ide> public function testSetEngineValid() {
<ide> * @return void
<ide> */
<ide> public function testConfigSettingDefaultConfigKey() {
<del> Configure::write('Cache.test_name', [
<add> Cache::config('tests', [
<ide> 'engine' => 'File',
<del> 'prefix' => 'test_name_'
<add> 'prefix' => 'tests_'
<ide> ]);
<ide>
<del> Cache::write('value_one', 'I am cached', 'test_name');
<del> $result = Cache::read('value_one', 'test_name');
<add> Cache::write('value_one', 'I am cached', 'tests');
<add> $result = Cache::read('value_one', 'tests');
<ide> $this->assertEquals('I am cached', $result);
<ide>
<ide> $result = Cache::read('value_one');
<ide> public function testConfigSettingDefaultConfigKey() {
<ide> $result = Cache::read('value_one');
<ide> $this->assertEquals('I am in default config!', $result);
<ide>
<del> $result = Cache::read('value_one', 'test_name');
<add> $result = Cache::read('value_one', 'tests');
<ide> $this->assertEquals('I am cached', $result);
<ide>
<del> Cache::delete('value_one', 'test_name');
<add> Cache::delete('value_one', 'tests');
<ide> Cache::delete('value_one', 'default');
<ide> }
<ide>
<ide> /**
<ide> * testGroupConfigs method
<ide> */
<ide> public function testGroupConfigs() {
<del> Configure::write('Cache.latest', [
<add> Cache::config('latest', [
<ide> 'duration' => 300,
<ide> 'engine' => 'File',
<ide> 'groups' => ['posts', 'comments'],
<ide> public function testGroupConfigs() {
<ide> $result = Cache::groupConfigs('posts');
<ide> $this->assertEquals(['posts' => ['latest']], $result);
<ide>
<del> Configure::write('Cache.page', [
<add> Cache::config('page', [
<ide> 'duration' => 86400,
<ide> 'engine' => 'File',
<ide> 'groups' => ['posts', 'archive'],
<ide> public function testGroupConfigs() {
<ide> $result = Cache::groupConfigs('archive');
<ide> $this->assertEquals(['archive' => ['page']], $result);
<ide>
<del> Configure::write('Cache.archive', [
<add> Cache::config('archive', [
<ide> 'duration' => 86400 * 30,
<ide> 'engine' => 'File',
<ide> 'groups' => ['posts', 'archive', 'comments'],
<ide> public function testConfigured() {
<ide> $result = Cache::configured();
<ide> $this->assertContains('_cake_core_', $result);
<ide> $this->assertNotContains('default', $result, 'Unconnected engines should not display.');
<del>
<del> Cache::engine('default');
<del> $result = Cache::configured();
<del> $this->assertContains('default', $result, 'default should exist now.');
<ide> }
<ide>
<ide> /**
<ide> public function testDrop() {
<ide> $result = Cache::drop('default');
<ide> $this->assertTrue($result, 'Built engines should be dropped');
<ide>
<del> $config = Configure::read('Cache.default');
<del> $this->assertEquals('File', $config['engine'], 'Config data should not be removed.');
<del>
<del> Configure::write('Cache.unconfigTest', [
<add> Cache::config('unconfigTest', [
<ide> 'engine' => 'TestAppCache'
<ide> ]);
<ide> $this->assertInstanceOf(
<ide> public function testDrop() {
<ide> * @return void
<ide> */
<ide> public function testDropChangeConfig() {
<del> Configure::write('Cache.tests', [
<add> Cache::config('tests', [
<ide> 'engine' => 'File',
<ide> ]);
<ide> $result = Cache::engine('tests');
<ide> public function testDropChangeConfig() {
<ide>
<ide> Cache::drop('tests');
<ide>
<del> Configure::write('Cache.tests', [
<add> Cache::config('tests', [
<ide> 'engine' => 'File',
<ide> 'extra' => 'value'
<ide> ]);
<ide> public function testWriteTriggerError() {
<ide> 'Plugin' => array(CAKE . 'Test/TestApp/Plugin/')
<ide> ), App::RESET);
<ide> Configure::write('App.namespace', 'TestApp');
<del> Configure::write('Cache.test_trigger', [
<add> Cache::config('test_trigger', [
<ide> 'engine' => 'TestAppCache',
<ide> 'prefix' => ''
<ide> ]);
<ide> public function testWriteTriggerError() {
<ide> */
<ide> public function testCacheDisable() {
<ide> Configure::write('Cache.disable', false);
<del> Configure::write('Cache.test_cache_disable_1', [
<add> Cache::config('test_cache_disable_1', [
<ide> 'engine' => 'File',
<ide> 'path' => TMP . 'tests'
<ide> ]);
<ide> public function testCacheDisable() {
<ide> $this->assertSame(Cache::read('key_3', 'test_cache_disable_1'), 'hello');
<ide>
<ide> Configure::write('Cache.disable', true);
<del> Configure::write('Cache.test_cache_disable_2', [
<add> Cache::config('test_cache_disable_2', [
<ide> 'engine' => 'File',
<ide> 'path' => TMP . 'tests'
<ide> ]);
<ide> public function testSet() {
<ide> * @return void
<ide> */
<ide> public function testSetModifySettings() {
<del> Configure::write('Cache.tests', [
<add> Cache::config('tests', [
<ide> 'engine' => 'File',
<ide> 'duration' => '+1 minute'
<ide> ]);
<del> Cache::drop('tests');
<ide>
<ide> $result = Cache::set(['duration' => '+1 year'], 'tests');
<ide> $this->assertEquals(strtotime('+1 year') - time(), $result['duration']);
<ide> public function testSetModifySettings() {
<ide> * @return void
<ide> */
<ide> public function testSetModifyAndResetSettings() {
<del> Configure::write('Cache.tests', [
<add> Cache::config('tests', [
<ide> 'engine' => 'File',
<ide> 'duration' => '+1 minute'
<ide> ]);
<del> Cache::drop('tests');
<ide> $result = Cache::set('duration', '+1 year', 'tests');
<ide> $this->assertEquals(strtotime('+1 year') - time(), $result['duration']);
<ide>
<ide> public function testSetModifyAndResetSettings() {
<ide> * @return void
<ide> */
<ide> public function testSetOnAlternateConfigs() {
<del> Configure::write('Cache.file_config', [
<add> Cache::config('file_config', [
<ide> 'engine' => 'File',
<ide> 'prefix' => 'test_file_'
<ide> ]);
<ide><path>lib/Cake/Test/TestCase/Cache/Engine/ApcEngineTest.php
<ide> public function setUp() {
<ide> }
<ide>
<ide> Configure::write('Cache.disable', false);
<del> Configure::write('Cache.apc', ['engine' => 'Apc', 'prefix' => 'cake_']);
<add> Cache::config('apc', ['engine' => 'Apc', 'prefix' => 'cake_']);
<ide> }
<ide>
<ide> /**
<ide> public function testReadAndWriteCache() {
<ide> * @return void
<ide> */
<ide> public function testReadWriteDurationZero() {
<del> Configure::write('apc', ['engine' => 'Apc', 'duration' => 0, 'prefix' => 'cake_']);
<add> Cache::config('apc', ['engine' => 'Apc', 'duration' => 0, 'prefix' => 'cake_']);
<ide> Cache::write('zero', 'Should save', 'apc');
<ide> sleep(1);
<ide>
<ide> public function testClear() {
<ide> * @return void
<ide> */
<ide> public function testGroupsReadWrite() {
<del> Configure::write('Cache.apc_groups', [
<add> Cache::config('apc_groups', [
<ide> 'engine' => 'Apc',
<ide> 'duration' => 0,
<ide> 'groups' => array('group_a', 'group_b'),
<ide> public function testGroupsReadWrite() {
<ide> * @return void
<ide> */
<ide> public function testGroupDelete() {
<del> Configure::write('Cache.apc_groups', array(
<add> Cache::config('apc_groups', array(
<ide> 'engine' => 'Apc',
<ide> 'duration' => 0,
<ide> 'groups' => array('group_a', 'group_b'),
<ide> public function testGroupDelete() {
<ide> * @return void
<ide> */
<ide> public function testGroupClear() {
<del> Configure::write('Cache.apc_groups', array(
<add> Cache::config('apc_groups', array(
<ide> 'engine' => 'Apc',
<ide> 'duration' => 0,
<ide> 'groups' => array('group_a', 'group_b'),
<ide><path>lib/Cake/Test/TestCase/Cache/Engine/FileEngineTest.php
<ide> class FileEngineTest extends TestCase {
<ide> public function setUp() {
<ide> parent::setUp();
<ide> Configure::write('Cache.disable', false);
<del> Configure::write('Cache.file_test', [
<add> Cache::config('file_test', [
<ide> 'engine' => 'File',
<ide> 'path' => CACHE
<ide> ]);
<ide> public function testDeleteCache() {
<ide> * @return void
<ide> */
<ide> public function testSerialize() {
<del> Configure::write('Cache.file_test', ['engine' => 'File', 'serialize' => true]);
<add> Cache::config('file_test', ['engine' => 'File', 'serialize' => true]);
<ide> $data = 'this is a test of the emergency broadcasting system';
<ide> $write = Cache::write('serialize_test', $data, 'file_test');
<ide> $this->assertTrue($write);
<ide> public function testSerialize() {
<ide> * @return void
<ide> */
<ide> public function testClear() {
<del> Configure::write('Cache.file_test', ['engine' => 'File', 'duration' => 1]);
<add> Cache::config('file_test', ['engine' => 'File', 'duration' => 1]);
<ide>
<ide> $data = 'this is a test of the emergency broadcasting system';
<ide> $write = Cache::write('serialize_test1', $data, 'file_test');
<ide> public function testKeyPath() {
<ide> * @return void
<ide> */
<ide> public function testRemoveWindowsSlashesFromCache() {
<del> Configure::write('Cache.windows_test', [
<add> Cache::config('windows_test', [
<ide> 'engine' => 'File',
<ide> 'isWindows' => true,
<ide> 'prefix' => null,
<ide> public function testRemoveWindowsSlashesFromCache() {
<ide> * @return void
<ide> */
<ide> public function testWriteQuotedString() {
<del> Configure::write('Cache.file_test', array('engine' => 'File', 'path' => TMP . 'tests'));
<add> Cache::config('file_test', array('engine' => 'File', 'path' => TMP . 'tests'));
<ide> Cache::write('App.doubleQuoteTest', '"this is a quoted string"', 'file_test');
<ide> $this->assertSame(Cache::read('App.doubleQuoteTest', 'file_test'), '"this is a quoted string"');
<ide> Cache::write('App.singleQuoteTest', "'this is a quoted string'", 'file_test');
<ide> $this->assertSame(Cache::read('App.singleQuoteTest', 'file_test'), "'this is a quoted string'");
<ide>
<del> Configure::write('Cache.file_test', array('isWindows' => true, 'path' => TMP . 'tests'));
<add> Cache::config('file_test', array('isWindows' => true, 'path' => TMP . 'tests'));
<ide> $this->assertSame(Cache::read('App.doubleQuoteTest', 'file_test'), '"this is a quoted string"');
<ide> Cache::write('App.singleQuoteTest', "'this is a quoted string'", 'file_test');
<ide> $this->assertSame(Cache::read('App.singleQuoteTest', 'file_test'), "'this is a quoted string'");
<ide> public function testWriteQuotedString() {
<ide> public function testPathDoesNotExist() {
<ide> $this->skipIf(is_dir(TMP . 'tests' . DS . 'autocreate'), 'Cannot run if test directory exists.');
<ide>
<del> Configure::write('Cache.autocreate', array(
<add> Cache::config('autocreate', array(
<ide> 'engine' => 'File',
<ide> 'path' => TMP . 'tests' . DS . 'autocreate'
<ide> ));
<ide> public function testMaskSetting() {
<ide> if (DS === '\\') {
<ide> $this->markTestSkipped('File permission testing does not work on Windows.');
<ide> }
<del> Configure::write('Cache.mask_test', ['engine' => 'File', 'path' => TMP . 'tests']);
<add> Cache::config('mask_test', ['engine' => 'File', 'path' => TMP . 'tests']);
<ide> $data = 'This is some test content';
<ide> $write = Cache::write('masking_test', $data, 'mask_test');
<ide> $result = substr(sprintf('%o', fileperms(TMP . 'tests/cake_masking_test')), -4);
<ide> public function testMaskSetting() {
<ide> Cache::delete('masking_test', 'mask_test');
<ide> Cache::drop('mask_test');
<ide>
<del> Configure::write('Cache.mask_test', ['engine' => 'File', 'mask' => 0666, 'path' => TMP . 'tests']);
<add> Cache::config('mask_test', ['engine' => 'File', 'mask' => 0666, 'path' => TMP . 'tests']);
<ide> $write = Cache::write('masking_test', $data, 'mask_test');
<ide> $result = substr(sprintf('%o', fileperms(TMP . 'tests/cake_masking_test')), -4);
<ide> $expected = '0666';
<ide> $this->assertEquals($expected, $result);
<ide> Cache::delete('masking_test', 'mask_test');
<ide> Cache::drop('mask_test');
<ide>
<del> Configure::write('Cache.mask_test', ['engine' => 'File', 'mask' => 0644, 'path' => TMP . 'tests']);
<add> Cache::config('mask_test', ['engine' => 'File', 'mask' => 0644, 'path' => TMP . 'tests']);
<ide> $write = Cache::write('masking_test', $data, 'mask_test');
<ide> $result = substr(sprintf('%o', fileperms(TMP . 'tests/cake_masking_test')), -4);
<ide> $expected = '0644';
<ide> $this->assertEquals($expected, $result);
<ide> Cache::delete('masking_test', 'mask_test');
<ide> Cache::drop('mask_test');
<ide>
<del> Configure::write('Cache.mask_test', ['engine' => 'File', 'mask' => 0640, 'path' => TMP . 'tests']);
<add> Cache::config('mask_test', ['engine' => 'File', 'mask' => 0640, 'path' => TMP . 'tests']);
<ide> $write = Cache::write('masking_test', $data, 'mask_test');
<ide> $result = substr(sprintf('%o', fileperms(TMP . 'tests/cake_masking_test')), -4);
<ide> $expected = '0640';
<ide> public function testMaskSetting() {
<ide> * @return void
<ide> */
<ide> public function testGroupsReadWrite() {
<del> Configure::write('Cache.file_groups', [
<add> Cache::config('file_groups', [
<ide> 'engine' => 'File',
<ide> 'duration' => 3600,
<ide> 'groups' => array('group_a', 'group_b')
<ide> public function testGroupsReadWrite() {
<ide> * Test that clearing with repeat writes works properly
<ide> */
<ide> public function testClearingWithRepeatWrites() {
<del> Configure::write('Cache.repeat', [
<add> Cache::config('repeat', [
<ide> 'engine' => 'File',
<ide> 'groups' => array('users')
<ide> ]);
<ide> public function testClearingWithRepeatWrites() {
<ide> * @return void
<ide> */
<ide> public function testGroupDelete() {
<del> Configure::write('Cache.file_groups', [
<add> Cache::config('file_groups', [
<ide> 'engine' => 'File',
<ide> 'duration' => 3600,
<ide> 'groups' => array('group_a', 'group_b')
<ide> public function testGroupDelete() {
<ide> * @return void
<ide> */
<ide> public function testGroupClear() {
<del> Configure::write('Cache.file_groups', [
<add> Cache::config('file_groups', [
<ide> 'engine' => 'File',
<ide> 'duration' => 3600,
<ide> 'groups' => array('group_a', 'group_b')
<ide> ]);
<del> Configure::write('Cache.file_groups2', [
<add> Cache::config('file_groups2', [
<ide> 'engine' => 'File',
<ide> 'duration' => 3600,
<ide> 'groups' => array('group_b')
<ide> ]);
<del> Configure::write('Cache.file_groups3', [
<add> Cache::config('file_groups3', [
<ide> 'engine' => 'File',
<ide> 'duration' => 3600,
<ide> 'groups' => array('group_b'),
<ide><path>lib/Cake/Test/TestCase/Cache/Engine/MemcacheEngineTest.php
<ide> public function setUp() {
<ide> $this->skipIf(!class_exists('Memcache'), 'Memcache is not installed or configured properly.');
<ide>
<ide> Configure::write('Cache.disable', false);
<del> Configure::write('Cache.memcache', array(
<add> Cache::config('memcache', array(
<ide> 'engine' => 'Memcache',
<ide> 'prefix' => 'cake_',
<ide> 'duration' => 3600
<ide> public function testSettings() {
<ide> 'servers' => array('127.0.0.1'),
<ide> 'persistent' => true,
<ide> 'compress' => false,
<del> 'engine' => 'Memcache',
<add> 'engine' => 'Cake\Cache\Engine\MemcacheEngine',
<ide> 'groups' => array()
<ide> );
<ide> $this->assertEquals($expecting, $settings);
<ide> public function testIncrement() {
<ide> * @return void
<ide> */
<ide> public function testConfigurationConflict() {
<del> Configure::write('Cache.long_memcache', [
<add> Cache::config('long_memcache', [
<ide> 'engine' => 'Memcache',
<ide> 'duration' => '+2 seconds',
<ide> 'servers' => ['127.0.0.1:11211'],
<ide> ]);
<del> Configure::write('Cache.short_memcache', [
<add> Cache::config('short_memcache', [
<ide> 'engine' => 'Memcache',
<ide> 'duration' => '+1 seconds',
<ide> 'servers' => ['127.0.0.1:11211'],
<ide> ]);
<del> Configure::write('Cache.some_file', ['engine' => 'File']);
<add> Cache::config('some_file', ['engine' => 'File']);
<ide>
<ide> $this->assertTrue(Cache::write('duration_test', 'yay', 'long_memcache'));
<ide> $this->assertTrue(Cache::write('short_duration_test', 'boo', 'short_memcache'));
<ide> public function testConfigurationConflict() {
<ide> * @return void
<ide> */
<ide> public function testClear() {
<del> Configure::write('Cache.memcache2', [
<add> Cache::config('memcache2', [
<ide> 'engine' => 'Memcache',
<ide> 'prefix' => 'cake2_',
<ide> 'duration' => 3600
<ide> public function testClear() {
<ide> * @return void
<ide> */
<ide> public function testZeroDuration() {
<del> Configure::write('Cache.memcache', [
<add> Cache::config('memcache', [
<ide> 'engine' => 'Memcache',
<ide> 'prefix' => 'cake_',
<ide> 'duration' => 0
<ide> public function testLongDurationEqualToZero() {
<ide> * @return void
<ide> */
<ide> public function testGroupReadWrite() {
<del> Configure::write('Cache.memcache_groups', [
<add> Cache::config('memcache_groups', [
<ide> 'engine' => 'Memcache',
<ide> 'duration' => 3600,
<ide> 'groups' => ['group_a', 'group_b'],
<ide> 'prefix' => 'test_'
<ide> ]);
<del> Configure::write('Cache.memcache_helper', [
<add> Cache::config('memcache_helper', [
<ide> 'engine' => 'Memcache',
<ide> 'duration' => 3600,
<ide> 'prefix' => 'test_'
<ide> public function testGroupReadWrite() {
<ide> * @return void
<ide> */
<ide> public function testGroupDelete() {
<del> Configure::write('Cache.memcache_groups', [
<add> Cache::config('memcache_groups', [
<ide> 'engine' => 'Memcache',
<ide> 'duration' => 3600,
<ide> 'groups' => ['group_a', 'group_b']
<ide> public function testGroupDelete() {
<ide> * @return void
<ide> */
<ide> public function testGroupClear() {
<del> Configure::write('Cache.memcache_groups', [
<add> Cache::config('memcache_groups', [
<ide> 'engine' => 'Memcache',
<ide> 'duration' => 3600,
<ide> 'groups' => ['group_a', 'group_b']
<ide><path>lib/Cake/Test/TestCase/Cache/Engine/RedisEngineTest.php
<ide> public function setUp() {
<ide> $this->skipIf(!class_exists('Redis'), 'Redis is not installed or configured properly.');
<ide>
<ide> Configure::write('Cache.disable', false);
<del> Configure::write('Cache.redis', array(
<add> Cache::config('redis', array(
<ide> 'engine' => 'Cake\Cache\Engine\RedisEngine',
<ide> 'prefix' => 'cake_',
<ide> 'duration' => 3600
<ide> public function testIncrement() {
<ide> * @return void
<ide> */
<ide> public function testClear() {
<del> Configure::write('Cache.redis2', array(
<add> Cache::config('redis2', array(
<ide> 'engine' => 'Redis',
<ide> 'prefix' => 'cake2_',
<ide> 'duration' => 3600
<ide> public function testZeroDuration() {
<ide> * @return void
<ide> */
<ide> public function testGroupReadWrite() {
<del> Configure::write('Cache.redis_groups', [
<add> Cache::config('redis_groups', [
<ide> 'engine' => 'Redis',
<ide> 'duration' => 3600,
<ide> 'groups' => ['group_a', 'group_b'],
<ide> 'prefix' => 'test_'
<ide> ]);
<del> Configure::write('Cache.redis_helper', [
<add> Cache::config('redis_helper', [
<ide> 'engine' => 'Redis',
<ide> 'duration' => 3600,
<ide> 'prefix' => 'test_'
<ide> public function testGroupReadWrite() {
<ide> * @return void
<ide> */
<ide> public function testGroupDelete() {
<del> Configure::write('Cache.redis_groups', [
<add> Cache::config('redis_groups', [
<ide> 'engine' => 'Redis',
<ide> 'duration' => 3600,
<ide> 'groups' => ['group_a', 'group_b']
<ide> public function testGroupDelete() {
<ide> * @return void
<ide> */
<ide> public function testGroupClear() {
<del> Configure::write('Cache.redis_groups', [
<add> Cache::config('redis_groups', [
<ide> 'engine' => 'Redis',
<ide> 'duration' => 3600,
<ide> 'groups' => ['group_a', 'group_b']
<ide><path>lib/Cake/Test/TestCase/Cache/Engine/WincacheEngineTest.php
<ide> public function setUp() {
<ide> parent::setUp();
<ide> $this->skipIf(!function_exists('wincache_ucache_set'), 'Wincache is not installed or configured properly.');
<ide> Configure::write('Cache.disable', false);
<del> Configure::write('Cache.wincache', ['engine' => 'Wincache', 'prefix' => 'cake_']);
<add> Cache::config('wincache', ['engine' => 'Wincache', 'prefix' => 'cake_']);
<ide> }
<ide>
<ide> /**
<ide> public function testClear() {
<ide> * @return void
<ide> */
<ide> public function testGroupsReadWrite() {
<del> Configure::write('Cache.wincache_groups', [
<add> Cache::config('wincache_groups', [
<ide> 'engine' => 'Wincache',
<ide> 'duration' => 0,
<ide> 'groups' => ['group_a', 'group_b'],
<ide> public function testGroupsReadWrite() {
<ide> * @return void
<ide> */
<ide> public function testGroupDelete() {
<del> Configure::write('Cache.wincache_groups', [
<add> Cache::config('wincache_groups', [
<ide> 'engine' => 'Wincache',
<ide> 'duration' => 0,
<ide> 'groups' => ['group_a', 'group_b'],
<ide> public function testGroupDelete() {
<ide> * @return void
<ide> */
<ide> public function testGroupClear() {
<del> Configure::write('Cache.wincache_groups', [
<add> Cache::config('wincache_groups', [
<ide> 'engine' => 'Wincache',
<ide> 'duration' => 0,
<ide> 'groups' => ['group_a', 'group_b'],
<ide><path>lib/Cake/Test/TestCase/Cache/Engine/XcacheEngineTest.php
<ide> public function setUp() {
<ide> $this->markTestSkipped('Xcache is not installed or configured properly');
<ide> }
<ide> Configure::write('Cache.disable', false);
<del> Configure::write('Cache.xcache', ['engine' => 'Xcache', 'prefix' => 'cake_']);
<add> Cache::config('xcache', ['engine' => 'Xcache', 'prefix' => 'cake_']);
<ide> }
<ide>
<ide> /**
<ide> public function testIncrement() {
<ide> * @return void
<ide> */
<ide> public function testGroupsReadWrite() {
<del> Configure::write('Cache.xcache_groups', [
<add> Cache::config('xcache_groups', [
<ide> 'engine' => 'Xcache',
<ide> 'duration' => 0,
<ide> 'groups' => ['group_a', 'group_b'],
<ide> public function testGroupsReadWrite() {
<ide> * @return void
<ide> */
<ide> public function testGroupDelete() {
<del> Configure::write('Cache.xcache_groups', [
<add> Cache::config('xcache_groups', [
<ide> 'engine' => 'Xcache',
<ide> 'duration' => 0,
<ide> 'groups' => ['group_a', 'group_b'],
<ide> public function testGroupDelete() {
<ide> * @return void
<ide> */
<ide> public function testGroupClear() {
<del> Configure::write('Cache.xcache_groups', [
<add> Cache::config('xcache_groups', [
<ide> 'engine' => 'Xcache',
<ide> 'duration' => 0,
<ide> 'groups' => ['group_a', 'group_b'],
<ide><path>lib/Cake/Test/init.php
<ide> */
<ide>
<ide> use Cake\Core\Configure;
<add>use Cake\Cache\Cache;
<add>use Cake\Log\Log;
<ide>
<ide> define('DS', DIRECTORY_SEPARATOR);
<ide> define('ROOT', dirname(dirname(dirname(__DIR__))));
<ide> 'cssBaseUrl' => 'css/',
<ide> ]);
<ide>
<del>Configure::write('Cache._cake_core_', [
<del> 'engine' => 'File',
<del> 'prefix' => 'cake_core_',
<del> 'serialize' => true
<add>Cache::config([
<add> '_cake_core_' => [
<add> 'engine' => 'File',
<add> 'prefix' => 'cake_core_',
<add> 'serialize' => true
<add> ]
<ide> ]);
<ide>
<ide> Configure::write('Datasource.test', [
<ide> 'defaults' => 'php'
<ide> ]);
<ide>
<del>Configure::write('Log.debug', [
<del> 'engine' => 'Cake\Log\Engine\FileLog',
<del> 'levels' => ['notice', 'info', 'debug'],
<del> 'file' => 'debug',
<del>]);
<del>
<del>Configure::write('Log.error', [
<del> 'engine' => 'Cake\Log\Engine\FileLog',
<del> 'levels' => ['warning', 'error', 'critical', 'alert', 'emergency'],
<del> 'file' => 'error',
<add>Log::config([
<add> 'debug' => [
<add> 'engine' => 'Cake\Log\Engine\FileLog',
<add> 'levels' => ['notice', 'info', 'debug'],
<add> 'file' => 'debug',
<add> ],
<add> 'error' => [
<add> 'engine' => 'Cake\Log\Engine\FileLog',
<add> 'levels' => ['warning', 'error', 'critical', 'alert', 'emergency'],
<add> 'file' => 'error',
<add> ]
<ide> ]);
<ide>
<ide> $autoloader = new Cake\Core\ClassLoader('TestApp', dirname(__DIR__) . '/Test'); | 11 |
Python | Python | fix obsolete data in english tokenizer exceptions | 00cfadbf63ca59354c2f57a5b28e85d00097a190 | <ide><path>spacy/lang/en/tokenizer_exceptions.py
<ide> LEMMA: "be",
<ide> NORM: "am",
<ide> TAG: "VBP",
<del> "tenspect": 1,
<del> "number": 1,
<ide> },
<ide> ]
<ide> | 1 |
Ruby | Ruby | add check for head ref in diagnostics | abe47b79c898c49d762df5d0f52541722e8e202c | <ide><path>Library/Homebrew/diagnostic.rb
<ide> def check_brew_git_origin
<ide> end
<ide> end
<ide>
<del> def check_coretap_git_origin
<add> def check_coretap_git_config
<ide> coretap_path = CoreTap.instance.path
<ide> return if !Utils.git_available? || !(coretap_path/".git").exist?
<ide>
<ide> def check_coretap_git_origin
<ide> git -C "#{coretap_path}" remote set-url origin #{Formatter.url("https://github.com/Homebrew/homebrew-core.git")}
<ide> EOS
<ide> end
<add>
<add> head = coretap_path.head
<add> return unless head && head !~ %r{refs/heads/master}
<add>
<add> <<-EOS.undent
<add> Suspicious #{CoreTap.instance} git head found.
<add>
<add> With a non-standard head, your local version of Homebrew might not
<add> have all of the changes intended for the most recent release. The
<add> current git head is:
<add> #{head}
<add>
<add> Unless you have compelling reasons, consider setting the head to
<add> point at the master branch by running:
<add> git checkout master
<add> EOS
<ide> end
<ide>
<ide> def __check_linked_brew(f) | 1 |
Ruby | Ruby | add "build_dependencies" key to json output (#340) | e9cc2a5d88da6d1719763a26c1fc455c51e2c3db | <ide><path>Library/Homebrew/formula.rb
<ide> def to_hash
<ide> "dependencies" => deps.map(&:name).uniq,
<ide> "recommended_dependencies" => deps.select(&:recommended?).map(&:name).uniq,
<ide> "optional_dependencies" => deps.select(&:optional?).map(&:name).uniq,
<add> "build_dependencies" => deps.select(&:build?).map(&:name).uniq,
<ide> "conflicts_with" => conflicts.map(&:name),
<ide> "caveats" => caveats
<ide> } | 1 |
Python | Python | fix convert for newer megatron-lm bert model | 768e6c1449b12df9c8ae8f71be702c64ba3d9dd9 | <ide><path>src/transformers/models/megatron_bert/convert_megatron_bert_checkpoint.py
<ide> #
<ide>
<ide> import argparse
<del>import json
<ide> import os
<ide> import re
<ide> import zipfile
<ide>
<ide> import torch
<ide>
<add>from transformers import MegatronBertConfig
<add>
<ide>
<ide> ####################################################################################################
<ide>
<ide> def recursive_print(name, val, spaces=0):
<ide> print(msg, ":", val)
<ide>
<ide>
<add>def fix_query_key_value_ordering(param, checkpoint_version, num_splits, num_heads, hidden_size):
<add> # Permutes layout of param tensor to [num_splits * num_heads * hidden_size, :]
<add> # for compatibility with later versions of NVIDIA Megatron-LM.
<add> # The inverse operation is performed inside Megatron-LM to read checkpoints:
<add> # https://github.com/NVIDIA/Megatron-LM/blob/v2.4/megatron/checkpointing.py#L209
<add> # If param is the weight tensor of the self-attention block, the returned tensor
<add> # will have to be transposed one more time to be read by HuggingFace BERT.
<add> input_shape = param.size()
<add> if checkpoint_version == 1.0:
<add> # version 1.0 stores [num_heads * hidden_size * num_splits, :]
<add> saved_shape = (num_heads, hidden_size, num_splits) + input_shape[1:]
<add> param = param.view(*saved_shape)
<add> param = param.transpose(0, 2)
<add> param = param.transpose(1, 2).contiguous()
<add> elif checkpoint_version >= 2.0:
<add> # other versions store [num_heads * num_splits * hidden_size, :]
<add> saved_shape = (num_heads, num_splits, hidden_size) + input_shape[1:]
<add> param = param.view(*saved_shape)
<add> param = param.transpose(0, 1).contiguous()
<add> param = param.view(*input_shape)
<add> return param
<add>
<add>
<ide> ####################################################################################################
<ide>
<ide>
<del>def convert_megatron_checkpoint(args, input_state_dict):
<add>def convert_megatron_checkpoint(args, input_state_dict, config):
<ide> # The converted output model.
<ide> output_state_dict = {}
<ide>
<add> # old versions did not store training args
<add> ds_args = input_state_dict.get("args", None)
<add> if ds_args is not None:
<add> # do not make the user write a config file when the exact dimensions/sizes are already in the checkpoint
<add> # from pprint import pprint
<add> # pprint(vars(ds_args))
<add>
<add> config.tokenizer_type = ds_args.tokenizer_type
<add> config.vocab_size = ds_args.padded_vocab_size
<add> config.max_position_embeddings = ds_args.max_position_embeddings
<add> config.hidden_size = ds_args.hidden_size
<add> config.num_hidden_layers = ds_args.num_layers
<add> config.num_attention_heads = ds_args.num_attention_heads
<add> config.intermediate_size = ds_args.get("ffn_hidden_size", 4 * ds_args.hidden_size)
<add> # pprint(config)
<add>
<add> # The number of heads.
<add> heads = config.num_attention_heads
<add> # The hidden_size per head.
<add> hidden_size_per_head = config.hidden_size // heads
<add> # Megatron-LM checkpoint version
<add> if "checkpoint_version" in input_state_dict.keys():
<add> checkpoint_version = input_state_dict["checkpoint_version"]
<add> else:
<add> checkpoint_version = 0.0
<add>
<ide> # The model.
<ide> model = input_state_dict["model"]
<ide> # The language model.
<ide> def convert_megatron_checkpoint(args, input_state_dict):
<ide>
<ide> # The word embeddings.
<ide> word_embeddings = embeddings["word_embeddings"]["weight"]
<add> # Truncate the embedding table to vocab_size rows.
<add> word_embeddings = word_embeddings[: config.vocab_size, :]
<ide> # Store the word embeddings.
<ide> output_state_dict["bert.embeddings.word_embeddings.weight"] = word_embeddings
<ide>
<ide> # The position embeddings.
<ide> pos_embeddings = embeddings["position_embeddings"]["weight"]
<del> # Trained for 512 x 1024.
<del> assert pos_embeddings.size(0) == 512 and pos_embeddings.size(1) == 1024
<add> assert pos_embeddings.size(0) == config.max_position_embeddings and pos_embeddings.size(1) == config.hidden_size
<ide> # Store the position embeddings.
<ide> output_state_dict["bert.embeddings.position_embeddings.weight"] = pos_embeddings
<ide>
<ide> def convert_megatron_checkpoint(args, input_state_dict):
<ide> output_state_dict["bert.embeddings.token_type_embeddings.weight"] = tokentype_embeddings
<ide>
<ide> # The transformer.
<del> transformer = lm["transformer"]
<add> transformer = lm["transformer"] if "transformer" in lm.keys() else lm["encoder"]
<ide>
<ide> # The regex to extract layer names.
<ide> layer_re = re.compile("layers\.(\d+)\.([a-z0-9_.]+)\.([a-z]+)")
<ide> def convert_megatron_checkpoint(args, input_state_dict):
<ide> # Make sure the QKV pointer is nil.
<ide> assert attention_qkv_weight is None, ""
<ide>
<add> out_val = fix_query_key_value_ordering(val, checkpoint_version, 3, heads, hidden_size_per_head)
<ide> # Store the tensor as we need the bias as well to interleave QKV and biases.
<del> attention_qkv_weight = val
<add> attention_qkv_weight = out_val
<ide>
<ide> # Transpose the bias.
<ide> elif op_name == "attention.query_key_value" and weight_or_bias == "bias":
<ide> def convert_megatron_checkpoint(args, input_state_dict):
<ide> assert attention_qkv_weight is not None, ""
<ide>
<ide> # Split the QKV matrix into Q, K and V. Megatron stores Q,K,V interleaved.
<del> q = attention_qkv_weight[0 * 1024 : 1 * 1024, :]
<del> k = attention_qkv_weight[1 * 1024 : 2 * 1024, :]
<del> v = attention_qkv_weight[2 * 1024 : 3 * 1024, :]
<add> q = attention_qkv_weight[0 * config.hidden_size : 1 * config.hidden_size, :]
<add> k = attention_qkv_weight[1 * config.hidden_size : 2 * config.hidden_size, :]
<add> v = attention_qkv_weight[2 * config.hidden_size : 3 * config.hidden_size, :]
<ide>
<add> out_val = fix_query_key_value_ordering(val, checkpoint_version, 3, heads, hidden_size_per_head)
<ide> # Split the bias.
<del> q_bias = val[0 * 1024 : 1 * 1024]
<del> k_bias = val[1 * 1024 : 2 * 1024]
<del> v_bias = val[2 * 1024 : 3 * 1024]
<add> q_bias = out_val[0 * config.hidden_size : 1 * config.hidden_size]
<add> k_bias = out_val[1 * config.hidden_size : 2 * config.hidden_size]
<add> v_bias = out_val[2 * config.hidden_size : 3 * config.hidden_size]
<ide>
<ide> # Store.
<ide> output_state_dict[f"{layer_name}.attention.self.query.weight"] = q
<ide> def convert_megatron_checkpoint(args, input_state_dict):
<ide> output_state_dict["bert.encoder.ln.weight"] = transformer["final_layernorm.weight"]
<ide> output_state_dict["bert.encoder.ln.bias"] = transformer["final_layernorm.bias"]
<ide>
<del> # The config.
<del> output_config = {
<del> "vocab_size": word_embeddings.size(0),
<del> "hidden_size": 1024,
<del> "num_hidden_layers": 24,
<del> "num_attention_heads": 16,
<del> "hidden_act": "gelu_new",
<del> "intermediate_size": 4096,
<del> "hidden_dropout_prob": 0.1,
<del> "attention_probs_dropout_prob": 0.1,
<del> "max_position_embeddings": 512,
<del> "type_vocab_size": 2,
<del> "initializer_range": 0.2,
<del> "layer_norm_eps": 1e-12,
<del> "position_embedding_type": "absolute",
<del> "use_cache": False,
<del> }
<del>
<ide> # The pooler.
<ide> pooler = lm["pooler"]
<ide>
<ide> def convert_megatron_checkpoint(args, input_state_dict):
<ide> output_state_dict["cls.seq_relationship.bias"] = binary_head["bias"]
<ide>
<ide> # It should be done!
<del> return output_state_dict, output_config
<add> return output_state_dict
<ide>
<ide>
<ide> ####################################################################################################
<ide> def main():
<ide> parser = argparse.ArgumentParser()
<ide> parser.add_argument("--print-checkpoint-structure", action="store_true")
<ide> parser.add_argument("path_to_checkpoint", type=str, help="Path to the ZIP file containing the checkpoint")
<add> parser.add_argument(
<add> "--config_file",
<add> default="",
<add> type=str,
<add> help="An optional config json file describing the pre-trained model.",
<add> )
<ide> args = parser.parse_args()
<ide>
<ide> # Extract the basename.
<ide> basename = os.path.dirname(args.path_to_checkpoint)
<ide>
<ide> # Load the model.
<add> # the .zip is very optional, let's keep it for backward compatibility
<ide> print(f'Extracting PyTorch state dictionary from "{args.path_to_checkpoint}"')
<del> with zipfile.ZipFile(args.path_to_checkpoint, "r") as checkpoint:
<del> with checkpoint.open("release/mp_rank_00/model_optim_rng.pt") as pytorch_dict:
<del> input_state_dict = torch.load(pytorch_dict, map_location="cpu")
<add> if args.path_to_checkpoint.endswith(".zip"):
<add> with zipfile.ZipFile(args.path_to_checkpoint, "r") as checkpoint:
<add> with checkpoint.open("release/mp_rank_00/model_optim_rng.pt") as pytorch_dict:
<add> input_state_dict = torch.load(pytorch_dict, map_location="cpu")
<add> else:
<add> input_state_dict = torch.load(args.path_to_checkpoint, map_location="cpu")
<add>
<add> if args.config_file == "":
<add> # Default config of megatron-bert 345m
<add> config = MegatronBertConfig()
<add> else:
<add> config = MegatronBertConfig.from_json_file(args.config_file)
<ide>
<ide> # Convert.
<ide> print("Converting")
<del> output_state_dict, output_config = convert_megatron_checkpoint(args, input_state_dict)
<add> output_state_dict = convert_megatron_checkpoint(args, input_state_dict, config)
<ide>
<ide> # Print the structure of converted state dict.
<ide> if args.print_checkpoint_structure:
<ide> recursive_print(None, output_state_dict)
<ide>
<ide> # Store the config to file.
<del> output_config_file = os.path.join(basename, "config.json")
<del> print(f'Saving config to "{output_config_file}"')
<del> with open(output_config_file, "w") as f:
<del> json.dump(output_config, f)
<add> print("Saving config")
<add> config.save_pretrained(basename)
<ide>
<ide> # Store the state_dict to file.
<ide> output_checkpoint_file = os.path.join(basename, "pytorch_model.bin") | 1 |
Javascript | Javascript | add missing return | 806047bd270094fba668929a36bd45c4c68f5491 | <ide><path>src/git-repository-async.js
<ide> module.exports = class GitRepositoryAsync {
<ide>
<ide> isPathIgnored (_path) {
<ide> return this.repoPromise.then((repo) => {
<del> Git.Ignore.pathIsIgnored(repo, _path)
<add> return Git.Ignore.pathIsIgnored(repo, _path)
<ide> })
<ide> }
<ide> | 1 |
Text | Text | fix comma splices in process.md | 4a7b401e5f78f49ce8378031fd456f27a0baa7b4 | <ide><path>doc/api/process.md
<ide> process.on('SIGTERM', handle);
<ide> removed (Node.js will no longer exit).
<ide> * `'SIGPIPE'` is ignored by default. It can have a listener installed.
<ide> * `'SIGHUP'` is generated on Windows when the console window is closed, and on
<del> other platforms under various similar conditions, see signal(7). It can have a
<add> other platforms under various similar conditions. See signal(7). It can have a
<ide> listener installed, however Node.js will be unconditionally terminated by
<ide> Windows about 10 seconds later. On non-Windows platforms, the default
<ide> behavior of `SIGHUP` is to terminate Node.js, but once a listener has been
<ide> process.kill(process.pid, 'SIGHUP');
<ide> ```
<ide>
<ide> When `SIGUSR1` is received by a Node.js process, Node.js will start the
<del>debugger, see [Signal Events][].
<add>debugger. See [Signal Events][].
<ide>
<ide> ## process.mainModule
<ide> <!-- YAML
<ide> The `process.stderr` property returns a stream connected to
<ide> stream) unless fd `2` refers to a file, in which case it is
<ide> a [Writable][] stream.
<ide>
<del>`process.stderr` differs from other Node.js streams in important ways, see
<add>`process.stderr` differs from other Node.js streams in important ways. See
<ide> [note on process I/O][] for more information.
<ide>
<ide> ## process.stdin
<ide> For example, to copy `process.stdin` to `process.stdout`:
<ide> process.stdin.pipe(process.stdout);
<ide> ```
<ide>
<del>`process.stdout` differs from other Node.js streams in important ways, see
<add>`process.stdout` differs from other Node.js streams in important ways. See
<ide> [note on process I/O][] for more information.
<ide>
<ide> ### A note on process I/O | 1 |
Text | Text | add tests for header parser microservice project | 86127a24f73ee29be6821ce06561c5f62f53be3f | <ide><path>curriculum/challenges/english/05-apis-and-microservices/apis-and-microservices-projects/request-header-parser-microservice.english.md
<ide> Start this project on Glitch using <a href='https://glitch.com/edit/#!/remix/clo
<ide>
<ide> ```yml
<ide> tests:
<del> - text: 'I can get the IP address, language and operating system for my browser.'
<del> testString: ''
<del>
<add> - text: 'Your IP address should be returned in the <code>ipaddress</code> key.'
<add> testString: 'getUserInput => $.get(getUserInput(''url'') + ''/api/whoami'').then(data => assert(data.ipaddress && data.ipaddress.length > 0), xhr => { throw new Error(xhr.responseText)})'
<add> - text: 'Your preferred language should be returned in the <code>language</code> key.'
<add> testString: 'getUserInput => $.get(getUserInput(''url'') + ''/api/whoami'').then(data => assert(data.language && data.language.length > 0), xhr => { throw new Error(xhr.responseText)})'
<add> - text: 'Your software should be returned in the <code>software</code> key.'
<add> testString: 'getUserInput => $.get(getUserInput(''url'') + ''/api/whoami'').then(data => assert(data.software && data.software.length > 0), xhr => { throw new Error(xhr.responseText)})'
<add>
<ide> ```
<ide>
<ide> </section> | 1 |
Python | Python | support nout == 0 and at method | a43174390de55b2496a9e9aed84cf424229e817a | <ide><path>numpy/core/tests/test_umath.py
<ide> def __array_ufunc__(self, ufunc, method, *inputs, **kwargs):
<ide> if results is NotImplemented:
<ide> return NotImplemented
<ide>
<add> if method == 'at':
<add> return
<add>
<ide> if ufunc.nout == 1:
<ide> results = (results,)
<ide>
<ide> results = tuple((np.asarray(result).view(A)
<ide> if output is None else output)
<ide> for result, output in zip(results, outputs))
<del> if isinstance(results[0], A):
<add> if results and isinstance(results[0], A):
<ide> results[0].info = info
<ide>
<ide> return results[0] if len(results) == 1 else results
<ide> def __array_ufunc__(self, ufunc, method, *inputs, **kwargs):
<ide> return NotImplemented
<ide>
<ide> d = np.arange(5.)
<del> a = np.arange(5.).view(A)
<ide> # 1 input, 1 output
<add> a = np.arange(5.).view(A)
<ide> b = np.sin(a)
<ide> check = np.sin(d)
<ide> assert_(np.all(check == b))
<ide> def __array_ufunc__(self, ufunc, method, *inputs, **kwargs):
<ide> b = np.sin(a, out=a)
<ide> assert_(np.all(check == b))
<ide> assert_equal(b.info, {'inputs': [0], 'outputs': [0]})
<add>
<ide> # 1 input, 2 outputs
<ide> a = np.arange(5.).view(A)
<ide> b1, b2 = np.modf(a)
<ide> def __array_ufunc__(self, ufunc, method, *inputs, **kwargs):
<ide> assert_(c1 is a)
<ide> assert_(c2 is b)
<ide> assert_equal(c1.info, {'inputs': [0], 'outputs': [0, 1]})
<add>
<ide> # 2 input, 1 output
<ide> a = np.arange(5.).view(A)
<ide> b = np.arange(5.).view(A)
<ide><path>numpy/doc/subclassing.py
<ide> def __array_ufunc__(self, ufunc, method, *inputs, **kwargs):
<ide> if results is NotImplemented:
<ide> return NotImplemented
<ide>
<add> if method == 'at':
<add> return
<add>
<ide> if ufunc.nout == 1:
<ide> results = (results,)
<ide>
<ide> results = tuple((np.asarray(result).view(A)
<ide> if output is None else output)
<ide> for result, output in zip(results, outputs))
<del> if isinstance(results[0], A):
<add> if results and isinstance(results[0], A):
<ide> results[0].info = info
<ide>
<ide> return results[0] if len(results) == 1 else results | 2 |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.