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
|
---|---|---|---|---|---|
Python | Python | rename a to old_schedules | 88e52d88b343e83f08b28292bffd057068ab2034 | <ide><path>celery/beat.py
<ide> def tick(self, event_t=event_t, min=min, heappop=heapq.heappop,
<ide> return min(verify[0], max_interval)
<ide> return min(adjust(next_time_to_run) or max_interval, max_interval)
<ide>
<del> def schedules_equal(self, a, b):
<del> if set(a.keys()) != set(b.keys()):
<add> def schedules_equal(self, old_schedules, b):
<add> if set(old_schedules.keys()) != set(b.keys()):
<ide> return False
<del> for name, model in a.items():
<add> for name, model in old_schedules.items():
<ide> b_model = b.get(name)
<ide> if not b_model:
<ide> return False | 1 |
Javascript | Javascript | prevent infinite digest with idn urls in edge | 705afcd160c8428133b36f2cd63db305dc52f2d7 | <ide><path>src/ng/location.js
<ide> function parseAppUrl(relativeUrl, locationObj) {
<ide> }
<ide> }
<ide>
<del>function startsWith(haystack, needle) {
<del> return haystack.lastIndexOf(needle, 0) === 0;
<add>function startsWith(str, search) {
<add> return str.slice(0, search.length) === search;
<ide> }
<ide>
<ide> /**
<ide><path>test/ng/locationSpec.js
<ide> describe('$location', function() {
<ide>
<ide>
<ide> describe('LocationHtml5Url', function() {
<del> var locationUrl, locationIndexUrl;
<add> var locationUrl, locationUmlautUrl, locationIndexUrl;
<ide>
<ide> beforeEach(function() {
<ide> locationUrl = new LocationHtml5Url('http://server/pre/', 'http://server/pre/', 'http://server/pre/path');
<add> locationUmlautUrl = new LocationHtml5Url('http://särver/pre/', 'http://särver/pre/', 'http://särver/pre/path');
<ide> locationIndexUrl = new LocationHtml5Url('http://server/pre/index.html', 'http://server/pre/', 'http://server/pre/path');
<ide> });
<ide>
<ide> describe('$location', function() {
<ide> // Note: relies on the previous state!
<ide> expect(parseLinkAndReturn(locationUrl, 'someIgnoredAbsoluteHref', '#test')).toEqual('http://server/pre/otherPath#test');
<ide>
<add> expect(parseLinkAndReturn(locationUmlautUrl, 'http://other')).toEqual(undefined);
<add> expect(parseLinkAndReturn(locationUmlautUrl, 'http://särver/pre')).toEqual('http://särver/pre/');
<add> expect(parseLinkAndReturn(locationUmlautUrl, 'http://särver/pre/')).toEqual('http://särver/pre/');
<add> expect(parseLinkAndReturn(locationUmlautUrl, 'http://särver/pre/otherPath')).toEqual('http://särver/pre/otherPath');
<add> // Note: relies on the previous state!
<add> expect(parseLinkAndReturn(locationUmlautUrl, 'someIgnoredAbsoluteHref', '#test')).toEqual('http://särver/pre/otherPath#test');
<add>
<ide> expect(parseLinkAndReturn(locationIndexUrl, 'http://server/pre')).toEqual('http://server/pre/');
<ide> expect(parseLinkAndReturn(locationIndexUrl, 'http://server/pre/')).toEqual('http://server/pre/');
<ide> expect(parseLinkAndReturn(locationIndexUrl, 'http://server/pre/otherPath')).toEqual('http://server/pre/otherPath'); | 2 |
Go | Go | move console into execdriver | 8c783c1c1336d8f2d1b08b9cbd8e2298d066750c | <ide><path>container.go
<ide> import (
<ide> "github.com/dotcloud/docker/graphdriver"
<ide> "github.com/dotcloud/docker/links"
<ide> "github.com/dotcloud/docker/nat"
<del> "github.com/dotcloud/docker/pkg/term"
<ide> "github.com/dotcloud/docker/runconfig"
<ide> "github.com/dotcloud/docker/utils"
<del> "github.com/kr/pty"
<ide> "io"
<ide> "io/ioutil"
<ide> "log"
<ide> type Container struct {
<ide> Driver string
<ide>
<ide> command *execdriver.Command
<add> console execdriver.Console
<ide> stdout *utils.WriteBroadcaster
<ide> stderr *utils.WriteBroadcaster
<ide> stdin io.ReadCloser
<ide> stdinPipe io.WriteCloser
<del> ptyMaster io.Closer
<ide>
<ide> runtime *Runtime
<ide>
<ide> func (container *Container) generateEnvConfig(env []string) error {
<ide> return nil
<ide> }
<ide>
<del>func (container *Container) setupPty() error {
<del> ptyMaster, ptySlave, err := pty.Open()
<del> if err != nil {
<del> return err
<del> }
<del> container.ptyMaster = ptyMaster
<del> container.command.Stdout = ptySlave
<del> container.command.Stderr = ptySlave
<del> container.command.Console = ptySlave.Name()
<del>
<del> // Copy the PTYs to our broadcasters
<del> go func() {
<del> defer container.stdout.CloseWriters()
<del> utils.Debugf("startPty: begin of stdout pipe")
<del> io.Copy(container.stdout, ptyMaster)
<del> utils.Debugf("startPty: end of stdout pipe")
<del> }()
<del>
<del> // stdin
<del> if container.Config.OpenStdin {
<del> container.command.Stdin = ptySlave
<del> container.command.SysProcAttr.Setctty = true
<del> go func() {
<del> defer container.stdin.Close()
<del> utils.Debugf("startPty: begin of stdin pipe")
<del> io.Copy(ptyMaster, container.stdin)
<del> utils.Debugf("startPty: end of stdin pipe")
<del> }()
<del> }
<del> return nil
<del>}
<del>
<del>func (container *Container) setupStd() error {
<del> container.command.Stdout = container.stdout
<del> container.command.Stderr = container.stderr
<del> if container.Config.OpenStdin {
<del> stdin, err := container.command.StdinPipe()
<del> if err != nil {
<del> return err
<del> }
<del> go func() {
<del> defer stdin.Close()
<del> utils.Debugf("start: begin of stdin pipe")
<del> io.Copy(stdin, container.stdin)
<del> utils.Debugf("start: end of stdin pipe")
<del> }()
<del> }
<del> return nil
<del>}
<del>
<ide> func (container *Container) Attach(stdin io.ReadCloser, stdinCloser io.Closer, stdout io.Writer, stderr io.Writer) chan error {
<ide> var cStdout, cStderr io.ReadCloser
<ide>
<ide> func (container *Container) Start() (err error) {
<ide> }
<ide> container.waitLock = make(chan struct{})
<ide>
<del> // Setuping pipes and/or Pty
<del> var setup func() error
<del> if container.Config.Tty {
<del> setup = container.setupPty
<del> } else {
<del> setup = container.setupStd
<add> container.console, err = execdriver.NewConsole(
<add> container.stdin, container.stdout, container.stderr,
<add> container.Config.OpenStdin, container.Config.Tty)
<add> if err != nil {
<add> return err
<ide> }
<del> if err := setup(); err != nil {
<add> if err := container.console.AttachTo(container.command); err != nil {
<ide> return err
<ide> }
<ide>
<ide> func (container *Container) cleanup() {
<ide> link.Disable()
<ide> }
<ide> }
<del>
<ide> if container.Config.OpenStdin {
<ide> if err := container.stdin.Close(); err != nil {
<ide> utils.Errorf("%s: Error close stdin: %s", container.ID, err)
<ide> }
<ide> }
<del> if err := container.stdout.CloseWriters(); err != nil {
<add> if err := container.stdout.Close(); err != nil {
<ide> utils.Errorf("%s: Error close stdout: %s", container.ID, err)
<ide> }
<del> if err := container.stderr.CloseWriters(); err != nil {
<add> if err := container.stderr.Close(); err != nil {
<ide> utils.Errorf("%s: Error close stderr: %s", container.ID, err)
<ide> }
<del>
<del> if container.ptyMaster != nil {
<del> if err := container.ptyMaster.Close(); err != nil {
<del> utils.Errorf("%s: Error closing Pty master: %s", container.ID, err)
<add> if container.console != nil {
<add> if err := container.console.Close(); err != nil {
<add> utils.Errorf("%s: Error closing console: %s", container.ID, err)
<ide> }
<ide> }
<ide>
<ide> func (container *Container) Wait() int {
<ide> }
<ide>
<ide> func (container *Container) Resize(h, w int) error {
<del> pty, ok := container.ptyMaster.(*os.File)
<del> if !ok {
<del> return fmt.Errorf("ptyMaster does not have Fd() method")
<del> }
<del> return term.SetWinsize(pty.Fd(), &term.Winsize{Height: uint16(h), Width: uint16(w)})
<add> return container.console.Resize(h, w)
<ide> }
<ide>
<ide> func (container *Container) ExportRw() (archive.Archive, error) {
<ide> func (container *Container) Exposes(p nat.Port) bool {
<ide> }
<ide>
<ide> func (container *Container) GetPtyMaster() (*os.File, error) {
<del> if container.ptyMaster == nil {
<add> ttyConsole, ok := container.console.(*execdriver.TtyConsole)
<add> if !ok {
<ide> return nil, ErrNoTTY
<ide> }
<del> if pty, ok := container.ptyMaster.(*os.File); ok {
<del> return pty, nil
<del> }
<del> return nil, ErrNotATTY
<add> return ttyConsole.Master, nil
<ide> }
<ide><path>execdriver/console.go
<add>package execdriver
<add>
<add>import (
<add> "github.com/dotcloud/docker/pkg/term"
<add> "github.com/kr/pty"
<add> "io"
<add> "os"
<add>)
<add>
<add>type Console interface {
<add> io.Closer
<add> Resize(height, width int) error
<add> AttachTo(command *Command) error
<add>}
<add>
<add>type pipes struct {
<add> Stdin io.ReadCloser
<add> Stdout, Stderr io.WriteCloser
<add>}
<add>
<add>func (p *pipes) Close() error {
<add> if p.Stderr != nil {
<add> p.Stdin.Close()
<add> }
<add> if p.Stdout != nil {
<add> p.Stdout.Close()
<add> }
<add> if p.Stderr != nil {
<add> p.Stderr.Close()
<add> }
<add> return nil
<add>}
<add>
<add>func NewConsole(stdin io.ReadCloser, stdout, stderr io.WriteCloser, useStdin, tty bool) (Console, error) {
<add> p := &pipes{
<add> Stdout: stdout,
<add> Stderr: stderr,
<add> }
<add> if useStdin {
<add> p.Stdin = stdin
<add> }
<add> if tty {
<add> return NewTtyConsole(p)
<add> }
<add> return NewStdConsole(p)
<add>}
<add>
<add>type TtyConsole struct {
<add> Master *os.File
<add> Slave *os.File
<add> pipes *pipes
<add>}
<add>
<add>func NewTtyConsole(p *pipes) (*TtyConsole, error) {
<add> ptyMaster, ptySlave, err := pty.Open()
<add> if err != nil {
<add> return nil, err
<add> }
<add> tty := &TtyConsole{
<add> Master: ptyMaster,
<add> Slave: ptySlave,
<add> pipes: p,
<add> }
<add> return tty, nil
<add>}
<add>
<add>func (t *TtyConsole) Resize(h, w int) error {
<add> return term.SetWinsize(t.Master.Fd(), &term.Winsize{Height: uint16(h), Width: uint16(w)})
<add>
<add>}
<add>
<add>func (t *TtyConsole) AttachTo(command *Command) error {
<add> command.Stdout = t.Slave
<add> command.Stderr = t.Slave
<add>
<add> command.Console = t.Slave.Name()
<add>
<add> go func() {
<add> defer t.pipes.Stdout.Close()
<add> io.Copy(t.pipes.Stdout, t.Master)
<add> }()
<add>
<add> if t.pipes.Stdin != nil {
<add> command.Stdin = t.Slave
<add> command.SysProcAttr.Setctty = true
<add>
<add> go func() {
<add> defer t.pipes.Stdin.Close()
<add> io.Copy(t.Master, t.pipes.Stdin)
<add> }()
<add> }
<add> return nil
<add>}
<add>
<add>func (t *TtyConsole) Close() error {
<add> err := t.Slave.Close()
<add> if merr := t.Master.Close(); err == nil {
<add> err = merr
<add> }
<add> return err
<add>}
<add>
<add>type StdConsole struct {
<add> pipes *pipes
<add>}
<add>
<add>func NewStdConsole(p *pipes) (*StdConsole, error) {
<add> return &StdConsole{p}, nil
<add>}
<add>
<add>func (s *StdConsole) AttachTo(command *Command) error {
<add> command.Stdout = s.pipes.Stdout
<add> command.Stderr = s.pipes.Stderr
<add>
<add> if s.pipes.Stdin != nil {
<add> stdin, err := command.StdinPipe()
<add> if err != nil {
<add> return err
<add> }
<add>
<add> go func() {
<add> defer stdin.Close()
<add> io.Copy(stdin, s.pipes.Stdin)
<add> }()
<add> }
<add> return nil
<add>}
<add>
<add>func (s *StdConsole) Resize(h, w int) error {
<add> // we do not need to reside a non tty
<add> return nil
<add>}
<add>
<add>func (s *StdConsole) Close() error {
<add> // nothing to close here
<add> return nil
<add>}
<ide><path>utils/utils.go
<ide> func (w *WriteBroadcaster) Write(p []byte) (n int, err error) {
<ide> return len(p), nil
<ide> }
<ide>
<del>func (w *WriteBroadcaster) CloseWriters() error {
<add>func (w *WriteBroadcaster) Close() error {
<ide> w.Lock()
<ide> defer w.Unlock()
<ide> for sw := range w.writers {
<ide><path>utils/utils_test.go
<ide> func TestWriteBroadcaster(t *testing.T) {
<ide> t.Errorf("Buffer contains %v", bufferC.String())
<ide> }
<ide>
<del> writer.CloseWriters()
<add> writer.Close()
<ide> }
<ide>
<ide> type devNullCloser int | 4 |
Javascript | Javascript | add test case | 06d1fb1e005625b2af5f1ad752c338a12eb355a3 | <ide><path>test/configCases/context-exclusion/simple/index.js
<add>function requireInContext(someVariable) {
<add> return require(`./some-dir/${someVariable}`);
<add>}
<add>
<add>it("should not exclude paths not matching the exclusion pattern", function() {
<add> requireInContext("file").should.be.eql("thats good");
<add> requireInContext("check-here/file").should.be.eql("thats good");
<add> requireInContext("check-here/check-here/file").should.be.eql("thats good");
<add>});
<add>
<add>it("should exclude paths/files matching the exclusion pattern", function() {
<add> (() => requireInContext("dont")).
<add> should.throw(/Cannot find module '.\/dont'/);
<add>
<add> (() => requireInContext("dont-check-here/file")).
<add> should.throw(/Cannot find module '.\/dont-check-here\/file'/);
<add>
<add> (() => requireInContext("check-here/dont-check-here/file")).
<add> should.throw(/Cannot find module '.\/check-here\/dont-check-here\/file'/);
<add>});
<ide><path>test/configCases/context-exclusion/simple/some-dir/check-here/check-here/file.js
<add>module.exports = "thats good";
<ide><path>test/configCases/context-exclusion/simple/some-dir/check-here/dont-check-here/file.js
<add>module.exports = "thats bad";
<ide><path>test/configCases/context-exclusion/simple/some-dir/check-here/file.js
<add>module.exports = "thats good";
<ide><path>test/configCases/context-exclusion/simple/some-dir/dont-check-here/file.js
<add>module.exports = "thats bad";
<ide><path>test/configCases/context-exclusion/simple/some-dir/dont.js
<add>module.exports = "thats bad";
<ide><path>test/configCases/context-exclusion/simple/some-dir/file.js
<add>module.exports = "thats good";
<ide><path>test/configCases/context-exclusion/simple/webpack.config.js
<add>var webpack = require("../../../../");
<add>
<add>module.exports = {
<add> plugins: [
<add> new webpack.ContextExclusionPlugin(/dont/)
<add> ]
<add>}; | 8 |
Text | Text | fix typo in documentation | f26fea92af0113672c6c6329885c219a063432e9 | <ide><path>docs/migrating/from-create-react-app.md
<ide> export default function Home() {
<ide>
<ide> ## Environment Variables
<ide>
<del>Next.js has support for `.env` [Environment Variables](/docs/basic-features/environment-variables.md) similar to Create React App. The main different is the prefix used to expose environment variables on the client-side.
<add>Next.js has support for `.env` [Environment Variables](/docs/basic-features/environment-variables.md) similar to Create React App. The main difference is the prefix used to expose environment variables on the client-side.
<ide>
<ide> - Change all environment variables with the `REACT_APP_` prefix to `NEXT_PUBLIC_`.
<ide> - Server-side environment variables will be available at build-time and in [API Routes](/docs/api-routes/introduction.md). | 1 |
Ruby | Ruby | add pkgutil version for xquartz 2.7.5_rc4 | 466cc33bf323430a9dfa24fa126028a7d2a42f85 | <ide><path>Library/Homebrew/os/mac/xquartz.rb
<ide> module XQuartz
<ide> "2.7.50" => "2.7.5_rc1",
<ide> "2.7.51" => "2.7.5_rc2",
<ide> "2.7.52" => "2.7.5_rc3",
<add> "2.7.53" => "2.7.5_rc4",
<ide> }.freeze
<ide>
<ide> # This returns the version number of XQuartz, not of the upstream X.org. | 1 |
Javascript | Javascript | replace uses of self | 74c1e0264296d9dbd9bff9dae63ba9c81cae45d4 | <ide><path>lib/_http_client.js
<ide> function isInvalidPath(s) {
<ide> }
<ide>
<ide> function ClientRequest(options, cb) {
<del> var self = this;
<del> OutgoingMessage.call(self);
<add> OutgoingMessage.call(this);
<ide>
<ide> if (typeof options === 'string') {
<ide> options = url.parse(options);
<ide> function ClientRequest(options, cb) {
<ide> 'Agent option must be an instance of http.Agent, undefined or false.'
<ide> );
<ide> }
<del> self.agent = agent;
<add> this.agent = agent;
<ide>
<ide> var protocol = options.protocol || defaultAgent.protocol;
<ide> var expectedProtocol = defaultAgent.protocol;
<del> if (self.agent && self.agent.protocol)
<del> expectedProtocol = self.agent.protocol;
<add> if (this.agent && this.agent.protocol)
<add> expectedProtocol = this.agent.protocol;
<ide>
<ide> var path;
<ide> if (options.path) {
<ide> function ClientRequest(options, cb) {
<ide> }
<ide>
<ide> const defaultPort = options.defaultPort ||
<del> self.agent && self.agent.defaultPort;
<add> this.agent && this.agent.defaultPort;
<ide>
<ide> var port = options.port = options.port || defaultPort || 80;
<ide> var host = options.host = options.hostname || options.host || 'localhost';
<ide>
<ide> var setHost = (options.setHost === undefined);
<ide>
<del> self.socketPath = options.socketPath;
<del> self.timeout = options.timeout;
<add> this.socketPath = options.socketPath;
<add> this.timeout = options.timeout;
<ide>
<ide> var method = options.method;
<ide> var methodIsString = (typeof method === 'string');
<ide> function ClientRequest(options, cb) {
<ide> if (!common._checkIsHttpToken(method)) {
<ide> throw new TypeError('Method must be a valid HTTP token');
<ide> }
<del> method = self.method = method.toUpperCase();
<add> method = this.method = method.toUpperCase();
<ide> } else {
<del> method = self.method = 'GET';
<add> method = this.method = 'GET';
<ide> }
<ide>
<del> self.path = options.path || '/';
<add> this.path = options.path || '/';
<ide> if (cb) {
<del> self.once('response', cb);
<add> this.once('response', cb);
<ide> }
<ide>
<ide> var headersArray = Array.isArray(options.headers);
<ide> function ClientRequest(options, cb) {
<ide> var keys = Object.keys(options.headers);
<ide> for (var i = 0; i < keys.length; i++) {
<ide> var key = keys[i];
<del> self.setHeader(key, options.headers[key]);
<add> this.setHeader(key, options.headers[key]);
<ide> }
<ide> }
<ide> if (host && !this.getHeader('host') && setHost) {
<ide> function ClientRequest(options, cb) {
<ide> method === 'DELETE' ||
<ide> method === 'OPTIONS' ||
<ide> method === 'CONNECT') {
<del> self.useChunkedEncodingByDefault = false;
<add> this.useChunkedEncodingByDefault = false;
<ide> } else {
<del> self.useChunkedEncodingByDefault = true;
<add> this.useChunkedEncodingByDefault = true;
<ide> }
<ide>
<ide> if (headersArray) {
<del> self._storeHeader(self.method + ' ' + self.path + ' HTTP/1.1\r\n',
<add> this._storeHeader(this.method + ' ' + this.path + ' HTTP/1.1\r\n',
<ide> options.headers);
<del> } else if (self.getHeader('expect')) {
<del> if (self._header) {
<add> } else if (this.getHeader('expect')) {
<add> if (this._header) {
<ide> throw new Error('Can\'t render headers after they are sent to the ' +
<ide> 'client');
<ide> }
<del> self._storeHeader(self.method + ' ' + self.path + ' HTTP/1.1\r\n',
<del> self[outHeadersKey]);
<add>
<add> this._storeHeader(this.method + ' ' + this.path + ' HTTP/1.1\r\n',
<add> this[outHeadersKey]);
<ide> }
<ide>
<ide> this._ended = false;
<ide> function ClientRequest(options, cb) {
<ide> this.maxHeadersCount = null;
<ide>
<ide> var called = false;
<del> if (self.socketPath) {
<del> self._last = true;
<del> self.shouldKeepAlive = false;
<add>
<add> const oncreate = (err, socket) => {
<add> if (called)
<add> return;
<add> called = true;
<add> if (err) {
<add> process.nextTick(() => this.emit('error', err));
<add> return;
<add> }
<add> this.onSocket(socket);
<add> this._deferToConnect(null, null, () => this._flush());
<add> };
<add>
<add> if (this.socketPath) {
<add> this._last = true;
<add> this.shouldKeepAlive = false;
<ide> const optionsPath = {
<del> path: self.socketPath,
<del> timeout: self.timeout
<add> path: this.socketPath,
<add> timeout: this.timeout
<ide> };
<del> const newSocket = self.agent.createConnection(optionsPath, oncreate);
<add> const newSocket = this.agent.createConnection(optionsPath, oncreate);
<ide> if (newSocket && !called) {
<ide> called = true;
<del> self.onSocket(newSocket);
<add> this.onSocket(newSocket);
<ide> } else {
<ide> return;
<ide> }
<del> } else if (self.agent) {
<add> } else if (this.agent) {
<ide> // If there is an agent we should default to Connection:keep-alive,
<ide> // but only if the Agent will actually reuse the connection!
<ide> // If it's not a keepAlive agent, and the maxSockets==Infinity, then
<ide> // there's never a case where this socket will actually be reused
<del> if (!self.agent.keepAlive && !Number.isFinite(self.agent.maxSockets)) {
<del> self._last = true;
<del> self.shouldKeepAlive = false;
<add> if (!this.agent.keepAlive && !Number.isFinite(this.agent.maxSockets)) {
<add> this._last = true;
<add> this.shouldKeepAlive = false;
<ide> } else {
<del> self._last = false;
<del> self.shouldKeepAlive = true;
<add> this._last = false;
<add> this.shouldKeepAlive = true;
<ide> }
<del> self.agent.addRequest(self, options);
<add> this.agent.addRequest(this, options);
<ide> } else {
<ide> // No agent, default to Connection:close.
<del> self._last = true;
<del> self.shouldKeepAlive = false;
<add> this._last = true;
<add> this.shouldKeepAlive = false;
<ide> if (typeof options.createConnection === 'function') {
<ide> const newSocket = options.createConnection(options, oncreate);
<ide> if (newSocket && !called) {
<ide> called = true;
<del> self.onSocket(newSocket);
<add> this.onSocket(newSocket);
<ide> } else {
<ide> return;
<ide> }
<ide> } else {
<ide> debug('CLIENT use net.createConnection', options);
<del> self.onSocket(net.createConnection(options));
<del> }
<del> }
<del>
<del> function oncreate(err, socket) {
<del> if (called)
<del> return;
<del> called = true;
<del> if (err) {
<del> process.nextTick(function() {
<del> self.emit('error', err);
<del> });
<del> return;
<add> this.onSocket(net.createConnection(options));
<ide> }
<del> self.onSocket(socket);
<del> self._deferToConnect(null, null, function() {
<del> self._flush();
<del> self = null;
<del> });
<ide> }
<ide>
<del> self._deferToConnect(null, null, function() {
<del> self._flush();
<del> self = null;
<del> });
<add> this._deferToConnect(null, null, () => this._flush());
<ide> }
<ide>
<ide> util.inherits(ClientRequest, OutgoingMessage);
<ide> ClientRequest.prototype._implicitHeader = function _implicitHeader() {
<ide>
<ide> ClientRequest.prototype.abort = function abort() {
<ide> if (!this.aborted) {
<del> process.nextTick(emitAbortNT, this);
<add> process.nextTick(emitAbortNT.bind(this));
<ide> }
<ide> // Mark as aborting so we can avoid sending queued request data
<ide> // This is used as a truthy flag elsewhere. The use of Date.now is for
<ide> ClientRequest.prototype.abort = function abort() {
<ide> };
<ide>
<ide>
<del>function emitAbortNT(self) {
<del> self.emit('abort');
<add>function emitAbortNT() {
<add> this.emit('abort');
<ide> }
<ide>
<ide>
<ide> function _deferToConnect(method, arguments_, cb) {
<ide> // calls that happen either now (when a socket is assigned) or
<ide> // in the future (when a socket gets assigned out of the pool and is
<ide> // eventually writable).
<del> var self = this;
<ide>
<del> function callSocketMethod() {
<add> const callSocketMethod = () => {
<ide> if (method)
<del> self.socket[method].apply(self.socket, arguments_);
<add> this.socket[method].apply(this.socket, arguments_);
<ide>
<ide> if (typeof cb === 'function')
<ide> cb();
<del> }
<add> };
<ide>
<del> var onSocket = function onSocket() {
<del> if (self.socket.writable) {
<add> const onSocket = () => {
<add> if (this.socket.writable) {
<ide> callSocketMethod();
<ide> } else {
<del> self.socket.once('connect', callSocketMethod);
<add> this.socket.once('connect', callSocketMethod);
<ide> }
<ide> };
<ide>
<del> if (!self.socket) {
<del> self.once('socket', onSocket);
<add> if (!this.socket) {
<add> this.once('socket', onSocket);
<ide> } else {
<ide> onSocket();
<ide> }
<ide> function _deferToConnect(method, arguments_, cb) {
<ide> ClientRequest.prototype.setTimeout = function setTimeout(msecs, callback) {
<ide> if (callback) this.once('timeout', callback);
<ide>
<del> var self = this;
<del> function emitTimeout() {
<del> self.emit('timeout');
<del> }
<add> const emitTimeout = () => this.emit('timeout');
<ide>
<ide> if (this.socket && this.socket.writable) {
<ide> if (this.timeoutCb)
<ide><path>lib/_http_outgoing.js
<ide> const crlf_buf = Buffer.from('\r\n');
<ide> OutgoingMessage.prototype.write = function write(chunk, encoding, callback) {
<ide> if (this.finished) {
<ide> var err = new Error('write after end');
<del> process.nextTick(writeAfterEndNT, this, err, callback);
<add> process.nextTick(writeAfterEndNT.bind(this), err, callback);
<ide>
<ide> return true;
<ide> }
<ide> OutgoingMessage.prototype.write = function write(chunk, encoding, callback) {
<ide> };
<ide>
<ide>
<del>function writeAfterEndNT(self, err, callback) {
<del> self.emit('error', err);
<add>function writeAfterEndNT(err, callback) {
<add> this.emit('error', err);
<ide> if (callback) callback(err);
<ide> }
<ide> | 2 |
Python | Python | improve type hinting to provider cloudant | 35fe97225ee0a29aa350bb6ed805428fd707ab2f | <ide><path>airflow/providers/cloudant/hooks/cloudant.py
<ide> class CloudantHook(BaseHook):
<ide> :type cloudant_conn_id: str
<ide> """
<ide>
<del> def __init__(self, cloudant_conn_id='cloudant_default'):
<add> def __init__(self, cloudant_conn_id: str = 'cloudant_default') -> None:
<ide> super().__init__()
<ide> self.cloudant_conn_id = cloudant_conn_id
<ide>
<del> def get_conn(self):
<add> def get_conn(self) -> cloudant:
<ide> """
<ide> Opens a connection to the cloudant service and closes it automatically if used as context manager.
<ide>
<ide> def get_conn(self):
<ide>
<ide> return cloudant_session
<ide>
<del> def _validate_connection(self, conn):
<add> def _validate_connection(self, conn: cloudant) -> None:
<ide> for conn_param in ['login', 'password']:
<ide> if not getattr(conn, conn_param):
<ide> raise AirflowException('missing connection parameter {conn_param}'.format( | 1 |
Text | Text | update react info on index.md | 647f51549896e0de2b62fe38ecb446c744153603 | <ide><path>guide/portuguese/react/index.md
<ide> localeTitle: React
<ide> ---
<ide> # React
<ide>
<del>React é uma biblioteca JavaScript para criar interfaces com o usuário. Ele foi eleito o mais amado na categoria "Frameworks, bibliotecas e outras tecnologias" da Pesquisa de desenvolvedores do Stack Overflow 2017. 1
<add>React é uma biblioteca JavaScript para criar interfaces com o usuário. É mantido pelo Facebook, Instagram e uma comunidade de desenvolvedores individuais e outras empresas. Ele foi eleito o mais amado na categoria "Frameworks, bibliotecas e outras tecnologias" da Pesquisa de desenvolvedores do Stack Overflow 2017. 1
<ide>
<ide> React é uma biblioteca JavaScript e os aplicativos React criados nele são executados no navegador, NÃO no servidor. Aplicativos desse tipo só se comunicam com o servidor quando necessário, o que os torna muito rápidos em comparação com os sites tradicionais que forçam o usuário a esperar que o servidor renderize novamente páginas inteiras e as envie para o navegador.
<ide> | 1 |
Ruby | Ruby | add a time to duplicable tests | fb0673f5ad7cf3fc54f922f3215be0b0107de29b | <ide><path>activesupport/test/core_ext/duplicable_test.rb
<ide>
<ide> class DuplicableTest < Test::Unit::TestCase
<ide> NO = [nil, false, true, :symbol, 1, 2.3, BigDecimal.new('4.56')]
<del> YES = ['1', Object.new, /foo/, [], {}]
<add> YES = ['1', Object.new, /foo/, [], {}, Time.now]
<ide>
<ide> def test_duplicable
<ide> NO.each do |v| | 1 |
Python | Python | fix flake8 error | 4e2a59afd8c8ef70bfe387e470531e8bf87c1587 | <ide><path>celery/backends/elasticsearch.py
<ide> from celery.exceptions import ImproperlyConfigured
<ide> from celery.five import items
<ide>
<del>from .base import KeyValueStoreBackend, Backend
<add>from .base import KeyValueStoreBackend
<ide>
<ide> try:
<ide> import elasticsearch | 1 |
Javascript | Javascript | ignore these tests during dst | 2e5163ddf39844a077489af8e0de87eebca7957e | <ide><path>src/test/helpers/dst.js
<add>import moment from '../../moment';
<add>
<add>export function isNearSpringDST() {
<add> return moment().subtract(1, 'day').utcOffset() !== moment().add(1, 'day').utcOffset();
<add>}
<ide><path>src/test/moment/zone_switching.js
<del>import { module, test } from '../qunit';
<add>import { module, test, expect } from '../qunit';
<ide> import moment from '../../moment';
<add>import { isNearSpringDST } from '../helpers/dst';
<ide>
<ide> module('zone switching');
<ide>
<ide> test('local to zone, keepLocalTime = false', function (assert) {
<ide> });
<ide>
<ide> test('utc to local, keepLocalTime = true', function (assert) {
<add> // Don't test near the spring DST transition
<add> if (isNearSpringDST()) {
<add> expect(0);
<add> return;
<add> }
<add>
<ide> var um = moment.utc(),
<ide> fmt = 'YYYY-DD-MM HH:mm:ss';
<ide>
<ide> test('utc to local, keepLocalTime = false', function (assert) {
<ide> });
<ide>
<ide> test('zone to local, keepLocalTime = true', function (assert) {
<add> // Don't test near the spring DST transition
<add> if (isNearSpringDST()) {
<add> expect(0);
<add> return;
<add> }
<add>
<ide> var m = moment(),
<ide> fmt = 'YYYY-DD-MM HH:mm:ss',
<ide> z; | 2 |
Text | Text | expand comment types in java | 0ec3c322a496f5f6303cc0da681b388cf4116261 | <ide><path>guide/english/java/comments-in-java/index.md
<ide> public class RandomNumbers{
<ide> }
<ide> ```
<ide>
<add>The difference between the documentation comment and the multi & single line comments is that the former is oriented about making your comments visible to anyone viewing the documentation, while the multi and single line comments are the ones that are supposed to mainly keep you on track.
<ide>
<ide> #### More Information:
<ide> * [Java Resources](http://guide.freecodecamp.org/java/resources/) | 1 |
Javascript | Javascript | add support for brackets around the header emails | e21d7b3000243e16cdd812c22f38591f5457872e | <ide><path>PDFFont.js
<ide> var Fonts = {
<ide> this._active = this[aFontName];
<ide> },
<ide>
<del> getUnicodeFor: function fonts_getUnicodeFor(aCode) {
<del> var glyph = this._active.encoding[aCode];
<del> var unicode = "0x" + GlyphsUnicode[glyph];
<del> return unicode || aCode;
<add> unicodeFromCode: function fonts_unicodeFromCode(aCode) {
<add> var active = this._active;
<add> if (!active)
<add> return aCode;
<add>
<add> var difference = active.encoding[aCode];
<add> var unicode = GlyphsUnicode[difference];
<add> return unicode ? "0x" + unicode : aCode;
<ide> }
<ide> };
<ide> | 1 |
Ruby | Ruby | fix typo for redirect_back | 1d6b77cc4dcda6643f14e7b57eed121eedede84d | <ide><path>actionpack/lib/action_controller/metal/redirecting.rb
<ide> def redirect_to(options = {}, response_status = {}) #:doc:
<ide> # redirect_back fallback_location: proc { edit_post_url(@post) }
<ide> #
<ide> # All options that can be passed to <tt>redirect_to</tt> are accepted as
<del> # options and the behavior is indetical.
<add> # options and the behavior is identical.
<ide> def redirect_back(fallback_location:, **args)
<ide> if referer = request.headers["Referer"]
<ide> redirect_to referer, **args | 1 |
Javascript | Javascript | reuse the row uint8array in jbig2's decodebitmap | 840d9d40b6e7c4e3dc0b341b8f52bf68c7d3e53b | <ide><path>src/core/jbig2.js
<ide> var Jbig2Image = (function Jbig2ImageClosure() {
<ide> var sbb_right = width - maxX;
<ide>
<ide> var pseudoPixelContext = ReusedContexts[templateIndex];
<add> var row = new Uint8Array(width);
<ide> var bitmap = [];
<ide>
<ide> var decoder = decodingContext.decoder;
<ide> var Jbig2Image = (function Jbig2ImageClosure() {
<ide> var sltp = decoder.readBit(contexts, pseudoPixelContext);
<ide> ltp ^= sltp;
<ide> if (ltp) {
<del> bitmap[i] = row;//bitmap[i - 1]); // duplicate previous row
<add> bitmap.push(row); // duplicate previous row
<ide> continue;
<ide> }
<ide> }
<del> var row = new Uint8Array(width);
<add> row = new Uint8Array(row);
<ide> bitmap.push(row);
<ide> for (j = 0; j < width; j++) {
<ide> if (useskip && skip[i][j]) { | 1 |
Text | Text | update readme with results for comparison | b181b9885cd92804dc8de5c339b03bfcd6877d98 | <ide><path>compression/README.md
<ide> To generate these metrics on your images you can run:
<ide> --compared_image=/tmp/decoded/image_15.png`
<ide>
<ide>
<add>## Results
<add>CSV results containing the post-entropy bitrates and MS-SSIM over Kodak can
<add>are available for reference. Each row of the CSV represents each of the Kodak
<add>images in their dataset number (1-24). Each column of the CSV represents each
<add>iteration of the model (1-16).
<add>
<add>[Post Entropy Bitrates](https://storage.googleapis.com/compression-ml/residual_gru_results/bitrate.csv)
<add>
<add>[MS-SSIM](https://storage.googleapis.com/compression-ml/residual_gru_results/msssim.csv)
<add>
<add>
<ide> ## FAQ
<ide>
<ide> #### How do I train my own compression network? | 1 |
Text | Text | replace window by self for js challenges | 9b75c1965a2f624388584b407ed749b7cc4a98cc | <ide><path>curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/create-an-export-fallback-with-export-default.english.md
<ide> function subtract(x,y) {return x - y;}
<ide> <div id='js-setup'>
<ide>
<ide> ```js
<del>window.exports = function(){};
<add>self.exports = function(){};
<ide> ```
<ide>
<ide> </div>
<ide>
<del>
<ide> </section>
<ide>
<ide> ## Solution
<ide> <section id='solution'>
<ide>
<ide> ```js
<del>// solution required
<add>export default function subtract(x,y) {return x - y;}
<ide> ```
<add>
<ide> </section>
<ide><path>curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/import-a-default-export.english.md
<ide> subtract(7,4);
<ide> <div id='js-setup'>
<ide>
<ide> ```js
<del>window.require = function(str) {
<del>if (str === 'math_functions') {
<del>return function(a, b) {
<del>return a - b;
<del>}}};
<add>self.require = function(str) {
<add> if (str === 'math_functions') {
<add> return function(a, b) {
<add> return a - b;
<add> }
<add> }
<add>};
<ide> ```
<ide>
<ide> </div>
<ide>
<del>
<ide> </section>
<ide>
<ide> ## Solution
<ide> <section id='solution'>
<ide>
<ide> ```js
<del>// solution required
<add>import subtract from "math_functions";
<add>subtract(7,4);
<ide> ```
<add>
<ide> </section>
<ide><path>curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/understand-the-differences-between-import-and-require.english.md
<ide> capitalizeString("hello!");
<ide> <div id='js-setup'>
<ide>
<ide> ```js
<del>window.require = function (str) {
<del>if (str === 'string_functions') {
<del>return {
<del>capitalizeString: str => str.toUpperCase()
<del>}}};
<add>self.require = function (str) {
<add> if (str === 'string_functions') {
<add> return {
<add> capitalizeString: str => str.toUpperCase()
<add> }
<add> }
<add>};
<ide> ```
<ide>
<ide> </div>
<ide>
<del>
<ide> </section>
<ide>
<ide> ## Solution
<ide> <section id='solution'>
<ide>
<ide> ```js
<del>// solution required
<add>import { capitalizeString } from 'string_functions';
<add>capitalizeString("hello!");
<ide> ```
<add>
<ide> </section>
<ide><path>curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use--to-import-everything-from-a-file.english.md
<ide> tests:
<ide> <div id='js-setup'>
<ide>
<ide> ```js
<del>window.require = function(str) {
<del>if (str === 'capitalize_strings') {
<del>return {
<del>capitalize: str => str.toUpperCase(),
<del>lowercase: str => str.toLowerCase()
<del>}}};
<add>self.require = function(str) {
<add> if (str === 'capitalize_strings') {
<add> return {
<add> capitalize: str => str.toUpperCase(),
<add> lowercase: str => str.toLowerCase()
<add> }
<add> }
<add>};
<ide> ```
<ide>
<ide> </div>
<ide>
<del>
<ide> </section>
<ide>
<ide> ## Solution
<ide> <section id='solution'>
<ide>
<ide> ```js
<del>// solution required
<add>import * as capitalize_strings from "capitalize_strings";
<ide> ```
<add>
<ide> </section>
<ide><path>curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-export-to-reuse-a-code-block.english.md
<ide> const bar = "foo";
<ide> <div id='js-setup'>
<ide>
<ide> ```js
<del>window.exports = function(){};
<add>self.exports = function(){};
<ide> ```
<ide>
<ide> </div> | 5 |
Javascript | Javascript | convert `util` to a class with static methods | f6c4a1f08088c707be90a774ae394951d94133de | <ide><path>src/shared/util.js
<ide> function isEvalSupported() {
<ide> }
<ide> }
<ide>
<del>var Util = (function UtilClosure() {
<del> function Util() {}
<add>const rgbBuf = ['rgb(', 0, ',', 0, ',', 0, ')'];
<ide>
<del> var rgbBuf = ['rgb(', 0, ',', 0, ',', 0, ')'];
<del>
<del> // makeCssRgb() can be called thousands of times. Using |rgbBuf| avoids
<add>class Util {
<add> // makeCssRgb() can be called thousands of times. Using ´rgbBuf` avoids
<ide> // creating many intermediate strings.
<del> Util.makeCssRgb = function Util_makeCssRgb(r, g, b) {
<add> static makeCssRgb(r, g, b) {
<ide> rgbBuf[1] = r;
<ide> rgbBuf[3] = g;
<ide> rgbBuf[5] = b;
<ide> return rgbBuf.join('');
<del> };
<add> }
<ide>
<ide> // Concatenates two transformation matrices together and returns the result.
<del> Util.transform = function Util_transform(m1, m2) {
<add> static transform(m1, m2) {
<ide> return [
<ide> m1[0] * m2[0] + m1[2] * m2[1],
<ide> m1[1] * m2[0] + m1[3] * m2[1],
<ide> var Util = (function UtilClosure() {
<ide> m1[0] * m2[4] + m1[2] * m2[5] + m1[4],
<ide> m1[1] * m2[4] + m1[3] * m2[5] + m1[5]
<ide> ];
<del> };
<add> }
<ide>
<ide> // For 2d affine transforms
<del> Util.applyTransform = function Util_applyTransform(p, m) {
<del> var xt = p[0] * m[0] + p[1] * m[2] + m[4];
<del> var yt = p[0] * m[1] + p[1] * m[3] + m[5];
<add> static applyTransform(p, m) {
<add> const xt = p[0] * m[0] + p[1] * m[2] + m[4];
<add> const yt = p[0] * m[1] + p[1] * m[3] + m[5];
<ide> return [xt, yt];
<del> };
<add> }
<ide>
<del> Util.applyInverseTransform = function Util_applyInverseTransform(p, m) {
<del> var d = m[0] * m[3] - m[1] * m[2];
<del> var xt = (p[0] * m[3] - p[1] * m[2] + m[2] * m[5] - m[4] * m[3]) / d;
<del> var yt = (-p[0] * m[1] + p[1] * m[0] + m[4] * m[1] - m[5] * m[0]) / d;
<add> static applyInverseTransform(p, m) {
<add> const d = m[0] * m[3] - m[1] * m[2];
<add> const xt = (p[0] * m[3] - p[1] * m[2] + m[2] * m[5] - m[4] * m[3]) / d;
<add> const yt = (-p[0] * m[1] + p[1] * m[0] + m[4] * m[1] - m[5] * m[0]) / d;
<ide> return [xt, yt];
<del> };
<add> }
<ide>
<ide> // Applies the transform to the rectangle and finds the minimum axially
<ide> // aligned bounding box.
<del> Util.getAxialAlignedBoundingBox =
<del> function Util_getAxialAlignedBoundingBox(r, m) {
<del>
<del> var p1 = Util.applyTransform(r, m);
<del> var p2 = Util.applyTransform(r.slice(2, 4), m);
<del> var p3 = Util.applyTransform([r[0], r[3]], m);
<del> var p4 = Util.applyTransform([r[2], r[1]], m);
<add> static getAxialAlignedBoundingBox(r, m) {
<add> const p1 = Util.applyTransform(r, m);
<add> const p2 = Util.applyTransform(r.slice(2, 4), m);
<add> const p3 = Util.applyTransform([r[0], r[3]], m);
<add> const p4 = Util.applyTransform([r[2], r[1]], m);
<ide> return [
<ide> Math.min(p1[0], p2[0], p3[0], p4[0]),
<ide> Math.min(p1[1], p2[1], p3[1], p4[1]),
<ide> Math.max(p1[0], p2[0], p3[0], p4[0]),
<ide> Math.max(p1[1], p2[1], p3[1], p4[1])
<ide> ];
<del> };
<add> }
<ide>
<del> Util.inverseTransform = function Util_inverseTransform(m) {
<del> var d = m[0] * m[3] - m[1] * m[2];
<add> static inverseTransform(m) {
<add> const d = m[0] * m[3] - m[1] * m[2];
<ide> return [m[3] / d, -m[1] / d, -m[2] / d, m[0] / d,
<ide> (m[2] * m[5] - m[4] * m[3]) / d, (m[4] * m[1] - m[5] * m[0]) / d];
<del> };
<add> }
<ide>
<ide> // Apply a generic 3d matrix M on a 3-vector v:
<ide> // | a b c | | X |
<ide> // | d e f | x | Y |
<ide> // | g h i | | Z |
<ide> // M is assumed to be serialized as [a,b,c,d,e,f,g,h,i],
<ide> // with v as [X,Y,Z]
<del> Util.apply3dTransform = function Util_apply3dTransform(m, v) {
<add> static apply3dTransform(m, v) {
<ide> return [
<ide> m[0] * v[0] + m[1] * v[1] + m[2] * v[2],
<ide> m[3] * v[0] + m[4] * v[1] + m[5] * v[2],
<ide> m[6] * v[0] + m[7] * v[1] + m[8] * v[2]
<ide> ];
<del> };
<add> }
<ide>
<ide> // This calculation uses Singular Value Decomposition.
<ide> // The SVD can be represented with formula A = USV. We are interested in the
<ide> // matrix S here because it represents the scale values.
<del> Util.singularValueDecompose2dScale =
<del> function Util_singularValueDecompose2dScale(m) {
<del>
<del> var transpose = [m[0], m[2], m[1], m[3]];
<add> static singularValueDecompose2dScale(m) {
<add> const transpose = [m[0], m[2], m[1], m[3]];
<ide>
<ide> // Multiply matrix m with its transpose.
<del> var a = m[0] * transpose[0] + m[1] * transpose[2];
<del> var b = m[0] * transpose[1] + m[1] * transpose[3];
<del> var c = m[2] * transpose[0] + m[3] * transpose[2];
<del> var d = m[2] * transpose[1] + m[3] * transpose[3];
<add> const a = m[0] * transpose[0] + m[1] * transpose[2];
<add> const b = m[0] * transpose[1] + m[1] * transpose[3];
<add> const c = m[2] * transpose[0] + m[3] * transpose[2];
<add> const d = m[2] * transpose[1] + m[3] * transpose[3];
<ide>
<ide> // Solve the second degree polynomial to get roots.
<del> var first = (a + d) / 2;
<del> var second = Math.sqrt((a + d) * (a + d) - 4 * (a * d - c * b)) / 2;
<del> var sx = first + second || 1;
<del> var sy = first - second || 1;
<add> const first = (a + d) / 2;
<add> const second = Math.sqrt((a + d) * (a + d) - 4 * (a * d - c * b)) / 2;
<add> const sx = first + second || 1;
<add> const sy = first - second || 1;
<ide>
<ide> // Scale values are the square roots of the eigenvalues.
<ide> return [Math.sqrt(sx), Math.sqrt(sy)];
<del> };
<add> }
<ide>
<ide> // Normalize rectangle rect=[x1, y1, x2, y2] so that (x1,y1) < (x2,y2)
<ide> // For coordinate systems whose origin lies in the bottom-left, this
<ide> // means normalization to (BL,TR) ordering. For systems with origin in the
<ide> // top-left, this means (TL,BR) ordering.
<del> Util.normalizeRect = function Util_normalizeRect(rect) {
<del> var r = rect.slice(0); // clone rect
<add> static normalizeRect(rect) {
<add> const r = rect.slice(0); // clone rect
<ide> if (rect[0] > rect[2]) {
<ide> r[0] = rect[2];
<ide> r[2] = rect[0];
<ide> var Util = (function UtilClosure() {
<ide> r[3] = rect[1];
<ide> }
<ide> return r;
<del> };
<add> }
<ide>
<ide> // Returns a rectangle [x1, y1, x2, y2] corresponding to the
<ide> // intersection of rect1 and rect2. If no intersection, returns 'false'
<ide> // The rectangle coordinates of rect1, rect2 should be [x1, y1, x2, y2]
<del> Util.intersect = function Util_intersect(rect1, rect2) {
<add> static intersect(rect1, rect2) {
<ide> function compare(a, b) {
<ide> return a - b;
<ide> }
<ide>
<ide> // Order points along the axes
<del> var orderedX = [rect1[0], rect1[2], rect2[0], rect2[2]].sort(compare),
<del> orderedY = [rect1[1], rect1[3], rect2[1], rect2[3]].sort(compare),
<del> result = [];
<add> const orderedX = [rect1[0], rect1[2], rect2[0], rect2[2]].sort(compare);
<add> const orderedY = [rect1[1], rect1[3], rect2[1], rect2[3]].sort(compare);
<add> const result = [];
<ide>
<ide> rect1 = Util.normalizeRect(rect1);
<ide> rect2 = Util.normalizeRect(rect2);
<ide> var Util = (function UtilClosure() {
<ide> }
<ide>
<ide> return result;
<del> };
<del>
<del> return Util;
<del>})();
<add> }
<add>}
<ide>
<ide> const PDFStringTranslateTable = [
<ide> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | 1 |
PHP | PHP | apply fixes from styleci | 274e81829b643fe4cf20b302ffaff5100c1a8f2b | <ide><path>src/Illuminate/Auth/Authenticatable.php
<ide> trait Authenticatable
<ide> public function logoutOtherDevices($password, $attribute = 'password')
<ide> {
<ide> return tap($this->forceFill([
<del> $attribute => Hash::make($password)
<add> $attribute => Hash::make($password),
<ide> ]))->save();
<ide> }
<ide> | 1 |
Text | Text | add 1.3.2 release notes | 4dd3368b51b2b00936f91fcc951d81d0c0d918ae | <ide><path>docs/sources/release-notes.md
<ide> page_keywords: docker, documentation, about, technology, understanding, release
<ide>
<ide> #Release Notes
<ide>
<add>##Version 1.3.2
<add>(2014-11-24)
<add>
<add>This release fixes some bugs and addresses some security issues. We have also
<add>made improvements to aspects of `docker run`.
<add>
<add>*Security fixes*
<add>
<add>Patches and changes were made to address CVE-2014-6407 and CVE-2014-6408.
<add>Specifically, changes were made in order to:
<add>
<add>* Prevent host privilege escalation from an image extraction vulnerability (CVE-2014-6407).
<add>
<add>* Prevent container escalation from malicious security options applied to images (CVE-2014-6408).
<add>
<add>*Daemon fixes*
<add>
<add>The `--insecure-registry` flag of the `docker run` command has undergone
<add>several refinements and additions. For details, please see the
<add>[command-line reference](http://docs.docker.com/reference/commandline/cli/#run).
<add>
<add>* You can now specify a sub-net in order to set a range of registries which the Docker daemon will consider insecure.
<add>
<add>* By default, Docker now defines `localhost` as an insecure registry.
<add>
<add>* Registries can now be referenced using the Classless Inter-Domain Routing (CIDR) format.
<add>
<add>* When mirroring is enabled, the experimental registry v2 API is skipped.
<add>
<ide> ##Version 1.3.1
<ide> (2014-10-28)
<ide> | 1 |
Text | Text | add example use of serializermethodfield to docs | 5f4c385a86b877217c1e1bc2eaff58206eabb747 | <ide><path>docs/api-guide/fields.md
<ide> This field is always read-only.
<ide>
<ide> ## SerializerMethodField
<ide>
<del>This is a read-only field. It gets its value by calling a method on the serializer class it is attached to. It can be used to add any sort of data to the serialized representation of your object. The field's constructor accepts a single argument, which is the name of the method on the serializer to be called. The method should accept a single argument (in addition to `self`), which is the object being serialized. It should return whatever you want to be included in the serialized representation of the object.
<add>This is a read-only field. It gets its value by calling a method on the serializer class it is attached to. It can be used to add any sort of data to the serialized representation of your object. The field's constructor accepts a single argument, which is the name of the method on the serializer to be called. The method should accept a single argument (in addition to `self`), which is the object being serialized. It should return whatever you want to be included in the serialized representation of the object. For example:
<add>
<add> from rest_framework import serializers
<add> from django.contrib.auth.models import User
<add> from django.utils.timezone import now
<add>
<add> class UserSerializer(serializers.ModelSerializer):
<add>
<add> days_since_joined = serializers.SerializerMethodField('get_days_since_joined')
<add>
<add> class Meta:
<add> model = User
<add>
<add> def get_days_since_joined(self, obj):
<add> return (now() - obj.date_joined).days
<ide>
<ide> [cite]: http://www.python.org/dev/peps/pep-0020/
<ide> [FILE_UPLOAD_HANDLERS]: https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-FILE_UPLOAD_HANDLERS | 1 |
Java | Java | expose localaddress in webflux server | 1b172c1d20ecf96839abc02a67ae2a763af2815e | <ide><path>spring-test/src/main/java/org/springframework/mock/http/server/reactive/MockServerHttpRequest.java
<ide> /*
<del> * Copyright 2002-2018 the original author or authors.
<add> * Copyright 2002-2019 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> public final class MockServerHttpRequest extends AbstractServerHttpRequest {
<ide> @Nullable
<ide> private final InetSocketAddress remoteAddress;
<ide>
<add> @Nullable
<add> private final InetSocketAddress localAddress;
<add>
<ide> @Nullable
<ide> private final SslInfo sslInfo;
<ide>
<ide> public final class MockServerHttpRequest extends AbstractServerHttpRequest {
<ide>
<ide> private MockServerHttpRequest(HttpMethod httpMethod, URI uri, @Nullable String contextPath,
<ide> HttpHeaders headers, MultiValueMap<String, HttpCookie> cookies,
<del> @Nullable InetSocketAddress remoteAddress, @Nullable SslInfo sslInfo,
<del> Publisher<? extends DataBuffer> body) {
<add> @Nullable InetSocketAddress remoteAddress, @Nullable InetSocketAddress localAddress,
<add> @Nullable SslInfo sslInfo, Publisher<? extends DataBuffer> body) {
<ide>
<ide> super(uri, contextPath, headers);
<ide> this.httpMethod = httpMethod;
<ide> this.cookies = cookies;
<ide> this.remoteAddress = remoteAddress;
<add> this.localAddress = localAddress;
<ide> this.sslInfo = sslInfo;
<ide> this.body = Flux.from(body);
<ide> }
<ide> public InetSocketAddress getRemoteAddress() {
<ide> return this.remoteAddress;
<ide> }
<ide>
<add> @Nullable
<add> @Override
<add> public InetSocketAddress getLocalAddress() {
<add> return this.localAddress;
<add> }
<add>
<ide> @Nullable
<ide> @Override
<ide> protected SslInfo initSslInfo() {
<ide> public static BaseBuilder<?> options(String urlTemplate, Object... uriVars) {
<ide> */
<ide> B remoteAddress(InetSocketAddress remoteAddress);
<ide>
<add> /**
<add> * Set the local address to return.
<add> * @since 5.2.3
<add> */
<add> B localAddress(InetSocketAddress localAddress);
<add>
<ide> /**
<ide> * Set SSL session information and certificates.
<ide> */
<ide> private static class DefaultBodyBuilder implements BodyBuilder {
<ide> @Nullable
<ide> private InetSocketAddress remoteAddress;
<ide>
<add> @Nullable
<add> private InetSocketAddress localAddress;
<add>
<ide> @Nullable
<ide> private SslInfo sslInfo;
<ide>
<ide> public BodyBuilder remoteAddress(InetSocketAddress remoteAddress) {
<ide> return this;
<ide> }
<ide>
<add> @Override
<add> public BodyBuilder localAddress(InetSocketAddress localAddress) {
<add> this.localAddress = localAddress;
<add> return this;
<add> }
<add>
<ide> @Override
<ide> public void sslInfo(SslInfo sslInfo) {
<ide> this.sslInfo = sslInfo;
<ide> private Charset getCharset() {
<ide> public MockServerHttpRequest body(Publisher<? extends DataBuffer> body) {
<ide> applyCookiesIfNecessary();
<ide> return new MockServerHttpRequest(this.method, getUrlToUse(), this.contextPath,
<del> this.headers, this.cookies, this.remoteAddress, this.sslInfo, body);
<add> this.headers, this.cookies, this.remoteAddress, this.localAddress, this.sslInfo, body);
<ide> }
<ide>
<ide> private void applyCookiesIfNecessary() {
<ide><path>spring-test/src/main/java/org/springframework/mock/web/reactive/function/server/MockServerRequest.java
<ide> public final class MockServerRequest implements ServerRequest {
<ide> @Nullable
<ide> private final InetSocketAddress remoteAddress;
<ide>
<add> @Nullable
<add> private final InetSocketAddress localAddress;
<add>
<ide> private final List<HttpMessageReader<?>> messageReaders;
<ide>
<ide> @Nullable
<ide> private MockServerRequest(HttpMethod method, URI uri, String contextPath, MockHe
<ide> MultiValueMap<String, HttpCookie> cookies, @Nullable Object body,
<ide> Map<String, Object> attributes, MultiValueMap<String, String> queryParams,
<ide> Map<String, String> pathVariables, @Nullable WebSession session, @Nullable Principal principal,
<del> @Nullable InetSocketAddress remoteAddress, List<HttpMessageReader<?>> messageReaders,
<del> @Nullable ServerWebExchange exchange) {
<add> @Nullable InetSocketAddress remoteAddress, @Nullable InetSocketAddress localAddress,
<add> List<HttpMessageReader<?>> messageReaders, @Nullable ServerWebExchange exchange) {
<ide>
<ide> this.method = method;
<ide> this.uri = uri;
<ide> private MockServerRequest(HttpMethod method, URI uri, String contextPath, MockHe
<ide> this.session = session;
<ide> this.principal = principal;
<ide> this.remoteAddress = remoteAddress;
<add> this.localAddress = localAddress;
<ide> this.messageReaders = messageReaders;
<ide> this.exchange = exchange;
<ide> }
<ide> public Optional<InetSocketAddress> remoteAddress() {
<ide> return Optional.ofNullable(this.remoteAddress);
<ide> }
<ide>
<add> @Override
<add> public Optional<InetSocketAddress> localAddress() {
<add> return Optional.ofNullable(this.localAddress);
<add> }
<add>
<ide> @Override
<ide> public List<HttpMessageReader<?>> messageReaders() {
<ide> return this.messageReaders;
<ide> public interface Builder {
<ide>
<ide> Builder remoteAddress(InetSocketAddress remoteAddress);
<ide>
<add> Builder localAddress(InetSocketAddress localAddress);
<add>
<ide> Builder messageReaders(List<HttpMessageReader<?>> messageReaders);
<ide>
<ide> Builder exchange(ServerWebExchange exchange);
<ide> private static class BuilderImpl implements Builder {
<ide> @Nullable
<ide> private InetSocketAddress remoteAddress;
<ide>
<add> @Nullable
<add> private InetSocketAddress localAddress;
<add>
<ide> private List<HttpMessageReader<?>> messageReaders = HandlerStrategies.withDefaults().messageReaders();
<ide>
<ide> @Nullable
<ide> public Builder remoteAddress(InetSocketAddress remoteAddress) {
<ide> return this;
<ide> }
<ide>
<add> @Override
<add> public Builder localAddress(InetSocketAddress localAddress) {
<add> Assert.notNull(localAddress, "'localAddress' must not be null");
<add> this.localAddress = localAddress;
<add> return this;
<add> }
<add>
<ide> @Override
<ide> public Builder messageReaders(List<HttpMessageReader<?>> messageReaders) {
<ide> Assert.notNull(messageReaders, "'messageReaders' must not be null");
<ide> public MockServerRequest body(Object body) {
<ide> this.body = body;
<ide> return new MockServerRequest(this.method, this.uri, this.contextPath, this.headers,
<ide> this.cookies, this.body, this.attributes, this.queryParams, this.pathVariables,
<del> this.session, this.principal, this.remoteAddress, this.messageReaders,
<del> this.exchange);
<add> this.session, this.principal, this.remoteAddress, this.localAddress,
<add> this.messageReaders, this.exchange);
<ide> }
<ide>
<ide> @Override
<ide> public MockServerRequest build() {
<ide> return new MockServerRequest(this.method, this.uri, this.contextPath, this.headers,
<ide> this.cookies, null, this.attributes, this.queryParams, this.pathVariables,
<del> this.session, this.principal, this.remoteAddress, this.messageReaders,
<del> this.exchange);
<add> this.session, this.principal, this.remoteAddress, this.localAddress,
<add> this.messageReaders, this.exchange);
<ide> }
<ide> }
<ide>
<ide><path>spring-web/src/main/java/org/springframework/http/server/reactive/DefaultServerHttpRequestBuilder.java
<ide> /*
<del> * Copyright 2002-2018 the original author or authors.
<add> * Copyright 2002-2019 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> private static class MutatedServerHttpRequest extends AbstractServerHttpRequest
<ide>
<ide> private final MultiValueMap<String, HttpCookie> cookies;
<ide>
<del> @Nullable
<del> private final InetSocketAddress remoteAddress;
<del>
<ide> @Nullable
<ide> private final SslInfo sslInfo;
<ide>
<ide> public MutatedServerHttpRequest(URI uri, @Nullable String contextPath,
<ide> super(uri, contextPath, headers);
<ide> this.methodValue = methodValue;
<ide> this.cookies = cookies;
<del> this.remoteAddress = originalRequest.getRemoteAddress();
<ide> this.sslInfo = sslInfo != null ? sslInfo : originalRequest.getSslInfo();
<ide> this.body = body;
<ide> this.originalRequest = originalRequest;
<ide> protected MultiValueMap<String, HttpCookie> initCookies() {
<ide> @Nullable
<ide> @Override
<ide> public InetSocketAddress getRemoteAddress() {
<del> return this.remoteAddress;
<add> return this.originalRequest.getRemoteAddress();
<add> }
<add>
<add> @Nullable
<add> @Override
<add> public InetSocketAddress getLocalAddress() {
<add> return this.originalRequest.getLocalAddress();
<ide> }
<ide>
<ide> @Nullable
<ide><path>spring-web/src/main/java/org/springframework/http/server/reactive/ReactorServerHttpRequest.java
<ide> /*
<del> * Copyright 2002-2018 the original author or authors.
<add> * Copyright 2002-2019 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> public InetSocketAddress getRemoteAddress() {
<ide> return this.request.remoteAddress();
<ide> }
<ide>
<add> @Override
<add> public InetSocketAddress getLocalAddress() {
<add> return this.request.hostAddress();
<add> }
<add>
<ide> @Override
<ide> @Nullable
<ide> protected SslInfo initSslInfo() {
<ide><path>spring-web/src/main/java/org/springframework/http/server/reactive/ServerHttpRequest.java
<ide> default InetSocketAddress getRemoteAddress() {
<ide> return null;
<ide> }
<ide>
<add> /**
<add> * Return the local address the request was accepted on, if available.
<add> * 5.2.3
<add> */
<add> @Nullable
<add> default InetSocketAddress getLocalAddress() {
<add> return null;
<add> }
<add>
<ide> /**
<ide> * Return the SSL session information if the request has been transmitted
<ide> * over a secure protocol including SSL certificates, if available.
<ide><path>spring-web/src/main/java/org/springframework/http/server/reactive/ServerHttpRequestDecorator.java
<ide> /*
<del> * Copyright 2002-2018 the original author or authors.
<add> * Copyright 2002-2019 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> public InetSocketAddress getRemoteAddress() {
<ide> return getDelegate().getRemoteAddress();
<ide> }
<ide>
<add> @Override
<add> public InetSocketAddress getLocalAddress() {
<add> return getDelegate().getLocalAddress();
<add> }
<add>
<ide> @Nullable
<ide> @Override
<ide> public SslInfo getSslInfo() {
<ide><path>spring-web/src/main/java/org/springframework/http/server/reactive/ServletServerHttpRequest.java
<ide> /*
<del> * Copyright 2002-2018 the original author or authors.
<add> * Copyright 2002-2019 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> public InetSocketAddress getRemoteAddress() {
<ide> return new InetSocketAddress(this.request.getRemoteHost(), this.request.getRemotePort());
<ide> }
<ide>
<add> @Override
<add> public InetSocketAddress getLocalAddress() {
<add> return new InetSocketAddress(this.request.getLocalAddr(), this.request.getLocalPort());
<add> }
<add>
<ide> @Override
<ide> @Nullable
<ide> protected SslInfo initSslInfo() {
<ide><path>spring-web/src/main/java/org/springframework/http/server/reactive/UndertowServerHttpRequest.java
<ide> public InetSocketAddress getRemoteAddress() {
<ide> return this.exchange.getSourceAddress();
<ide> }
<ide>
<add> @Override
<add> public InetSocketAddress getLocalAddress() {
<add> return this.exchange.getDestinationAddress();
<add> }
<add>
<ide> @Nullable
<ide> @Override
<ide> protected SslInfo initSslInfo() {
<ide><path>spring-web/src/test/java/org/springframework/mock/http/server/reactive/test/MockServerHttpRequest.java
<ide> /*
<del> * Copyright 2002-2018 the original author or authors.
<add> * Copyright 2002-2019 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> * @author Rossen Stoyanchev
<ide> * @since 5.0
<ide> */
<del>public class MockServerHttpRequest extends AbstractServerHttpRequest {
<add>public final class MockServerHttpRequest extends AbstractServerHttpRequest {
<ide>
<ide> private final HttpMethod httpMethod;
<ide>
<ide> public class MockServerHttpRequest extends AbstractServerHttpRequest {
<ide> @Nullable
<ide> private final InetSocketAddress remoteAddress;
<ide>
<add> @Nullable
<add> private final InetSocketAddress localAddress;
<add>
<ide> @Nullable
<ide> private final SslInfo sslInfo;
<ide>
<ide> public class MockServerHttpRequest extends AbstractServerHttpRequest {
<ide>
<ide> private MockServerHttpRequest(HttpMethod httpMethod, URI uri, @Nullable String contextPath,
<ide> HttpHeaders headers, MultiValueMap<String, HttpCookie> cookies,
<del> @Nullable InetSocketAddress remoteAddress, @Nullable SslInfo sslInfo,
<del> Publisher<? extends DataBuffer> body) {
<add> @Nullable InetSocketAddress remoteAddress, @Nullable InetSocketAddress localAddress,
<add> @Nullable SslInfo sslInfo, Publisher<? extends DataBuffer> body) {
<ide>
<ide> super(uri, contextPath, headers);
<ide> this.httpMethod = httpMethod;
<ide> this.cookies = cookies;
<ide> this.remoteAddress = remoteAddress;
<add> this.localAddress = localAddress;
<ide> this.sslInfo = sslInfo;
<ide> this.body = Flux.from(body);
<ide> }
<ide> public InetSocketAddress getRemoteAddress() {
<ide> return this.remoteAddress;
<ide> }
<ide>
<add> @Nullable
<add> @Override
<add> public InetSocketAddress getLocalAddress() {
<add> return this.localAddress;
<add> }
<add>
<ide> @Nullable
<ide> @Override
<ide> protected SslInfo initSslInfo() {
<ide> public static BaseBuilder<?> options(String urlTemplate, Object... uriVars) {
<ide> */
<ide> B remoteAddress(InetSocketAddress remoteAddress);
<ide>
<add> /**
<add> * Set the local address to return.
<add> * @since 5.2.3
<add> */
<add> B localAddress(InetSocketAddress localAddress);
<add>
<ide> /**
<ide> * Set SSL session information and certificates.
<ide> */
<ide> private static class DefaultBodyBuilder implements BodyBuilder {
<ide> @Nullable
<ide> private InetSocketAddress remoteAddress;
<ide>
<add> @Nullable
<add> private InetSocketAddress localAddress;
<add>
<ide> @Nullable
<ide> private SslInfo sslInfo;
<ide>
<ide> public BodyBuilder remoteAddress(InetSocketAddress remoteAddress) {
<ide> return this;
<ide> }
<ide>
<add> @Override
<add> public BodyBuilder localAddress(InetSocketAddress localAddress) {
<add> this.localAddress = localAddress;
<add> return this;
<add> }
<add>
<ide> @Override
<ide> public void sslInfo(SslInfo sslInfo) {
<ide> this.sslInfo = sslInfo;
<ide> private Charset getCharset() {
<ide> public MockServerHttpRequest body(Publisher<? extends DataBuffer> body) {
<ide> applyCookiesIfNecessary();
<ide> return new MockServerHttpRequest(this.method, getUrlToUse(), this.contextPath,
<del> this.headers, this.cookies, this.remoteAddress, this.sslInfo, body);
<add> this.headers, this.cookies, this.remoteAddress, this.localAddress, this.sslInfo, body);
<ide> }
<ide>
<ide> private void applyCookiesIfNecessary() {
<ide><path>spring-webflux/src/main/java/org/springframework/web/reactive/function/server/DefaultServerRequest.java
<ide> public Optional<InetSocketAddress> remoteAddress() {
<ide> return Optional.ofNullable(request().getRemoteAddress());
<ide> }
<ide>
<add> @Override
<add> public Optional<InetSocketAddress> localAddress() {
<add> return Optional.ofNullable(request().getLocalAddress());
<add> }
<add>
<ide> @Override
<ide> public List<HttpMessageReader<?>> messageReaders() {
<ide> return this.messageReaders;
<ide><path>spring-webflux/src/main/java/org/springframework/web/reactive/function/server/RequestPredicates.java
<ide> public Optional<InetSocketAddress> remoteAddress() {
<ide> return this.request.remoteAddress();
<ide> }
<ide>
<add> @Override
<add> public Optional<InetSocketAddress> localAddress() {
<add> return this.request.localAddress();
<add> }
<add>
<ide> @Override
<ide> public List<HttpMessageReader<?>> messageReaders() {
<ide> return this.request.messageReaders();
<ide><path>spring-webflux/src/main/java/org/springframework/web/reactive/function/server/ServerRequest.java
<ide> default PathContainer pathContainer() {
<ide> */
<ide> Optional<InetSocketAddress> remoteAddress();
<ide>
<add> /**
<add> * Get the remote address to which this request is connected, if available.
<add> * @since 5.2.3
<add> */
<add> Optional<InetSocketAddress> localAddress();
<add>
<ide> /**
<ide> * Get the readers used to convert the body of this request.
<ide> * @since 5.1
<ide><path>spring-webflux/src/main/java/org/springframework/web/reactive/function/server/support/ServerRequestWrapper.java
<ide> public Optional<InetSocketAddress> remoteAddress() {
<ide> return this.delegate.remoteAddress();
<ide> }
<ide>
<add> @Override
<add> public Optional<InetSocketAddress> localAddress() {
<add> return this.delegate.localAddress();
<add> }
<add>
<ide> @Override
<ide> public List<HttpMessageReader<?>> messageReaders() {
<ide> return this.delegate.messageReaders();
<ide><path>spring-webflux/src/test/java/org/springframework/web/reactive/function/server/MockServerRequest.java
<ide> * @author Arjen Poutsma
<ide> * @since 5.0
<ide> */
<del>public class MockServerRequest implements ServerRequest {
<add>public final class MockServerRequest implements ServerRequest {
<ide>
<ide> private final HttpMethod method;
<ide>
<ide> public class MockServerRequest implements ServerRequest {
<ide> @Nullable
<ide> private final InetSocketAddress remoteAddress;
<ide>
<add> @Nullable
<add> private final InetSocketAddress localAddress;
<add>
<ide> private final List<HttpMessageReader<?>> messageReaders;
<ide>
<ide> @Nullable
<ide> private MockServerRequest(HttpMethod method, URI uri, String contextPath, MockHe
<ide> MultiValueMap<String, HttpCookie> cookies, @Nullable Object body,
<ide> Map<String, Object> attributes, MultiValueMap<String, String> queryParams,
<ide> Map<String, String> pathVariables, @Nullable WebSession session, @Nullable Principal principal,
<del> @Nullable InetSocketAddress remoteAddress, List<HttpMessageReader<?>> messageReaders,
<del> @Nullable ServerWebExchange exchange) {
<add> @Nullable InetSocketAddress remoteAddress, @Nullable InetSocketAddress localAddress,
<add> List<HttpMessageReader<?>> messageReaders, @Nullable ServerWebExchange exchange) {
<ide>
<ide> this.method = method;
<ide> this.uri = uri;
<ide> private MockServerRequest(HttpMethod method, URI uri, String contextPath, MockHe
<ide> this.session = session;
<ide> this.principal = principal;
<ide> this.remoteAddress = remoteAddress;
<add> this.localAddress = localAddress;
<ide> this.messageReaders = messageReaders;
<ide> this.exchange = exchange;
<ide> }
<ide> public Optional<InetSocketAddress> remoteAddress() {
<ide> return Optional.ofNullable(this.remoteAddress);
<ide> }
<ide>
<add> @Override
<add> public Optional<InetSocketAddress> localAddress() {
<add> return Optional.ofNullable(this.localAddress);
<add> }
<add>
<ide> @Override
<ide> public List<HttpMessageReader<?>> messageReaders() {
<ide> return this.messageReaders;
<ide> public interface Builder {
<ide> Builder session(WebSession session);
<ide>
<ide> /**
<add> * Sets the request {@link Principal}.
<ide> * @deprecated in favor of {@link #principal(Principal)}
<ide> */
<ide> @Deprecated
<ide> public interface Builder {
<ide>
<ide> Builder remoteAddress(InetSocketAddress remoteAddress);
<ide>
<add> Builder localAddress(InetSocketAddress localAddress);
<add>
<ide> Builder messageReaders(List<HttpMessageReader<?>> messageReaders);
<ide>
<ide> Builder exchange(ServerWebExchange exchange);
<ide> private static class BuilderImpl implements Builder {
<ide> @Nullable
<ide> private InetSocketAddress remoteAddress;
<ide>
<add> @Nullable
<add> private InetSocketAddress localAddress;
<add>
<ide> private List<HttpMessageReader<?>> messageReaders = HandlerStrategies.withDefaults().messageReaders();
<ide>
<ide> @Nullable
<ide> public Builder remoteAddress(InetSocketAddress remoteAddress) {
<ide> return this;
<ide> }
<ide>
<add> @Override
<add> public Builder localAddress(InetSocketAddress localAddress) {
<add> Assert.notNull(localAddress, "'localAddress' must not be null");
<add> this.localAddress = localAddress;
<add> return this;
<add> }
<add>
<ide> @Override
<ide> public Builder messageReaders(List<HttpMessageReader<?>> messageReaders) {
<ide> Assert.notNull(messageReaders, "'messageReaders' must not be null");
<ide> public MockServerRequest body(Object body) {
<ide> this.body = body;
<ide> return new MockServerRequest(this.method, this.uri, this.contextPath, this.headers,
<ide> this.cookies, this.body, this.attributes, this.queryParams, this.pathVariables,
<del> this.session, this.principal, this.remoteAddress, this.messageReaders,
<del> this.exchange);
<add> this.session, this.principal, this.remoteAddress, this.localAddress,
<add> this.messageReaders, this.exchange);
<ide> }
<ide>
<ide> @Override
<ide> public MockServerRequest build() {
<ide> return new MockServerRequest(this.method, this.uri, this.contextPath, this.headers,
<ide> this.cookies, null, this.attributes, this.queryParams, this.pathVariables,
<del> this.session, this.principal, this.remoteAddress, this.messageReaders,
<del> this.exchange);
<add> this.session, this.principal, this.remoteAddress, this.localAddress,
<add> this.messageReaders, this.exchange);
<ide> }
<ide> }
<ide> | 14 |
Text | Text | remove kickstarter links from homepage and readme | dce30207dae1725a2b08232fc4dee34e0949b14b | <ide><path>README.md
<del>---
<del>
<del>#### Django REST framework 3 - Kickstarter announcement!
<del>
<del>We are currently running a Kickstarter campaign to help fund the development of Django REST framework 3.
<del>
<del>If you want to help drive sustainable open-source development forward, then **please check out [the Kickstarter project](https://www.kickstarter.com/projects/tomchristie/django-rest-framework-3) and consider funding us.**
<del>
<del>---
<del>
<ide> # Django REST framework
<ide>
<ide> [![build-status-image]][travis]
<ide><path>docs/index.md
<ide>
<ide> ---
<ide>
<del>#### Django REST framework 3 - Kickstarter announcement!
<del>
<del>We are currently running a Kickstarter campaign to help fund the development of Django REST framework 3.
<del>
<del>If you want to help drive sustainable open-source development **please [check out the Kickstarter project](https://www.kickstarter.com/projects/tomchristie/django-rest-framework-3) and consider funding us.**
<del>
<del>---
<del>
<ide> <p>
<ide> <h1 style="position: absolute;
<ide> width: 1px; | 2 |
PHP | PHP | allow quiet creation | e9cd94c89f59c833c13d04f32f1e31db419a4c0c | <ide><path>src/Illuminate/Database/Eloquent/Factories/Factory.php
<ide> public function createOne($attributes = [])
<ide> return $this->count(null)->create($attributes);
<ide> }
<ide>
<add> /**
<add> * Create a single model and persist it to the database.
<add> *
<add> * @param array $attributes
<add> * @return \Illuminate\Database\Eloquent\Model
<add> */
<add> public function createOneQuietly($attributes = [])
<add> {
<add> return $this->count(null)->createQuietly($attributes);
<add> }
<add>
<ide> /**
<ide> * Create a collection of models and persist them to the database.
<ide> *
<ide> public function createMany(iterable $records)
<ide> );
<ide> }
<ide>
<add> /**
<add> * Create a collection of models and persist them to the database.
<add> *
<add> * @param iterable $records
<add> * @return \Illuminate\Database\Eloquent\Collection
<add> */
<add> public function createManyQuietly(iterable $records)
<add> {
<add> return Model::withoutEvents(function () use ($records) {
<add> return $this->createMany($records);
<add> });
<add> }
<add>
<ide> /**
<ide> * Create a collection of models and persist them to the database.
<ide> *
<ide> public function create($attributes = [], ?Model $parent = null)
<ide> return $results;
<ide> }
<ide>
<add> /**
<add> * Create a collection of models and persist them to the database.
<add> *
<add> * @param array $attributes
<add> * @param \Illuminate\Database\Eloquent\Model|null $parent
<add> * @return \Illuminate\Database\Eloquent\Collection|\Illuminate\Database\Eloquent\Model
<add> */
<add> public function createQuietly($attributes = [], ?Model $parent = null)
<add> {
<add> return Model::withoutEvents(function () use ($attributes, $parent) {
<add> return $this->create($attributes, $parent);
<add> });
<add> }
<add>
<ide> /**
<ide> * Create a callback that persists a model in the database when invoked.
<ide> * | 1 |
Python | Python | simplify is_config() and normalize_string_keys() | f7dcaa1f6b32a45afde456e3a854939fc2440daa | <ide><path>spacy/compat.py
<ide> def symlink_to(orig, dest):
<ide>
<ide>
<ide> def is_config(python2=None, python3=None, windows=None, linux=None, osx=None):
<del> return ((python2 is None or python2 == is_python2) and
<del> (python3 is None or python3 == is_python3) and
<del> (windows is None or windows == is_windows) and
<del> (linux is None or linux == is_linux) and
<del> (osx is None or osx == is_osx))
<add> return (python2 in (None, is_python2) and
<add> python3 in (None, is_python3) and
<add> windows in (None, is_windows) and
<add> linux in (None, is_linux) and
<add> osx in (None, is_osx))
<ide>
<ide>
<ide> def normalize_string_keys(old): | 1 |
Text | Text | add changelog for 2.8.2 [ci skip] | c3b7c8200c2ba1366d54e8f2e5afab75a45ddea1 | <ide><path>CHANGELOG.md
<ide>
<ide> - [#14156](https://github.com/emberjs/ember.js/pull/14156) [FEATURE ember-glimmer] Enable by default.
<ide>
<add>### 2.8.2 (October 6, 2016)
<add>
<add>- [#14365](https://github.com/emberjs/ember.js/pull/14365) [BUGFIX] Fix an issue with URLs with encoded characters and a trailing slash.
<add>- [#14382](https://github.com/emberjs/ember.js/pull/14382) [BUGFIX] Allow bound `id` on tagless components.
<add>- [#14421](https://github.com/emberjs/ember.js/pull/14421) [BUGFIX] Fix an issue with local components lookup.
<add>
<ide> ### 2.8.1 (September 14, 2016)
<ide>
<ide> - [#14184](https://github.com/emberjs/ember.js/pull/14184) [BUGFIX] Ensure that promises that reject with non Errors (i.e. something without a `.stack`) do not trigger an error during Ember's internal error processing. | 1 |
Javascript | Javascript | support "free" mocks | 801b83da2d37e6cdd97d6e4e8e157293fb9dbd84 | <ide><path>packager/react-packager/src/DependencyResolver/DependencyGraph/ResolutionRequest.js
<ide> class ResolutionRequest {
<ide> const filteredPairs = [];
<ide>
<ide> dependencies.forEach((modDep, i) => {
<add> const name = depNames[i];
<ide> if (modDep == null) {
<add> // It is possible to require mocks that don't have a real
<add> // module backing them. If a dependency cannot be found but there
<add> // exists a mock with the desired ID, resolve it and add it as
<add> // a dependency.
<add> if (mocks && mocks[name]) {
<add> const mockModule = this._moduleCache.getModule(mocks[name]);
<add> return filteredPairs.push([name, mockModule]);
<add> }
<add>
<ide> debug(
<ide> 'WARNING: Cannot find required module `%s` from module `%s`',
<del> depNames[i],
<add> name,
<ide> mod.path
<ide> );
<ide> return false;
<ide> }
<del> return filteredPairs.push([depNames[i], modDep]);
<add> return filteredPairs.push([name, modDep]);
<ide> });
<ide>
<ide> response.setResolvedDependencyPairs(mod, filteredPairs);
<ide><path>packager/react-packager/src/DependencyResolver/DependencyGraph/__tests__/DependencyGraph-test.js
<ide>
<ide> jest.autoMockOff();
<ide>
<del>const Promise = require('promise');
<add>jest.mock('fs');
<ide>
<del>jest
<del> .mock('fs');
<add>const Promise = require('promise');
<add>const DependencyGraph = require('../index');
<add>const fs = require('graceful-fs');
<ide>
<del>var DependencyGraph = require('../index');
<del>var fs = require('graceful-fs');
<add>const mocksPattern = /(?:[\\/]|^)__mocks__[\\/]([^\/]+)\.js$/;
<ide>
<ide> describe('DependencyGraph', function() {
<ide> let defaults;
<ide> describe('DependencyGraph', function() {
<ide> var root = '/root';
<ide> fs.__setMockFilesystem({
<ide> 'root': {
<del> '__mocks': {
<add> '__mocks__': {
<ide> 'A.js': '',
<ide> },
<ide> 'index.js': '',
<ide> describe('DependencyGraph', function() {
<ide> var dgraph = new DependencyGraph({
<ide> ...defaults,
<ide> roots: [root],
<del> mocksPattern: /(?:[\\/]|^)__mocks__[\\/]([^\/]+)\.js$/,
<add> mocksPattern,
<ide> });
<ide>
<ide> return dgraph.getDependencies('/root/b.js')
<ide> describe('DependencyGraph', function() {
<ide> var dgraph = new DependencyGraph({
<ide> ...defaults,
<ide> roots: [root],
<del> mocksPattern: /(?:[\\/]|^)__mocks__[\\/]([^\/]+)\.js$/,
<add> mocksPattern,
<ide> });
<ide>
<ide> return getOrderedDependenciesAsJSON(dgraph, '/root/A.js')
<ide> describe('DependencyGraph', function() {
<ide> id: '/root/__mocks__/A.js',
<ide> dependencies: ['b'],
<ide> },
<add> {
<add> path: '/root/__mocks__/b.js',
<add> isJSON: false,
<add> isAsset: false,
<add> isAsset_DEPRECATED: false,
<add> isPolyfill: false,
<add> id: '/root/__mocks__/b.js',
<add> dependencies: [],
<add> },
<add> ]);
<add> });
<add> });
<add>
<add> pit('resolves mocks that do not have a real module associated with them', () => {
<add> var root = '/root';
<add> fs.__setMockFilesystem({
<add> 'root': {
<add> '__mocks__': {
<add> 'foo.js': [
<add> 'require("b");',
<add> ].join('\n'),
<add> 'b.js': '',
<add> },
<add> 'A.js': [
<add> '/**',
<add> ' * @providesModule A',
<add> ' */',
<add> 'require("foo");',
<add> ].join('\n'),
<add> },
<add> });
<add>
<add> var dgraph = new DependencyGraph({
<add> ...defaults,
<add> roots: [root],
<add> mocksPattern,
<add> });
<add>
<add> return getOrderedDependenciesAsJSON(dgraph, '/root/A.js')
<add> .then(deps => {
<add> expect(deps).toEqual([
<add> {
<add> path: '/root/A.js',
<add> isJSON: false,
<add> isAsset: false,
<add> isAsset_DEPRECATED: false,
<add> isPolyfill: false,
<add> id: 'A',
<add> dependencies: ['foo'],
<add> },
<add> {
<add> path: '/root/__mocks__/foo.js',
<add> isJSON: false,
<add> isAsset: false,
<add> isAsset_DEPRECATED: false,
<add> isPolyfill: false,
<add> id: '/root/__mocks__/foo.js',
<add> dependencies: ['b'],
<add> },
<add> {
<add> path: '/root/__mocks__/b.js',
<add> isJSON: false,
<add> isAsset: false,
<add> isAsset_DEPRECATED: false,
<add> isPolyfill: false,
<add> id: '/root/__mocks__/b.js',
<add> dependencies: [],
<add> },
<ide> ]);
<ide> });
<ide> }); | 2 |
Javascript | Javascript | fix another ie test issue - issue | d593ed12f3bd1fce7d47dee4c116f8d98fa5e185 | <ide><path>packages/ember/tests/helpers/link_to_test.js
<ide> test("The {{link-to}} helper works in an #each'd array of string route names", f
<ide>
<ide> bootApplication();
<ide>
<del> var $links = Ember.$('a', '#qunit-fixture');
<add> function linksEqual($links, expected) {
<add> equal($links.length, expected.length, "Has correct number of links");
<add>
<add> var idx;
<add> for (idx = 0; idx < $links.length; idx++) {
<add> var href = Ember.$($links[idx]).attr('href');
<add> // Old IE includes the whole hostname as well
<add> equal(href.slice(-expected[idx].length), expected[idx], "Expected link to be '"+expected[idx]+"', but was '"+href+"'");
<add> }
<add> }
<ide>
<del> deepEqual(map.call($links,function(el) { return Ember.$(el).attr('href'); }), ["/foo", "/bar", "/rar", "/foo", "/bar", "/rar", "/bar", "/foo"]);
<add> linksEqual(Ember.$('a', '#qunit-fixture'), ["/foo", "/bar", "/rar", "/foo", "/bar", "/rar", "/bar", "/foo"]);
<ide>
<ide> var indexController = container.lookup('controller:index');
<ide> Ember.run(indexController, 'set', 'route1', 'rar');
<ide>
<del> $links = Ember.$('a', '#qunit-fixture');
<del> deepEqual(map.call($links, function(el) { return Ember.$(el).attr('href'); }), ["/foo", "/bar", "/rar", "/foo", "/bar", "/rar", "/rar", "/foo"]);
<add> linksEqual(Ember.$('a', '#qunit-fixture'), ["/foo", "/bar", "/rar", "/foo", "/bar", "/rar", "/rar", "/foo"]);
<ide>
<ide> Ember.run(indexController.routeNames, 'shiftObject');
<ide>
<del> $links = Ember.$('a', '#qunit-fixture');
<del> deepEqual(map.call($links, function(el) { return Ember.$(el).attr('href'); }), ["/bar", "/rar", "/bar", "/rar", "/rar", "/foo"]);
<add> linksEqual(Ember.$('a', '#qunit-fixture'), ["/bar", "/rar", "/bar", "/rar", "/rar", "/foo"]);
<ide> });
<ide>
<ide> if (Ember.FEATURES.isEnabled('link-to-non-block')) { | 1 |
Javascript | Javascript | fix house scene so no trackback input | ca824254777002d51c7bf48f9f6fc2ca9fcd8454 | <ide><path>threejs/lessons/resources/threejs-fog.js
<ide> scene.add(gltf.scene);
<ide> });
<ide>
<del> camera.fov = 30;
<add> camera.fov = 45;
<ide> camera.position.set(0.4, 1, 1.7);
<ide> camera.lookAt(1, 1, 0.7);
<ide>
<ide>
<ide> const target = [1, 1, 0.7];
<ide> return {
<add> trackball: false,
<ide> obj3D: new THREE.Object3D(),
<ide> update: (time) => {
<ide> camera.lookAt(target[0] + Math.sin(time * .25) * .5, target[1], target[2]); | 1 |
PHP | PHP | fix cs errors | dc0b8fcd9e7e59d792eee3b3b43f7d51e3effc47 | <ide><path>src/TestSuite/Constraint/Response/HeaderNotContains.php
<ide> <?php
<add>declare(strict_types=1);
<ide> /**
<ide> * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
<ide> * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
<ide><path>tests/TestCase/Shell/Task/ExtractTaskTest.php
<ide> use Cake\Core\Plugin;
<ide> use Cake\Filesystem\Folder;
<ide> use Cake\TestSuite\TestCase;
<del>use PHPUnit\Framework\MockObject\MockObject;
<ide>
<ide> /**
<ide> * ExtractTaskTest class
<ide><path>tests/TestCase/TestSuite/EmailTraitTest.php
<ide> public function setUp()
<ide> 'from' => '[email protected]',
<ide> ]);
<ide> TransportFactory::setConfig('test_tools', [
<del> 'className' => TestEmailTransport::class
<add> 'className' => TestEmailTransport::class,
<ide> ]);
<ide>
<ide> TestEmailTransport::replaceAllTransports();
<ide><path>tests/TestCase/TestSuite/TestEmailTransportTest.php
<ide> public function setUp()
<ide> TransportFactory::drop('transport_alternate');
<ide>
<ide> TransportFactory::setConfig('transport_default', [
<del> 'className' => DebugTransport::class
<add> 'className' => DebugTransport::class,
<ide> ]);
<ide> TransportFactory::setConfig('transport_alternate', [
<del> 'className' => DebugTransport::class
<add> 'className' => DebugTransport::class,
<ide> ]);
<ide>
<ide> Email::setConfig('default', [ | 4 |
Ruby | Ruby | fix migrations with pg 7.x | e7059fd28191a77d53e66389f8df5b22036699e8 | <ide><path>activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
<ide> def update(sql, name = nil)
<ide>
<ide> alias_method :delete, :update
<ide>
<add> def add_column(table_name, column_name, type, options = {})
<add> native_type = native_database_types[type]
<add> sql_commands = ["ALTER TABLE #{table_name} ADD #{column_name} #{type_to_sql(type, options[:limit])}"]
<add> if options[:default]
<add> sql_commands << "ALTER TABLE #{table_name} ALTER #{column_name} SET DEFAULT '#{options[:default]}'"
<add> end
<add> if options[:null] == false
<add> sql_commands << "ALTER TABLE #{table_name} ALTER #{column_name} SET NOT NULL"
<add> end
<add> sql_commands.each { |cmd| execute(cmd) }
<add> end
<add>
<add>
<ide> def begin_db_transaction() execute "BEGIN" end
<ide> def commit_db_transaction() execute "COMMIT" end
<ide> def rollback_db_transaction() execute "ROLLBACK" end | 1 |
Java | Java | provide subclass hooks in path matching resolver | 1947de3334827e90b84c6f7951a52f7747221083 | <ide><path>spring-core/src/main/java/org/springframework/core/io/support/PathMatchingResourcePatternResolver.java
<ide>
<ide> import org.apache.commons.logging.Log;
<ide> import org.apache.commons.logging.LogFactory;
<del>
<ide> import org.springframework.core.io.DefaultResourceLoader;
<ide> import org.springframework.core.io.FileSystemResource;
<ide> import org.springframework.core.io.Resource;
<ide> protected Resource[] findAllClassPathResources(String location) throws IOExcepti
<ide> // We need to have pointers to each of the jar files on the classpath as well...
<ide> addAllClassLoaderJarRoots(cl, result);
<ide> }
<add> postProcessFindAllClassPathResourcesResult(location, result);
<ide> return result.toArray(new Resource[result.size()]);
<ide> }
<ide>
<add> /**
<add> * Subclass hook allowing for post processing of a
<add> * {@link #findAllClassPathResources(String) findAllClassPathResources} result.
<add> * @param location the absolute path within the classpath
<add> * @param result a mutable set of the results which can be post processed
<add> */
<add> protected void postProcessFindAllClassPathResourcesResult(String location, Set<Resource> result) {
<add> }
<add>
<ide> /**
<ide> * Convert the given URL as returned from the ClassLoader into a {@link Resource}.
<ide> * <p>The default implementation simply creates a {@link UrlResource} instance.
<ide> protected Resource convertClassLoaderURL(URL url) {
<ide> * @param classLoader the ClassLoader to search (including its ancestors)
<ide> * @param result the set of resources to add jar roots to
<ide> */
<del> private void addAllClassLoaderJarRoots(ClassLoader classLoader, Set<Resource> result) {
<add> protected void addAllClassLoaderJarRoots(ClassLoader classLoader, Set<Resource> result) {
<ide> if (classLoader instanceof URLClassLoader) {
<ide> try {
<ide> for (URL url : ((URLClassLoader) classLoader).getURLs()) { | 1 |
Javascript | Javascript | remove unnecessary comma in parallaxshader | e2773b2bc6942f685210709c313d3c62750b697b | <ide><path>examples/js/shaders/ParallaxShader.js
<ide> THREE.ParallaxShader = {
<ide> basic: 'USE_BASIC_PARALLAX',
<ide> steep: 'USE_STEEP_PARALLAX',
<ide> occlusion: 'USE_OCLUSION_PARALLAX', // a.k.a. POM
<del> relief: 'USE_RELIEF_PARALLAX',
<add> relief: 'USE_RELIEF_PARALLAX'
<ide> },
<ide>
<ide> uniforms: {
<ide> THREE.ParallaxShader = {
<ide> "vec2 mapUv = perturbUv( -vViewPosition, normalize( vNormal ), normalize( vViewPosition ) );",
<ide> "gl_FragColor = texture2D( map, mapUv );",
<ide>
<del> "}",
<add> "}"
<ide>
<ide> ].join( "\n" )
<ide> | 1 |
Python | Python | avoid invalid labels of truth | 43c243254aec4bcb6f977f4f512fb181ec7e986e | <ide><path>examples/single_model_scripts/utils_multiple_choice.py
<ide> def normalize(truth):
<ide> return int(truth) - 1
<ide> else:
<ide> logger.info("truth ERROR!")
<add>
<ide> examples = []
<ide> three_choice = 0
<ide> four_choice = 0
<ide> def normalize(truth):
<ide> continue
<ide> four_choice += 1
<ide> truth = str(normalize(data_raw["answerKey"]))
<add> assert truth is not None
<ide> question_choices = data_raw["question"]
<ide> question = question_choices["stem"]
<ide> id = data_raw["id"] | 1 |
Text | Text | add travis badge to readme | f33db6b7d0749dca3f3478758952e7590ee28a00 | <ide><path>README.md
<ide> 
<ide>
<add>[](https://travis-ci.org/atom/atom)
<add>
<ide> Atom is a hackable text editor for the 21st century, built on [atom-shell](https://github.com/atom/atom-shell), and based on everything we love about our favorite editors. We designed it to be deeply customizable, but still approachable using the default configuration.
<ide>
<ide> Visit [atom.io](https://atom.io) to learn more or visit the [Atom forum](https://discuss.atom.io).
<ide> If you want to read about using Atom or developing packages in Atom, the [Atom F
<ide>
<ide> The [API reference](https://atom.io/docs/api) for developing packages is also documented on Atom.io.
<ide>
<del>
<ide> ## Installing
<ide>
<ide> ### OS X | 1 |
Python | Python | add test for port propagation issue | 8b3b1cbcf650df843d7e1329db7f0572883dd67c | <ide><path>libcloud/test/test_connection.py
<ide> def test_constructor(self):
<ide> self.assertEqual(conn.proxy_host, '127.0.0.5')
<ide> self.assertEqual(conn.proxy_port, 3128)
<ide>
<add> def test_connection_to_unusual_port(self):
<add> conn = LibcloudConnection(host='localhost', port=8080)
<add> self.assertEqual(conn.proxy_scheme, None)
<add> self.assertEqual(conn.proxy_host, None)
<add> self.assertEqual(conn.proxy_port, None)
<add> self.assertEqual(conn.host, 'http://localhost:8080')
<add>
<add> conn = LibcloudConnection(host='localhost', port=80)
<add> self.assertEqual(conn.host, 'http://localhost')
<add>
<ide>
<ide> class ConnectionClassTestCase(unittest.TestCase):
<ide> def setUp(self): | 1 |
Java | Java | resolve t94204073 by swallowing errors | 94a2b2c86d70c3f09432d0a4d89f0c4702ceb504 | <ide><path>ReactAndroid/src/main/java/com/facebook/react/views/scroll/ScrollEvent.java
<ide> import androidx.core.util.Pools;
<ide> import com.facebook.infer.annotation.Assertions;
<ide> import com.facebook.react.bridge.Arguments;
<add>import com.facebook.react.bridge.ReactSoftException;
<ide> import com.facebook.react.bridge.WritableMap;
<ide> import com.facebook.react.uimanager.PixelUtil;
<ide> import com.facebook.react.uimanager.events.Event;
<ide>
<ide> /** A event dispatched from a ScrollView scrolling. */
<ide> public class ScrollEvent extends Event<ScrollEvent> {
<add> private static String TAG = ScrollEvent.class.getSimpleName();
<ide>
<ide> private static final Pools.SynchronizedPool<ScrollEvent> EVENTS_POOL =
<ide> new Pools.SynchronizedPool<>(3);
<ide> public static ScrollEvent obtain(
<ide>
<ide> @Override
<ide> public void onDispose() {
<del> EVENTS_POOL.release(this);
<add> try {
<add> EVENTS_POOL.release(this);
<add> } catch (IllegalStateException e) {
<add> // This exception can be thrown when an event is double-released.
<add> // This is a problem but won't cause user-visible impact, so it's okay to fail silently.
<add> ReactSoftException.logSoftException(TAG, e);
<add> }
<ide> }
<ide>
<ide> private ScrollEvent() {} | 1 |
Text | Text | add changelog entry for [ci skip] | 404cb36ee391ac7445fa90dfec17fbda524c6227 | <ide><path>activerecord/CHANGELOG.md
<add>* Make sure transaction state gets reset after a commit operation on the record.
<add>
<add> If a new transaction was open inside a callback, the record was loosing track
<add> of the transaction level state, and it was leaking that state.
<add>
<add> Fixes #12566.
<add>
<add> *arthurnn*
<add>
<ide> * Pass `has_and_belongs_to_many` `:autosave` option to
<ide> the underlying `has_many :through` association.
<ide> | 1 |
Java | Java | cover changes of | 819c377313e1b509cec5183f4c6685a6675b45f6 | <ide><path>src/main/java/io/reactivex/rxjava3/internal/operators/maybe/MaybeZipArray.java
<ide>
<ide> package io.reactivex.rxjava3.internal.operators.maybe;
<ide>
<del>import java.util.Arrays;
<ide> import java.util.Objects;
<ide> import java.util.concurrent.atomic.*;
<ide>
<ide><path>src/main/java/io/reactivex/rxjava3/internal/operators/single/SingleZipArray.java
<ide>
<ide> package io.reactivex.rxjava3.internal.operators.single;
<ide>
<del>import java.util.Arrays;
<ide> import java.util.Objects;
<ide> import java.util.concurrent.atomic.*;
<ide>
<ide><path>src/test/java/io/reactivex/rxjava3/internal/operators/maybe/MaybeZipArrayTest.java
<ide> public void oneSourceOnly() {
<ide> .test()
<ide> .assertResult(Arrays.asList(1));
<ide> }
<add>
<add> @Test
<add> public void onSuccessAfterDispose() {
<add> AtomicReference<MaybeObserver<? super Integer>> emitter = new AtomicReference<>();
<add>
<add> TestObserver<List<Object>> to = Maybe.zipArray(Arrays::asList,
<add> (MaybeSource<Integer>)o -> emitter.set(o), Maybe.<Integer>never())
<add> .test();
<add>
<add> emitter.get().onSubscribe(Disposable.empty());
<add>
<add> to.dispose();
<add>
<add> emitter.get().onSuccess(1);
<add>
<add> to.assertEmpty();
<add> }
<ide> }
<ide><path>src/test/java/io/reactivex/rxjava3/internal/operators/single/SingleZipArrayTest.java
<ide> import static org.junit.Assert.*;
<ide>
<ide> import java.util.*;
<add>import java.util.concurrent.atomic.AtomicReference;
<ide>
<ide> import org.junit.Test;
<ide>
<ide> import io.reactivex.rxjava3.core.*;
<add>import io.reactivex.rxjava3.disposables.Disposable;
<ide> import io.reactivex.rxjava3.exceptions.TestException;
<ide> import io.reactivex.rxjava3.functions.*;
<ide> import io.reactivex.rxjava3.internal.functions.Functions;
<ide> public void bothSucceed() {
<ide> .test()
<ide> .assertResult(Arrays.asList(1, 2));
<ide> }
<add>
<add> @Test
<add> public void onSuccessAfterDispose() {
<add> AtomicReference<SingleObserver<? super Integer>> emitter = new AtomicReference<>();
<add>
<add> TestObserver<List<Object>> to = Single.zipArray(Arrays::asList,
<add> (SingleSource<Integer>)o -> emitter.set(o), Single.<Integer>never())
<add> .test();
<add>
<add> emitter.get().onSubscribe(Disposable.empty());
<add>
<add> to.dispose();
<add>
<add> emitter.get().onSuccess(1);
<add>
<add> to.assertEmpty();
<add> }
<ide> } | 4 |
Javascript | Javascript | reduce timeouts in test-net-keepalive | 0d39d35739828afdc388140ccb30420aea3d3484 | <ide><path>test/parallel/test-net-keepalive.js
<ide> var echoServer = net.createServer(function(connection) {
<ide> serverConnection = connection;
<ide> connection.setTimeout(0);
<ide> assert.notEqual(connection.setKeepAlive, undefined);
<del> // send a keepalive packet after 1000 ms
<del> connection.setKeepAlive(true, 1000);
<add> // send a keepalive packet after 50 ms
<add> connection.setKeepAlive(true, common.platformTimeout(50));
<ide> connection.on('end', function() {
<ide> connection.end();
<ide> });
<ide> echoServer.on('listening', function() {
<ide> serverConnection.end();
<ide> clientConnection.end();
<ide> echoServer.close();
<del> }, 1200);
<add> }, common.platformTimeout(100));
<ide> }); | 1 |
Javascript | Javascript | extract common logic | 605da8b420207d93c034461f44775d9296830c0c | <ide><path>packages/react-reconciler/src/ReactFiberScheduler.js
<ide> function retrySuspendedRoot(
<ide> if (isPriorityLevelSuspended(root, suspendedTime)) {
<ide> // Ping at the original level
<ide> retryTime = suspendedTime;
<del> markPingedPriorityLevel(root, retryTime);
<ide> } else {
<ide> // Placeholder already timed out. Compute a new expiration time
<ide> const currentTime = requestCurrentTime();
<ide> retryTime = computeExpirationForFiber(currentTime, fiber);
<del> markPendingPriorityLevel(root, retryTime);
<ide> }
<ide>
<add> markPingedPriorityLevel(root, retryTime);
<ide> scheduleWorkToRoot(fiber, retryTime);
<ide> const rootExpirationTime = root.expirationTime;
<ide> if (rootExpirationTime !== NoWork) { | 1 |
Python | Python | move base64 to utils.serialization | 2c541284b2a6a3c2ce42dec95f1cfdfdafadc2c9 | <ide><path>celery/security/serialization.py
<ide> """
<ide> from __future__ import absolute_import
<ide>
<del>import base64
<del>
<ide> from kombu.serialization import registry, dumps, loads
<ide> from kombu.utils.encoding import bytes_to_str, str_to_bytes, ensure_bytes
<ide>
<ide> from .certificate import Certificate, FSCertStore
<ide> from .key import PrivateKey
<ide> from .utils import reraise_errors
<add>from celery.utils.serialization import b64encode, b64decode
<ide>
<ide> __all__ = ['SecureSerializer', 'register_auth']
<ide>
<ide>
<del>def b64encode(s):
<del> return bytes_to_str(base64.b64encode(str_to_bytes(s)))
<del>
<del>
<del>def b64decode(s):
<del> return base64.b64decode(str_to_bytes(s))
<del>
<del>
<ide> class SecureSerializer(object):
<ide>
<ide> def __init__(self, key=None, cert=None, cert_store=None,
<ide><path>celery/utils/serialization.py
<ide> """
<ide> from __future__ import absolute_import
<ide>
<add>from base64 import b64encode as base64encode, b64decode as base64decode
<ide> from inspect import getmro
<ide> from itertools import takewhile
<ide>
<ide> except ImportError:
<ide> import pickle # noqa
<ide>
<add>from kombu.utils.encoding import bytes_to_str, str_to_bytes
<add>
<ide> from .encoding import safe_repr
<ide>
<ide> __all__ = ['UnpickleableExceptionWrapper', 'subclass_exception',
<ide> def get_pickled_exception(exc):
<ide> if isinstance(exc, UnpickleableExceptionWrapper):
<ide> return exc.restore()
<ide> return exc
<add>
<add>
<add>def b64encode(s):
<add> return bytes_to_str(base64encode(str_to_bytes(s)))
<add>
<add>
<add>def b64decode(s):
<add> return base64decode(str_to_bytes(s)) | 2 |
Python | Python | delete the end spaces | c3d382e63f9d466200250a1006dd79062f2cbbce | <ide><path>airflow/utils.py
<ide> def send_MIME_email(e_from, e_to, mime_msg):
<ide> logging.info("Sent an altert email to " + str(to))
<ide> s.sendmail(e_from, e_to, mime_msg.as_string())
<ide> s.quit()
<del>
<del>
<del> | 1 |
Text | Text | add middleware docs | b51acfaf9758436dad32a9b9a2a8fb15e1163ff6 | <ide><path>docs/middleware.md
<add># Middleware
<add>
<add>A middleware is a function that wraps the `dispatch()` method, or another middleware. For example:
<add>
<add>```js
<add>// Instead of this
<add>dispatch(action)
<add>// do this
<add>middleware(dispatch)(action)
<add>```
<add>
<add>Multiple middleware can be composed manually
<add>
<add>```js
<add>middleware1(middleware2(dispatch))(action)
<add>```
<add>
<add>Or using the provided `compose()` utility:
<add>
<add>```js
<add>import { compose } from 'redux';
<add>
<add>// All are equivalent:
<add>middleware1(middleware2(dispatch))(action)
<add>compose(middleware1, middleware2)(dispatch)(action)
<add>compose(middleware1, middleware2, dispatch)(action)
<add>```
<add>
<add>`compose` enables you to easily compose an array of middleware using spread notation:
<add>
<add>```
<add>compose(...middlewares);
<add>```
<add>
<add>## Example of how to write middleware
<add>
<add>Here's a middleware for adding naive promise support to Redux:
<add>
<add>```js
<add>function promiseMiddleware(next) {
<add> return action =>
<add> action && typeof action.then === 'function'
<add> ? action.then(next)
<add> : next(action);
<add>}
<add>```
<add>
<add>Pretty simple, right? Since they're just higher-order functions, most middleware will be very concise and easy to read.
<add>
<add>Note that `next` can be called as many times as needed, or not at all.
<add>
<add>## Use cases
<add>
<add>Often they'll be used like schedulers. They can be used to implement promise support (a la Flummox), observable support, generator support, whatever. Or they can be used for side-effects like logging.
<add>
<add>
<add>## API
<add>
<add>Because middleware simply wraps `dispatch()` to return a function of the same signature, you can use them from the call site without any extra set up. (For the same reason, middleware is actually compatible with any Flux library with a `dispatch()` method.)
<add>
<add>However, for the most part, you'll want to configure middleware at the dispatcher level and apply them to every dispatch.
<add>
<add>For now, we are treating middleware as an advanced feature. You'll have to forgo the `createRedux(stores)` shortcut and create a dispatcher using `createDispatcher()`, which has an optional second parameter for configuring middleware. You can pass an array of middleware:
<add>
<add>```js
<add>const dispatcher = createDispatcher(
<add> composeStores({ fakeStore }),
<add> [promiseMiddleware, filterUndefined]
<add>);
<add>```
<add>
<add>Or alternatively, you can pass a function that returns an array of middleware. The function accepts a single parameter, `getState()`, which enables the use of middleware that needs to access the current state on demand. For example, here's how the default dispatcher is created internally when you call `createRedux(stores)`:
<add>
<add>```js
<add>const dispatcher = createDispatcher(
<add> composeStores(stores),
<add> getState => [thunkMiddleware(getState)]
<add>);
<add>```
<add>
<add>`thunkMiddleware` is an example of a higher-order function that returns a middleware.
<add>
<add>After creating your dispatcher, pass it to `createRedux()`:
<add>
<add>```js
<add>const redux = createRedux(dispatcher);
<add>``` | 1 |
Ruby | Ruby | use connection.error_number in mysqldatabasetasks | 15c81c8ed4930574d9900a6f947d4e0ebaa82a2f | <ide><path>activerecord/lib/active_record/tasks/mysql_database_tasks.rb
<ide> def create
<ide> connection.create_database configuration["database"], creation_options
<ide> establish_connection configuration
<ide> rescue ActiveRecord::StatementInvalid => error
<del> if error.cause.error_number == ER_DB_CREATE_EXISTS
<add> if connection.error_number(error.cause) == ER_DB_CREATE_EXISTS
<ide> raise DatabaseAlreadyExists
<ide> else
<ide> raise
<ide><path>activerecord/test/cases/tasks/mysql_rake_test.rb
<ide> module ActiveRecord
<ide> class MysqlDBCreateTest < ActiveRecord::TestCase
<ide> def setup
<del> @connection = Class.new { def create_database(*); end }.new
<add> @connection = Class.new do
<add> def create_database(*); end
<add> def error_number(_); end
<add> end.new
<ide> @configuration = {
<ide> "adapter" => "mysql2",
<ide> "database" => "my-app-db"
<ide> def test_create_when_database_exists_outputs_info_to_stderr
<ide> with_stubbed_connection_establish_connection do
<ide> ActiveRecord::Base.connection.stub(
<ide> :create_database,
<del> proc { raise ActiveRecord::Tasks::DatabaseAlreadyExists }
<add> proc { raise ActiveRecord::StatementInvalid }
<ide> ) do
<del> ActiveRecord::Tasks::DatabaseTasks.create @configuration
<add> ActiveRecord::Base.connection.stub(:error_number, 1007) do
<add> ActiveRecord::Tasks::DatabaseTasks.create @configuration
<add> end
<ide>
<ide> assert_equal "Database 'my-app-db' already exists\n", $stderr.string
<ide> end | 2 |
Python | Python | fix line too long linting errors in os driver | 1da255007897ad2099f8fa618ffb3abe938ba109 | <ide><path>libcloud/compute/drivers/openstack.py
<ide> class OpenStack_2_NodeDriver(OpenStack_1_1_NodeDriver):
<ide> # compute API. This deprecated proxied API does not offer all
<ide> # functionality that the Glance Image service API offers.
<ide> # See https://developer.openstack.org/api-ref/compute/
<del> # > These APIs are proxy calls to the Image service. Nova has deprecated all
<del> # > the proxy APIs and users should use the native APIs instead. These will fail
<del> # > with a 404 starting from microversion 2.36. See: Relevant Image APIs.
<del> # For example, managing image visibility and sharing machine images across
<del> # tenants can not be done using the proxied image API in the compute endpoint,
<del> # but it can be done with the Glance Image API.
<del> # See https://developer.openstack.org/api-ref/image/v2/index.html#list-image-members
<add> #
<add> # > These APIs are proxy calls to the Image service. Nova has deprecated
<add> # > all the proxy APIs and users should use the native APIs instead. These
<add> # > will fail with a 404 starting from microversion 2.36. See: Relevant
<add> # > Image APIs.
<add> #
<add> # For example, managing image visibility and sharing machine
<add> # images across tenants can not be done using the proxied image API in the
<add> # compute endpoint, but it can be done with the Glance Image API.
<add> # See https://developer.openstack.org/api-ref/
<add> # image/v2/index.html#list-image-members
<ide> image_connectionCls = OpenStack_2_ImageConnection
<ide> image_connection = None
<ide> type = Provider.OPENSTACK | 1 |
Ruby | Ruby | fix corner case | a232e3a791ac97b3ac45ab9d6b34e5c65a49b943 | <ide><path>Library/Homebrew/dev-cmd/extract.rb
<ide>
<ide> class BottleSpecification
<ide> def method_missing(*); end
<add>
<add> def respond_to_missing?(*)
<add> true
<add> end
<ide> end
<ide>
<ide> class Module
<ide> def method_missing(*); end
<add>
<add> def respond_to_missing?(*)
<add> true
<add> end
<ide> end
<ide>
<ide> class DependencyCollector
<ide> def extract
<ide> end
<ide> odie "Could not find #{name}! The formula or version may not have existed." if test_formula.nil?
<ide> result = Git.last_revision_of_file(repo, file, before_commit: rev)
<add> elsif File.exist?(file)
<add> version = Formulary.factory(file).version
<add> result = File.read(file)
<ide> else
<ide> rev = Git.last_revision_commit_of_file(repo, file)
<ide> version = formula_at_revision(repo, name, file, rev).version | 1 |
Javascript | Javascript | fix trailing whitespace | 64a3f42f14d9bc43b7ddb1f91a8800372aca41e6 | <ide><path>src/ng/directive/input.js
<ide> function textInputType(scope, element, attr, ctrl, $sniffer, $browser) {
<ide> var value = element.val(),
<ide> event = ev && ev.type;
<ide>
<del> // IE (11 and under) seem to emit an 'input' event if the placeholder value changes.
<add> // IE (11 and under) seem to emit an 'input' event if the placeholder value changes.
<ide> // We don't want to dirty the value when this happens, so we abort here. Unfortunately,
<ide> // IE also sends input events for other non-input-related things, (such as focusing on a
<ide> // form control), so this change is not entirely enough to solve this. | 1 |
Python | Python | add kerberos integration when launching trino | 7f1ac2d5f9ecc582247f0bcc07caf08330fb7ed4 | <ide><path>dev/breeze/src/airflow_breeze/params/shell_params.py
<ide> def compose_file(self) -> str:
<ide> if len(integrations) > 0:
<ide> for integration in integrations:
<ide> compose_file_list.append(DOCKER_COMPOSE_DIR / f"integration-{integration}.yml")
<add> if "trino" in integrations and "kerberos" not in integrations:
<add> get_console().print(
<add> "[warning]Adding `kerberos` integration as it is implicitly needed by trino",
<add> )
<add> compose_file_list.append(DOCKER_COMPOSE_DIR / "integration-kerberos.yml")
<ide> return os.pathsep.join([os.fspath(f) for f in compose_file_list])
<ide>
<ide> @property | 1 |
Ruby | Ruby | remove unusused variables | 7ba0fe21729794e4023bdb182a9ff562231be0c9 | <ide><path>activerecord/lib/active_record/attribute_methods/primary_key.rb
<ide> def get_primary_key(base_name) #:nodoc:
<ide> # end
<ide> # Project.primary_key # => "foo_id"
<ide> def primary_key=(value)
<del> @original_primary_key = @primary_key if defined?(@primary_key)
<del> @primary_key = value && value.to_s
<del> @quoted_primary_key = nil
<add> @primary_key = value && value.to_s
<add> @quoted_primary_key = nil
<ide> end
<ide> end
<ide> end
<ide><path>activerecord/lib/active_record/locking/optimistic.rb
<ide> def locking_enabled?
<ide>
<ide> # Set the column to use for optimistic locking. Defaults to +lock_version+.
<ide> def locking_column=(value)
<del> @original_locking_column = @locking_column if defined?(@locking_column)
<del> @locking_column = value.to_s
<add> @locking_column = value.to_s
<ide> end
<ide>
<ide> # The version column used for optimistic locking. Defaults to +lock_version+.
<ide><path>activerecord/lib/active_record/model_schema.rb
<ide> def table_name
<ide> # You can also just define your own <tt>self.table_name</tt> method; see
<ide> # the documentation for ActiveRecord::Base#table_name.
<ide> def table_name=(value)
<del> @original_table_name = @table_name if defined?(@table_name)
<del> @table_name = value && value.to_s
<del> @quoted_table_name = nil
<del> @arel_table = nil
<del> @relation = Relation.new(self, arel_table)
<add> @table_name = value && value.to_s
<add> @quoted_table_name = nil
<add> @arel_table = nil
<add> @relation = Relation.new(self, arel_table)
<ide> end
<ide>
<ide> # Returns a quoted version of the table name, used to construct SQL statements.
<ide> def inheritance_column
<ide>
<ide> # Sets the value of inheritance_column
<ide> def inheritance_column=(value)
<del> @original_inheritance_column = inheritance_column
<del> @inheritance_column = value.to_s
<add> @inheritance_column = value.to_s
<ide> end
<ide>
<ide> def sequence_name
<ide> def reset_sequence_name #:nodoc:
<ide> # self.sequence_name = "projectseq" # default would have been "project_seq"
<ide> # end
<ide> def sequence_name=(value)
<del> @original_sequence_name = @sequence_name if defined?(@sequence_name)
<del> @sequence_name = value.to_s
<add> @sequence_name = value.to_s
<ide> end
<ide>
<ide> # Indicates whether the table associated with this class exists | 3 |
Python | Python | update outdated docs in scheduler_job.py | 61b1ea368df5aa0962ae85b7caff442c990bba57 | <ide><path>airflow/jobs/scheduler_job.py
<ide> class DagFileProcessor(LoggingMixin):
<ide> This includes:
<ide>
<ide> 1. Execute the file and look for DAG objects in the namespace.
<del> 2. Pickle the DAG and save it to the DB (if necessary).
<del> 3. For each DAG, see what tasks should run and create appropriate task
<del> instances in the DB.
<del> 4. Record any errors importing the file into ORM
<del> 5. Kill (in ORM) any task instances belonging to the DAGs that haven't
<del> issued a heartbeat in a while.
<add> 2. Execute any Callbacks if passed to DagFileProcessor.process_file
<add> 3. Serialize the DAGs and save it to DB (or update existing record in the DB).
<add> 4. Pickle the DAG and save it to the DB (if necessary).
<add> 5. Record any errors importing the file into ORM
<ide>
<del> Returns a list of SimpleDag objects that represent the DAGs found in
<del> the file
<add> Returns a tuple of 'number of dags found' and 'the count of import errors'
<ide>
<ide> :param dag_ids: If specified, only look at these DAG ID's
<ide> :type dag_ids: List[str]
<ide> def process_file(
<ide> This includes:
<ide>
<ide> 1. Execute the file and look for DAG objects in the namespace.
<del> 2. Pickle the DAG and save it to the DB (if necessary).
<del> 3. For each DAG, see what tasks should run and create appropriate task
<del> instances in the DB.
<del> 4. Record any errors importing the file into ORM
<add> 2. Execute any Callbacks if passed to this method.
<add> 3. Serialize the DAGs and save it to DB (or update existing record in the DB).
<add> 4. Pickle the DAG and save it to the DB (if necessary).
<add> 5. Record any errors importing the file into ORM
<ide>
<ide> :param file_path: the path to the Python file that should be executed
<ide> :type file_path: str
<ide> def _execute(self) -> None:
<ide>
<ide> self.register_signals()
<ide>
<del> # Start after resetting orphaned tasks to avoid stressing out DB.
<ide> self.processor_agent.start()
<ide>
<ide> execute_start_time = timezone.utcnow() | 1 |
Text | Text | clarify require/import mutual exclusivity | f89530fccc9a2420cef58861aaafa9732683e154 | <ide><path>doc/api/esm.md
<ide> Node.js supports the following conditions:
<ide> * `"import"` - matched when the package is loaded via `import` or
<ide> `import()`. Can reference either an ES module or CommonJS file, as both
<ide> `import` and `import()` can load either ES module or CommonJS sources.
<add> _Always matched when the `"require"` condition is not matched._
<ide> * `"require"` - matched when the package is loaded via `require()`.
<ide> As `require()` only supports CommonJS, the referenced file must be CommonJS.
<add> _Always matched when the `"import"` condition is not matched._
<ide> * `"node"` - matched for any Node.js environment. Can be a CommonJS or ES
<ide> module file. _This condition should always come after `"import"` or
<ide> `"require"`._ | 1 |
Javascript | Javascript | move object destruction to the end of the run loop | 98fe46e280893efc9a5dfd6b6c9815fc007a4fe7 | <ide><path>packages/sproutcore-runtime/lib/system/core_object.js
<ide> CoreObject.PrototypeMixin = SC.Mixin.create({
<ide>
<ide> isDestroyed: false,
<ide>
<add> /**
<add> Destroys an object by setting the isDestroyed flag and removing its
<add> metadata, which effectively destroys observers and bindings.
<add>
<add> If you try to set a property on a destroyed object, an exception will be
<add> raised.
<add>
<add> Note that destruction is scheduled for the end of the run loop and does not
<add> happen immediately.
<add>
<add> @returns {SC.Object} receiver
<add> */
<ide> destroy: function() {
<ide> set(this, 'isDestroyed', true);
<del> this[SC.META_KEY] = null;
<add> SC.run.schedule('destroy', this, this._scheduledDestroy);
<ide> return this;
<ide> },
<ide>
<add> /**
<add> Invoked by the run loop to actually destroy the object. This is
<add> scheduled for execution by the `destroy` method.
<add>
<add> @private
<add> */
<add> _scheduledDestroy: function() {
<add> this[SC.META_KEY] = null;
<add> },
<add>
<ide> bind: function(to, from) {
<ide> if (!(from instanceof SC.Binding)) { from = SC.Binding.from(from); }
<ide> from.to(to).connect(this);
<ide><path>packages/sproutcore-runtime/lib/system/run_loop.js
<ide> SC.run.end = function() {
<ide>
<ide> @property {String}
<ide> */
<del>SC.run.queues = ['sync', 'actions', 'timers'];
<add>SC.run.queues = ['sync', 'actions', 'destroy', 'timers'];
<ide>
<ide> /**
<ide> Adds the passed target/method and any optional arguments to the named
<ide><path>packages/sproutcore-runtime/tests/system/object/destroy_test.js
<add>// ==========================================================================
<add>// Project: SproutCore Runtime
<add>// Copyright: ©2011 Strobe Inc. and contributors.
<add>// License: Licensed under MIT license (see license.js)
<add>// ==========================================================================
<add>/*globals raises TestObject */
<add>
<add>module('sproutcore-runtime/system/object/destroy_test');
<add>
<add>test("should schedule objects to be destroyed at the end of the run loop", function() {
<add> var obj = SC.Object.create();
<add>
<add> SC.run(function() {
<add> var meta;
<add> obj.destroy();
<add> meta = SC.meta(obj);
<add> ok(meta, "object is not destroyed immediately");
<add> });
<add>
<add> ok(obj.get('isDestroyed'), "object is destroyed after run loop finishes");
<add>});
<add>
<add>test("should raise an exception when modifying watched properties on a destroyed object", function() {
<add> var obj = SC.Object.create({
<add> foo: "bar",
<add> fooDidChange: SC.observer(function() { }, 'foo')
<add> });
<add>
<add> SC.run(function() {
<add> obj.destroy();
<add> });
<add>
<add> raises(function() {
<add> SC.set(obj, 'foo', 'baz');
<add> }, Error, "raises an exception");
<add>});
<ide><path>packages/sproutcore-runtime/tests/system/object/observer_test.js
<ide> testBoth('observer should not fire after being destroyed', function(get, set) {
<ide>
<ide> equals(get(obj, 'count'), 0, 'precond - should not invoke observer immediately');
<ide>
<del> obj.destroy();
<add> SC.run(function() { obj.destroy(); });
<ide>
<ide> raises(function() {
<ide> set(obj, 'bar', "BAZ");
<ide><path>packages/sproutcore-views/lib/system/event_dispatcher.js
<ide> SC.EventDispatcher = SC.Object.extend(
<ide> result = true, manager = null;
<ide>
<ide> if (!handled) {
<del> manager = self._findNearestEventManager(view,eventName);
<add> manager = self._findNearestEventManager(view, eventName);
<ide> }
<ide>
<ide> if (manager) {
<ide> result = self._dispatchEvent(manager, evt, eventName, view);
<del> }
<del> else {
<del> result = self._bubbleEvent(view,evt,eventName);
<add> } else if (view) {
<add> result = self._bubbleEvent(view, evt, eventName);
<add> } else {
<add> evt.stopPropagation();
<ide> }
<ide>
<ide> return result;
<ide><path>packages/sproutcore-views/lib/views/view.js
<ide> SC.View = SC.Object.extend(
<ide> $: function(sel) {
<ide> var elem = get(this, 'element');
<ide>
<del> if (!elem) {
<add> if (!elem && !get(this, 'isDestroyed')) {
<ide> // if we don't have an element yet, someone calling this.$() is
<ide> // trying to update an element that isn't in the DOM. Instead,
<ide> // rerender the view to allow the render method to reflect the
<ide><path>packages/sproutcore-views/tests/system/event_dispatcher_test.js
<ide> test("should dispatch events to views", function() {
<ide> equals(parentKeyDownCalled, 0, "does not call keyDown on parent if child handles event");
<ide> });
<ide>
<del>
<ide> test("should send change events up view hierarchy if view contains form elements", function() {
<ide> var receivedEvent;
<ide> view = SC.View.create({
<ide> test("should send change events up view hierarchy if view contains form elements
<ide> equals(receivedEvent.target, SC.$('#is-done')[0], "target property is the element that was clicked");
<ide> });
<ide>
<add>test("events should stop propagating if the view is destroyed", function() {
<add> var parentViewReceived, receivedEvent;
<add>
<add> var parentView = SC.ContainerView.create({
<add> change: function(evt) {
<add> parentViewReceived = true;
<add> }
<add> });
<add>
<add> view = parentView.createChildView(SC.View, {
<add> render: function(buffer) {
<add> buffer.push('<input id="is-done" type="checkbox">');
<add> },
<add>
<add> change: function(evt) {
<add> receivedEvent = true;
<add> get(this, 'parentView').destroy();
<add> }
<add> });
<add>
<add> SC.get(parentView, 'childViews').pushObject(view);
<add>
<add> SC.run(function() {
<add> parentView.append();
<add> });
<add>
<add> ok(SC.$('#is-done').length, "precond - view is in the DOM");
<add> SC.$('#is-done').trigger('change');
<add> ok(!SC.$('#is-done').length, "precond - view is not in the DOM");
<add> ok(receivedEvent, "calls change method when a child element is changed");
<add> ok(!parentViewReceived, "parent view does not receive the event");
<add>});
<add>
<ide> test("should not interfere with event propagation", function() {
<ide> var receivedEvent;
<ide> view = SC.View.create({ | 7 |
Text | Text | add duplicate cve check in sec. release doc | a2115450eb373bd515ff963a55f55947e9a6ada4 | <ide><path>doc/guides/security-release-process.md
<ide> information described.
<ide> * Approved
<ide> * Pass `make test`
<ide> * Have CVEs
<add> * Make sure that dependent libraries have CVEs for their issues. We should
<add> only create CVEs for vulnerabilities in Node.js itself. This is to avoid
<add> having duplicate CVEs for the same vulnerability.
<ide> * Described in the pre/post announcements
<ide>
<ide> * [ ] Pre-release announcement [email][]: ***LINK TO EMAIL*** | 1 |
Javascript | Javascript | improve findbytype() error message | 053347e6bc69de79dfa46bb422868b023851c315 | <ide><path>packages/react-test-renderer/src/ReactTestRenderer.js
<ide> import {
<ide> ScopeComponent,
<ide> } from 'shared/ReactWorkTags';
<ide> import invariant from 'shared/invariant';
<add>import getComponentName from 'shared/getComponentName';
<ide> import ReactVersion from 'shared/ReactVersion';
<ide>
<ide> import {getPublicInstance} from './ReactTestHostConfig';
<ide> class ReactTestInstance {
<ide> findByType(type: any): ReactTestInstance {
<ide> return expectOne(
<ide> this.findAllByType(type, {deep: false}),
<del> `with node type: "${type.displayName || type.name}"`,
<add> `with node type: "${getComponentName(type) || 'Unknown'}"`,
<ide> );
<ide> }
<ide>
<ide><path>packages/react-test-renderer/src/__tests__/ReactTestRenderer-test.internal.js
<ide> describe('ReactTestRenderer', () => {
<ide> expect(Scheduler).toFlushWithoutYielding();
<ide> ReactTestRenderer.create(<App />);
<ide> });
<add>
<add> it('calling findByType() with an invalid component will fall back to "Unknown" for component name', () => {
<add> const App = () => null;
<add> const renderer = ReactTestRenderer.create(<App />);
<add> const NonComponent = {};
<add>
<add> expect(() => {
<add> renderer.root.findByType(NonComponent);
<add> }).toThrowError(`No instances found with node type: "Unknown"`);
<add> });
<ide> }); | 2 |
Text | Text | revise style guide | e4a3664fe98aad704503e6e19e75750d02eed384 | <ide><path>doc/STYLE_GUIDE.md
<ide> # Style Guide
<ide>
<del>* Documentation is written in markdown files with names formatted as
<add>* Documentation is in markdown files with names formatted as
<ide> `lowercase-with-dashes.md`.
<del> * Underscores in filenames are allowed only when they are present in the
<del> topic the document will describe (e.g. `child_process`).
<add> * Use an underscore in the filename only if the underscore is part of the
<add> topic name (e.g., `child_process`).
<ide> * Some files, such as top-level markdown files, are exceptions.
<ide> * Documents should be word-wrapped at 80 characters.
<del>* The formatting described in `.editorconfig` is preferred.
<del> * A [plugin][] is available for some editors to automatically apply these
<del> rules.
<del>* Changes to documentation should be checked with `make lint-md`.
<del>* American English spelling is preferred.
<add>* `.editorconfig` describes the preferred formatting.
<add> * A [plugin][] is available for some editors to apply these rules.
<add>* Check changes to documentation with `make lint-md`.
<add>* Use American English spelling.
<ide> * OK: _capitalize_, _color_
<ide> * NOT OK: _capitalise_, _colour_
<ide> * Use [serial commas][].
<ide> * Use gender-neutral pronouns and gender-neutral plural nouns.
<ide> * OK: _they_, _their_, _them_, _folks_, _people_, _developers_
<ide> * NOT OK: _his_, _hers_, _him_, _her_, _guys_, _dudes_
<del>* When combining wrapping elements (parentheses and quotes), terminal
<del> punctuation should be placed:
<add>* When combining wrapping elements (parentheses and quotes), place terminal
<add> punctuation:
<ide> * Inside the wrapping element if the wrapping element contains a complete
<del> clause — a subject, verb, and an object.
<add> clause.
<ide> * Outside of the wrapping element if the wrapping element contains only a
<ide> fragment of a clause.
<ide> * Documents must start with a level-one heading.
<ide> * Prefer affixing links to inlining links — prefer `[a link][]` to
<ide> `[a link](http://example.com)`.
<del>* When documenting APIs, note the version the API was introduced in at
<del> the end of the section. If an API has been deprecated, also note the first
<del> version that the API appeared deprecated in.
<del>* When using dashes, use [Em dashes][] ("—" or `Option+Shift+"-"` on macOS)
<del> surrounded by spaces, as per [The New York Times Manual of Style and Usage][].
<del>* Including assets:
<del> * If you wish to add an illustration or full program, add it to the
<del> appropriate sub-directory in the `assets/` dir.
<del> * Link to it like so: `[Asset](/assets/{subdir}/{filename})` for file-based
<del> assets, and `` for image-based assets.
<del> * For illustrations, prefer SVG to other assets. When SVG is not feasible,
<del> please keep a close eye on the filesize of the asset you're introducing.
<add>* When documenting APIs, update the YAML comment associated with the API as
<add> appropriate. This is especially true when introducing or deprecating an API.
<add>* Use [Em dashes][] ("—" or `Option+Shift+"-"` on macOS) surrounded by spaces,
<add> as per [The New York Times Manual of Style and Usage][].
<ide> * For code blocks:
<ide> * Use language aware fences. ("```js")
<del> * Code need not be complete — treat code blocks as an illustration or aid to
<add> * Code need not be complete. Treat code blocks as an illustration or aid to
<ide> your point, not as complete running programs. If a complete running program
<ide> is necessary, include it as an asset in `assets/code-examples` and link to
<ide> it.
<del>* When using underscores, asterisks, and backticks, please use proper escaping
<del> (`\_`, `\*` and ``\` `` instead of `_`, `*` and `` ` ``).
<del>* References to constructor functions should use PascalCase.
<del>* References to constructor instances should use camelCase.
<del>* References to methods should be used with parentheses: for example,
<del> `socket.end()` instead of `socket.end`.
<add>* When using underscores, asterisks, and backticks, please use
<add> backslash-escaping: `\_`, `\*`, and ``\` ``.
<add>* Constructors should use PascalCase.
<add>* Instances should use camelCase.
<add>* Denote methods with parentheses: `socket.end()` instead of `socket.end`.
<ide> * Function arguments or object properties should use the following format:
<ide> * ``` * `name` {type|type2} Optional description. **Default:** `value`. ```
<ide> <!--lint disable maximum-line-length remark-lint--> | 1 |
Go | Go | create securityattribute only once (windows) | 2e66c0b6f05acaf00283689786d2c3ac7d1014a0 | <ide><path>pkg/system/filesys_windows.go
<ide> var volumePath = regexp.MustCompile(`^\\\\\?\\Volume{[a-z0-9-]+}\\?$`)
<ide> // so that it is both volume path aware, and can create a directory with
<ide> // an appropriate SDDL defined ACL.
<ide> func MkdirAllWithACL(path string, _ os.FileMode, sddl string) error {
<del> return mkdirall(path, true, sddl)
<add> sa, err := makeSecurityAttributes(sddl)
<add> if err != nil {
<add> return &os.PathError{Op: "mkdirall", Path: path, Err: err}
<add> }
<add> return mkdirall(path, sa)
<ide> }
<ide>
<ide> // MkdirAll is a custom version of os.MkdirAll that is volume path aware for
<ide> // Windows. It can be used as a drop-in replacement for os.MkdirAll.
<ide> func MkdirAll(path string, _ os.FileMode) error {
<del> return mkdirall(path, false, "")
<add> return mkdirall(path, nil)
<ide> }
<ide>
<ide> // mkdirall is a custom version of os.MkdirAll modified for use on Windows
<ide> // so that it is both volume path aware, and can create a directory with
<ide> // a DACL.
<del>func mkdirall(path string, applyACL bool, sddl string) error {
<add>func mkdirall(path string, perm *windows.SecurityAttributes) error {
<ide> if volumePath.MatchString(path) {
<ide> return nil
<ide> }
<ide> func mkdirall(path string, applyACL bool, sddl string) error {
<ide>
<ide> if j > 1 {
<ide> // Create parent
<del> err = mkdirall(path[0:j-1], false, sddl)
<add> err = mkdirall(path[0:j-1], perm)
<ide> if err != nil {
<ide> return err
<ide> }
<ide> }
<ide>
<ide> // Parent now exists; invoke os.Mkdir or mkdirWithACL and use its result.
<del> if applyACL {
<del> err = mkdirWithACL(path, sddl)
<del> } else {
<del> err = os.Mkdir(path, 0)
<del> }
<del>
<add> err = mkdirWithACL(path, perm)
<ide> if err != nil {
<ide> // Handle arguments like "foo/." by
<ide> // double-checking that directory doesn't exist.
<ide> func mkdirall(path string, applyACL bool, sddl string) error {
<ide> // in golang to cater for creating a directory am ACL permitting full
<ide> // access, with inheritance, to any subfolder/file for Built-in Administrators
<ide> // and Local System.
<del>func mkdirWithACL(name string, sddl string) error {
<del> sa := windows.SecurityAttributes{Length: 0}
<del> sd, err := windows.SecurityDescriptorFromString(sddl)
<del> if err != nil {
<del> return &os.PathError{Op: "mkdir", Path: name, Err: err}
<add>func mkdirWithACL(name string, sa *windows.SecurityAttributes) error {
<add> if sa == nil {
<add> return os.Mkdir(name, 0)
<ide> }
<del> sa.Length = uint32(unsafe.Sizeof(sa))
<del> sa.InheritHandle = 1
<del> sa.SecurityDescriptor = sd
<ide>
<ide> namep, err := windows.UTF16PtrFromString(name)
<ide> if err != nil {
<ide> return &os.PathError{Op: "mkdir", Path: name, Err: err}
<ide> }
<ide>
<del> e := windows.CreateDirectory(namep, &sa)
<del> if e != nil {
<del> return &os.PathError{Op: "mkdir", Path: name, Err: e}
<add> err = windows.CreateDirectory(namep, sa)
<add> if err != nil {
<add> return &os.PathError{Op: "mkdir", Path: name, Err: err}
<ide> }
<ide> return nil
<ide> }
<add>
<add>func makeSecurityAttributes(sddl string) (*windows.SecurityAttributes, error) {
<add> var sa windows.SecurityAttributes
<add> sa.Length = uint32(unsafe.Sizeof(sa))
<add> sa.InheritHandle = 1
<add> var err error
<add> sa.SecurityDescriptor, err = windows.SecurityDescriptorFromString(sddl)
<add> if err != nil {
<add> return nil, err
<add> }
<add> return &sa, nil
<add>} | 1 |
Javascript | Javascript | specify electronversion in electronpackager | f953287e5485746ab1aad455c801b349ab115ef2 | <ide><path>build/lib/package-application.js
<ide> module.exports = function () {
<ide> ignore: buildIgnoredPathsRegExp(),
<ide> out: CONFIG.buildOutputPath,
<ide> overwrite: true,
<del> platform: process.platform
<add> platform: process.platform,
<add> version: CONFIG.appMetadata.electronVersion
<ide> }, (err, appPaths) => {
<ide> if (err) {
<ide> console.error(err) | 1 |
Text | Text | capitalize composer, link to 3.0 contributing docs | af82881f42fedfd3ed538beef05324939e24c4a6 | <ide><path>README.md
<ide> applications, without any loss to flexibility.
<ide> ## Installing CakePHP via Composer
<ide>
<ide> You can install CakePHP into your project using
<del>[composer](http://getcomposer.org). If you're starting a new project, we
<add>[Composer](http://getcomposer.org). If you're starting a new project, we
<ide> recommend using the [app skeleton](https://github.com/cakephp/app) as
<ide> a starting point. For existing applications you can run the following:
<ide>
<ide> See [CONTRIBUTING.md](CONTRIBUTING.md) for more information.
<ide>
<ide> [CONTRIBUTING.md](CONTRIBUTING.md) - Quick pointers for contributing to the CakePHP project.
<ide>
<del>[CookBook "Contributing" Section (2.x)](http://book.cakephp.org/2.0/en/contributing.html) [(3.0)](http://book.cakephp.org/3.0/en/contributing.html) - Version-specific details about contributing to the project.
<add>[CookBook "Contributing" Section](http://book.cakephp.org/3.0/en/contributing.html) - Details about contributing to the project. | 1 |
Javascript | Javascript | remove deprecated extracted hooks | a672e8f2f9ad3aeb75213a27978b83ddbc257d91 | <ide><path>lib/Compilation.js
<ide> class Compilation {
<ide> // TODO the following hooks are weirdly located here
<ide> // TODO move them for webpack 5
<ide> /** @type {SyncHook<object, Module>} */
<del> normalModuleLoader: new SyncHook(["loaderContext", "module"]),
<del>
<del> /** @type {SyncBailHook<Chunk[]>} */
<del> optimizeExtractedChunksBasic: new SyncBailHook(["chunks"]),
<del> /** @type {SyncBailHook<Chunk[]>} */
<del> optimizeExtractedChunks: new SyncBailHook(["chunks"]),
<del> /** @type {SyncBailHook<Chunk[]>} */
<del> optimizeExtractedChunksAdvanced: new SyncBailHook(["chunks"]),
<del> /** @type {SyncHook<Chunk[]>} */
<del> afterOptimizeExtractedChunks: new SyncHook(["chunks"])
<add> normalModuleLoader: new SyncHook(["loaderContext", "module"])
<ide> };
<ide> /** @type {string=} */
<ide> this.name = undefined;
<ide><path>lib/optimize/EnsureChunkConditionsPlugin.js
<ide> class EnsureChunkConditionsPlugin {
<ide> "EnsureChunkConditionsPlugin",
<ide> handler
<ide> );
<del> compilation.hooks.optimizeExtractedChunksBasic.tap(
<del> "EnsureChunkConditionsPlugin",
<del> handler
<del> );
<ide> }
<ide> );
<ide> }
<ide><path>lib/optimize/RemoveEmptyChunksPlugin.js
<ide> class RemoveEmptyChunksPlugin {
<ide> "RemoveEmptyChunksPlugin",
<ide> handler
<ide> );
<del> compilation.hooks.optimizeExtractedChunksBasic.tap(
<del> "RemoveEmptyChunksPlugin",
<del> handler
<del> );
<del> compilation.hooks.optimizeExtractedChunksAdvanced.tap(
<del> "RemoveEmptyChunksPlugin",
<del> handler
<del> );
<ide> });
<ide> }
<ide> }
<ide><path>lib/optimize/RemoveParentModulesPlugin.js
<ide> class RemoveParentModulesPlugin {
<ide> "RemoveParentModulesPlugin",
<ide> handler
<ide> );
<del> compilation.hooks.optimizeExtractedChunksBasic.tap(
<del> "RemoveParentModulesPlugin",
<del> handler
<del> );
<ide> });
<ide> }
<ide> } | 4 |
Javascript | Javascript | fix accidental broken impl | 00de31b7ec0a99ff7b899f1318bbc84b817d874e | <ide><path>src/utils/applyMiddleware.js
<ide> import compose from './compose';
<ide> * @returns {Function} A store enhancer applying the middleware.
<ide> */
<ide> export default function applyMiddleware(...middlewares) {
<del> return function applyGivenMiddleware(createStore) {
<del> middlewares = middlewares.slice();
<del> middlewares.reverse();
<add> return (next) => (reducer, initialState) => {
<add> var store = next(reducer, initialState);
<add> var dispatch = store.dispatch;
<add> var chain = [];
<ide>
<del> return function createStoreWithMiddleware(reducer, initialState) {
<del> const store = createStore(reducer, initialState);
<del>
<del> let dispatch = store.dispatch;
<del> let middlewareAPI = {
<del> getState: store.getState,
<del> dispatch: (action) => dispatch(action)
<del> };
<del> middlewares.forEach(middleware =>
<del> dispatch = middleware(store)(dispatch)
<del> );
<add> var middlewareAPI = {
<add> getState: store.getState,
<add> dispatch: (action) => dispatch(action)
<add> };
<add> chain = middlewares.map(middleware => middleware(middlewareAPI));
<add> dispatch = compose(...chain, store.dispatch);
<ide>
<del> return Object.assign({}, store, { dispatch });
<add> return {
<add> ...store,
<add> dispatch
<ide> };
<del> }
<add> };
<ide> } | 1 |
Javascript | Javascript | use arrow function | 484ad3b10334f21a36d3b439a19032a1d332b8ee | <ide><path>test/parallel/test-child-process-env.js
<ide> let response = '';
<ide>
<ide> child.stdout.setEncoding('utf8');
<ide>
<del>child.stdout.on('data', function(chunk) {
<add>child.stdout.on('data', (chunk) => {
<ide> console.log(`stdout: ${chunk}`);
<ide> response += chunk;
<ide> });
<ide>
<del>process.on('exit', function() {
<add>process.on('exit', () => {
<ide> assert.ok(response.includes('HELLO=WORLD'));
<ide> assert.ok(response.includes('FOO=BAR'));
<ide> assert.ok(!response.includes('UNDEFINED=undefined')); | 1 |
Text | Text | fix typos and tweak descriptions | 1606ccf7019a916207edc58f6b7678f95983b439 | <ide><path>docs/usage/deriving-data-selectors.md
<ide> You are not _required_ to use selectors for all state lookups, but they are a st
<ide>
<ide> **A "selector function" is any function that accepts the Redux store state (or part of the state) as an argument, and returns data that is based on that state.**
<ide>
<del>Selectors don't have to be written using a special library, and it doesn't matter whether you write them as arrow functions or the `function` keyword. For example, all of these are valid selector functions:
<add>**Selectors don't have to be written using a special library**, and it doesn't matter whether you write them as arrow functions or the `function` keyword. For example, all of these are valid selector functions:
<ide>
<ide> ```js
<ide> // Arrow function, direct lookup
<ide> const selectItemsWhoseNamesStartWith = (items, namePrefix) =>
<ide> items.filter(item => item.name.startsWith(namePrefix))
<ide> ```
<ide>
<del>A selector function can have any name you want. However, [**we recommend prefixing selector function names with the word `select` combiend with a description of the value being selected**](../style-guide/style-guide.md#name-selector-functions-as-selectthing). Typical examples of this would look like **`selectTodoById`**, **`selectFilteredTodos`**, and **`selectVisibleTodos**`.
<add>A selector function can have any name you want. However, [**we recommend prefixing selector function names with the word `select` combined with a description of the value being selected**](../style-guide/style-guide.md#name-selector-functions-as-selectthing). Typical examples of this would look like **`selectTodoById`**, **`selectFilteredTodos`**, and **`selectVisibleTodos`**.
<ide>
<ide> If you've used [the `useSelector` hook from React-Redux](../tutorials/fundamentals/part-5-ui-and-react.md), you're probably already familiar with the basic idea of a selector function - the functions that we pass to `useSelector` must be selectors:
<ide>
<ide> Selector functions are typically defined in two different parts of a Redux appli
<ide> - In slice files, alongside the reducer logic
<ide> - In component files, either outside the component, or inline in `useSelector` calls
<ide>
<del>A selector function can be used anywhere you have access to the entire Redux root state value. This includes the `useSelector` hook, the `mapState` function for `connect`, middleware, thunks, and sagas.
<add>A selector function can be used anywhere you have access to the entire Redux root state value. This includes the `useSelector` hook, the `mapState` function for `connect`, middleware, thunks, and sagas. For example, thunks and middleware have access to the `getState` argument, so you can call a selector there:
<add>
<add>```js
<add>function addTodosIfAllowed(todoText) {
<add> return (dispatch, getState) => {
<add> const state = getState()
<add> const canAddTodos = selectCanAddTodos(state)
<add>
<add> if (canAddTodos) {
<add> dispatch(todoAdded(todoText))
<add> }
<add> }
<add>}
<add>```
<ide>
<ide> It's not typically possible to use selectors inside of reducers, because a slice reducer only has access to its own slice of the Redux state, and most selectors expect to be given the _entire_ Redux root state as an argument.
<ide>
<ide> const brokenSelector = createSelector(
<ide>
<ide> **Any "output selector" that just returns its inputs is incorrect!** The output selector should always have the transformation logic.
<ide>
<add>Similarly, a memoized selector should _never_ use `state => state` as an input! That will force the selector to always recalculate.
<ide> :::
<ide>
<ide> In typical Reselect usage, you write your top-level "input selectors" as plain functions, and use `createSelector` to create memoized selectors that look up nested values:
<ide> const selectCompletedTodoDescriptions = createSelector(
<ide>
<ide> #### Passing Input Parameters
<ide>
<del>A Reselect-generated selector function can be called with as many arguments as you want: `selectThings(a, b, c, d, e, f)`. However, what matters for re-running the output is not the number of arguments, or whether the arguments themselves have changed to be new references. Instead, it's about the "input selectors" that were defined, and whether _their_ results have changed. Similarly, the arguments for the "output selector" are solely based on what the input selectors return.
<add>A Reselect-generated selector function can be called with as many arguments as you want: `selectThings(a, b, c, d, e)`. However, what matters for re-running the output is not the number of arguments, or whether the arguments themselves have changed to be new references. Instead, it's about the "input selectors" that were defined, and whether _their_ results have changed. Similarly, the arguments for the "output selector" are solely based on what the input selectors return.
<ide>
<ide> This means that if you want to pass additional parameters through to the output selector, you must define input selectors that extract those values from the original selector arguments:
<ide>
<ide> For consistency, you may want to consider passing additional parameters to a sel
<ide>
<ide> #### Selector Factories
<ide>
<del>**`createSelector` only has a default cache size of 1, and this is per each unique instance of a selector**. This creates problems when a single selector function needs to get reused in multiple places with differeing inputs.
<add>**`createSelector` only has a default cache size of 1, and this is per each unique instance of a selector**. This creates problems when a single selector function needs to get reused in multiple places with differing inputs.
<ide>
<ide> One option is to create a "selector factory" - a function that runs `createSelector()` and generates a new unique selector instance every time it's called:
<ide> | 1 |
Javascript | Javascript | add writetostorage method to viewhistory | 48399a3ec7bb9762c28027d4993638908f3e781a | <ide><path>web/view_history.js
<ide> var ViewHistory = (function ViewHistoryClosure() {
<ide> this.database = database;
<ide> },
<ide>
<del> set: function ViewHistory_set(name, val) {
<del> if (!this.isInitializedPromiseResolved) {
<del> return;
<del> }
<del> var file = this.file;
<del> file[name] = val;
<del> var database = JSON.stringify(this.database);
<add> _writeToStorage: function ViewHistory_writeToStorage() {
<add> var databaseStr = JSON.stringify(this.database);
<ide>
<ide> //#if B2G
<del>// asyncStorage.setItem('database', database);
<add>// asyncStorage.setItem('database', databaseStr);
<ide> //#endif
<ide>
<ide> //#if FIREFOX || MOZCENTRAL
<ide> // try {
<ide> // // See comment in try-catch block above.
<del>// sessionStorage.setItem('pdfjsHistory', database);
<add>// sessionStorage.setItem('pdfjsHistory', databaseStr);
<ide> // } catch (ex) {}
<ide> //#endif
<ide>
<ide> //#if !(FIREFOX || MOZCENTRAL || B2G)
<del> localStorage.setItem('database', database);
<add> localStorage.setItem('database', databaseStr);
<ide> //#endif
<ide> },
<ide>
<add> set: function ViewHistory_set(name, val) {
<add> if (!this.isInitializedPromiseResolved) {
<add> return;
<add> }
<add> this.file[name] = val;
<add> this._writeToStorage();
<add> },
<add>
<ide> get: function ViewHistory_get(name, defaultValue) {
<ide> if (!this.isInitializedPromiseResolved) {
<ide> return defaultValue; | 1 |
Javascript | Javascript | fix error message printing | e7391967c284bbe71c352312c06d27730e70b823 | <ide><path>lib/repl.js
<ide> function REPLServer(prompt,
<ide> errStack = self.writer(e);
<ide>
<ide> // Remove one line error braces to keep the old style in place.
<del> if (errStack[errStack.length - 1] === ']') {
<add> if (errStack[0] === '[' && errStack[errStack.length - 1] === ']') {
<ide> errStack = StringPrototypeSlice(errStack, 1, -1);
<ide> }
<ide> }
<ide><path>test/parallel/test-repl-pretty-stack-custom-writer.js
<add>'use strict';
<add>require('../common');
<add>const { PassThrough } = require('stream');
<add>const assert = require('assert');
<add>const repl = require('repl');
<add>
<add>{
<add> const input = new PassThrough();
<add> const output = new PassThrough();
<add>
<add> const r = repl.start({
<add> prompt: '',
<add> input,
<add> output,
<add> writer: String,
<add> terminal: false,
<add> useColors: false
<add> });
<add>
<add> r.write('throw new Error("foo[a]")\n');
<add> r.close();
<add> assert.strictEqual(output.read().toString(), 'Uncaught Error: foo[a]\n');
<add>} | 2 |
Javascript | Javascript | add tests for clearbuffer state machine | 275362ae3b748b86bf7ef278821351dca1d7c0fb | <ide><path>test/parallel/test-stream-writableState-uncorked-bufferedRequestCount.js
<add>'use strict';
<add>
<add>const common = require('../common');
<add>const assert = require('assert');
<add>const stream = require('stream');
<add>
<add>const writable = new stream.Writable();
<add>
<add>writable._writev = common.mustCall((chunks, cb) => {
<add> assert.equal(chunks.length, 2, 'two chunks to write');
<add> cb();
<add>}, 1);
<add>
<add>writable._write = common.mustCall((chunk, encoding, cb) => {
<add> cb();
<add>}, 1);
<add>
<add>// first cork
<add>writable.cork();
<add>assert.strictEqual(writable._writableState.corked, 1);
<add>assert.strictEqual(writable._writableState.bufferedRequestCount, 0);
<add>
<add>// cork again
<add>writable.cork();
<add>assert.strictEqual(writable._writableState.corked, 2);
<add>
<add>// the first chunk is buffered
<add>writable.write('first chunk');
<add>assert.strictEqual(writable._writableState.bufferedRequestCount, 1);
<add>
<add>// first uncork does nothing
<add>writable.uncork();
<add>assert.strictEqual(writable._writableState.corked, 1);
<add>assert.strictEqual(writable._writableState.bufferedRequestCount, 1);
<add>
<add>process.nextTick(uncork);
<add>
<add>// the second chunk is buffered, because we uncork at the end of tick
<add>writable.write('second chunk');
<add>assert.strictEqual(writable._writableState.corked, 1);
<add>assert.strictEqual(writable._writableState.bufferedRequestCount, 2);
<add>
<add>function uncork() {
<add> // second uncork flushes the buffer
<add> writable.uncork();
<add> assert.strictEqual(writable._writableState.corked, 0);
<add> assert.strictEqual(writable._writableState.bufferedRequestCount, 0);
<add>
<add> // verify that end() uncorks correctly
<add> writable.cork();
<add> writable.write('third chunk');
<add> writable.end();
<add>
<add> // end causes an uncork() as well
<add> assert.strictEqual(writable._writableState.corked, 0);
<add> assert.strictEqual(writable._writableState.bufferedRequestCount, 0);
<add>} | 1 |
Java | Java | fix compiler warning | b245918574024f4f0e576d984d3b336905d920e1 | <ide><path>spring-webflux/src/main/java/org/springframework/web/reactive/result/view/HttpMessageWriterView.java
<ide> public final Set<String> getModelKeys() {
<ide> @SuppressWarnings("unchecked")
<ide> public Mono<Void> render(Map<String, ?> model, MediaType contentType, ServerWebExchange exchange) {
<ide> return getObjectToRender(model)
<del> .map(value -> {
<del> Publisher stream = Mono.justOrEmpty(value);
<del> ResolvableType type = ResolvableType.forClass(value.getClass());
<del> ServerHttpResponse response = exchange.getResponse();
<del> return this.writer.write(stream, type, contentType, response, Collections.emptyMap());
<del> })
<add> .map(value -> write(value, contentType, exchange))
<ide> .orElseGet(() -> exchange.getResponse().setComplete());
<ide> }
<ide>
<ide> private boolean isMatch(Map.Entry<String, ?> entry) {
<ide> return getMessageWriter().canWrite(type, null);
<ide> }
<ide>
<add> @SuppressWarnings("unchecked")
<add> private <T> Mono<Void> write(T value, MediaType contentType, ServerWebExchange exchange) {
<add> Publisher<T> input = Mono.justOrEmpty(value);
<add> ResolvableType elementType = ResolvableType.forClass(value.getClass());
<add> return ((HttpMessageWriter<T>) this.writer).write(
<add> input, elementType, contentType, exchange.getResponse(), Collections.emptyMap());
<add> }
<add>
<ide> } | 1 |
Javascript | Javascript | normalize process.resourcespath on load | 75627f50a276e8998fc3da16b2bd0fb1ba40567f | <ide><path>static/index.js
<ide> window.onload = function() {
<ide> // Skip "?loadSettings=".
<ide> var loadSettings = JSON.parse(decodeURIComponent(location.search.substr(14)));
<ide>
<add> // Normalize to make sure drive letter case is consistent on Windows
<add> process.resourcesPath = path.normalize(process.resourcesPath);
<add>
<ide> var devMode = loadSettings.devMode || !loadSettings.resourcePath.startsWith(process.resourcesPath + require('path').sep);
<ide>
<ide> // Require before the module cache in dev mode | 1 |
Javascript | Javascript | use const in test-crypto-pbkdf2 | 7837866923347acaca73d607fabf1f73af7311d8 | <ide><path>test/parallel/test-crypto-pbkdf2.js
<ide> 'use strict';
<del>var common = require('../common');
<del>var assert = require('assert');
<add>const common = require('../common');
<add>const assert = require('assert');
<ide>
<ide> if (!common.hasCrypto) {
<ide> common.skip('missing crypto');
<ide> return;
<ide> }
<del>var crypto = require('crypto');
<add>const crypto = require('crypto');
<ide>
<ide> //
<ide> // Test PBKDF2 with RFC 6070 test vectors (except #4)
<ide> //
<ide> function testPBKDF2(password, salt, iterations, keylen, expected) {
<del> var actual = crypto.pbkdf2Sync(password, salt, iterations, keylen, 'sha256');
<add> const actual =
<add> crypto.pbkdf2Sync(password, salt, iterations, keylen, 'sha256');
<ide> assert.strictEqual(actual.toString('latin1'), expected);
<ide>
<ide> crypto.pbkdf2(password, salt, iterations, keylen, 'sha256', (err, actual) => {
<ide> testPBKDF2('pass\0word', 'sa\0lt', 4096, 16,
<ide> '\x89\xb6\x9d\x05\x16\xf8\x29\x89\x3c\x69\x62\x26\x65' +
<ide> '\x0a\x86\x87');
<ide>
<del>var expected =
<add>const expected =
<ide> '64c486c55d30d4c5a079b8823b7d7cb37ff0556f537da8410233bcec330ed956';
<del>var key = crypto.pbkdf2Sync('password', 'salt', 32, 32, 'sha256');
<add>const key = crypto.pbkdf2Sync('password', 'salt', 32, 32, 'sha256');
<ide> assert.strictEqual(key.toString('hex'), expected);
<ide>
<ide> crypto.pbkdf2('password', 'salt', 32, 32, 'sha256', common.mustCall(ondone)); | 1 |
Javascript | Javascript | fix typo in inspect-proxy | e8b8d940d503a3c51abdda216a34010f7a42410a | <ide><path>benchmark/util/inspect-proxy.js
<ide> const bench = common.createBenchmark(main, {
<ide> });
<ide>
<ide> function twoDifferentProxies(n) {
<del> // This one should be slower between we're looking up multiple proxies.
<add> // This one should be slower because we're looking up multiple proxies.
<ide> const proxyA = new Proxy({}, {get: () => {}});
<ide> const proxyB = new Proxy({}, {get: () => {}});
<ide> bench.start(); | 1 |
Python | Python | change default to v1 and 90 epochs | 7b21c9f78a6ba66f23b60045c510a2d5e3e5af66 | <ide><path>official/resnet/imagenet_main.py
<ide> def define_imagenet_flags():
<ide> resnet_run_loop.define_resnet_flags(
<ide> resnet_size_choices=['18', '34', '50', '101', '152', '200'])
<ide> flags.adopt_module_key_flags(resnet_run_loop)
<del> flags_core.set_defaults(train_epochs=100)
<add> flags_core.set_defaults(train_epochs=90)
<ide>
<ide>
<ide> def run_imagenet(flags_obj):
<ide><path>official/resnet/resnet_run_loop.py
<ide> def define_resnet_flags(resnet_size_choices=None):
<ide> flags.adopt_module_key_flags(flags_core)
<ide>
<ide> flags.DEFINE_enum(
<del> name='resnet_version', short_name='rv', default='2',
<add> name='resnet_version', short_name='rv', default='1',
<ide> enum_values=['1', '2'],
<ide> help=flags_core.help_wrap(
<ide> 'Version of ResNet. (1 or 2) See README.md for details.')) | 2 |
Javascript | Javascript | fix padding for labels | 87c59fea73cf55b63fca0d0049c351b2ceb468b8 | <ide><path>src/core/core.scale.js
<ide> export default class Scale extends Element {
<ide>
<ide> minSize.width = Math.min(me.maxWidth, minSize.width + labelWidth);
<ide>
<del> me.paddingTop = firstLabelSize.height / 2;
<del> me.paddingBottom = lastLabelSize.height / 2;
<add> me.paddingTop = lastLabelSize.height / 2;
<add> me.paddingBottom = firstLabelSize.height / 2;
<ide> }
<ide> }
<ide> | 1 |
Javascript | Javascript | add regression tests for all events | 291db05a756dd88d0f687b3083e85a22abbf5214 | <ide><path>packages/react-dom/src/__tests__/ReactDOMEventPropagation-test.js
<ide> describe('ReactDOMEventListener', () => {
<ide> let container;
<ide>
<ide> beforeEach(() => {
<add> window.TextEvent = function() {};
<ide> jest.resetModules();
<ide> React = require('react');
<ide> jest.isolateModules(() => {
<ide> describe('ReactDOMEventListener', () => {
<ide> }
<ide>
<ide> describe('bubbling events', () => {
<add> it('onAnimationEnd', () => {
<add> testNativeBubblingEvent({
<add> type: 'div',
<add> reactEvent: 'onAnimationEnd',
<add> nativeEvent: 'animationend',
<add> dispatch(node) {
<add> node.dispatchEvent(
<add> new Event('animationend', {
<add> bubbles: true,
<add> cancelable: true,
<add> }),
<add> );
<add> },
<add> });
<add> });
<add>
<add> it('onAnimationIteration', () => {
<add> testNativeBubblingEvent({
<add> type: 'div',
<add> reactEvent: 'onAnimationIteration',
<add> nativeEvent: 'animationiteration',
<add> dispatch(node) {
<add> node.dispatchEvent(
<add> new Event('animationiteration', {
<add> bubbles: true,
<add> cancelable: true,
<add> }),
<add> );
<add> },
<add> });
<add> });
<add>
<add> it('onAnimationStart', () => {
<add> testNativeBubblingEvent({
<add> type: 'div',
<add> reactEvent: 'onAnimationStart',
<add> nativeEvent: 'animationstart',
<add> dispatch(node) {
<add> node.dispatchEvent(
<add> new Event('animationstart', {
<add> bubbles: true,
<add> cancelable: true,
<add> }),
<add> );
<add> },
<add> });
<add> });
<add>
<add> it('onAuxClick', () => {
<add> testNativeBubblingEvent({
<add> type: 'div',
<add> reactEvent: 'onAuxClick',
<add> nativeEvent: 'auxclick',
<add> dispatch(node) {
<add> node.dispatchEvent(
<add> new KeyboardEvent('auxclick', {
<add> bubbles: true,
<add> cancelable: true,
<add> }),
<add> );
<add> },
<add> });
<add> });
<add>
<add> it('onBlur', () => {
<add> testNativeBubblingEvent({
<add> type: 'input',
<add> reactEvent: 'onBlur',
<add> nativeEvent: 'focusout',
<add> dispatch(node) {
<add> const e = new Event('focusout', {
<add> bubbles: true,
<add> cancelable: true,
<add> });
<add> node.dispatchEvent(e);
<add> },
<add> });
<add> });
<add>
<ide> // This test will fail in legacy mode (only used in WWW)
<ide> // because we emulate the React 16 behavior where
<ide> // the click handler is attached to the document.
<ide> describe('ReactDOMEventListener', () => {
<ide> reactEvent: 'onClick',
<ide> nativeEvent: 'click',
<ide> dispatch(node) {
<del> node.click();
<add> node.click();
<add> },
<add> });
<add> });
<add>
<add> it('onContextMenu', () => {
<add> testNativeBubblingEvent({
<add> type: 'div',
<add> reactEvent: 'onContextMenu',
<add> nativeEvent: 'contextmenu',
<add> dispatch(node) {
<add> node.dispatchEvent(
<add> new MouseEvent('contextmenu', {
<add> bubbles: true,
<add> cancelable: true,
<add> }),
<add> );
<add> },
<add> });
<add> });
<add>
<add> it('onCopy', () => {
<add> testNativeBubblingEvent({
<add> type: 'div',
<add> reactEvent: 'onCopy',
<add> nativeEvent: 'copy',
<add> dispatch(node) {
<add> node.dispatchEvent(
<add> new Event('copy', {
<add> bubbles: true,
<add> cancelable: true,
<add> }),
<add> );
<add> },
<add> });
<add> });
<add>
<add> it('onCut', () => {
<add> testNativeBubblingEvent({
<add> type: 'div',
<add> reactEvent: 'onCut',
<add> nativeEvent: 'cut',
<add> dispatch(node) {
<add> node.dispatchEvent(
<add> new Event('cut', {
<add> bubbles: true,
<add> cancelable: true,
<add> }),
<add> );
<add> },
<add> });
<add> });
<add>
<add> it('onDoubleClick', () => {
<add> testNativeBubblingEvent({
<add> type: 'div',
<add> reactEvent: 'onDoubleClick',
<add> nativeEvent: 'dblclick',
<add> dispatch(node) {
<add> node.dispatchEvent(
<add> new KeyboardEvent('dblclick', {
<add> bubbles: true,
<add> cancelable: true,
<add> }),
<add> );
<add> },
<add> });
<add> });
<add>
<add> it('onDrag', () => {
<add> testNativeBubblingEvent({
<add> type: 'div',
<add> reactEvent: 'onDrag',
<add> nativeEvent: 'drag',
<add> dispatch(node) {
<add> node.dispatchEvent(
<add> new MouseEvent('drag', {
<add> bubbles: true,
<add> cancelable: true,
<add> }),
<add> );
<add> },
<add> });
<add> });
<add>
<add> it('onDragEnd', () => {
<add> testNativeBubblingEvent({
<add> type: 'div',
<add> reactEvent: 'onDragEnd',
<add> nativeEvent: 'dragend',
<add> dispatch(node) {
<add> node.dispatchEvent(
<add> new MouseEvent('dragend', {
<add> bubbles: true,
<add> cancelable: true,
<add> }),
<add> );
<add> },
<add> });
<add> });
<add>
<add> it('onDragEnter', () => {
<add> testNativeBubblingEvent({
<add> type: 'div',
<add> reactEvent: 'onDragEnter',
<add> nativeEvent: 'dragenter',
<add> dispatch(node) {
<add> node.dispatchEvent(
<add> new MouseEvent('dragenter', {
<add> bubbles: true,
<add> cancelable: true,
<add> }),
<add> );
<add> },
<add> });
<add> });
<add>
<add> it('onDragExit', () => {
<add> testNativeBubblingEvent({
<add> type: 'div',
<add> reactEvent: 'onDragExit',
<add> nativeEvent: 'dragexit',
<add> dispatch(node) {
<add> node.dispatchEvent(
<add> new MouseEvent('dragexit', {
<add> bubbles: true,
<add> cancelable: true,
<add> }),
<add> );
<add> },
<add> });
<add> });
<add>
<add> it('onDragLeave', () => {
<add> testNativeBubblingEvent({
<add> type: 'div',
<add> reactEvent: 'onDragLeave',
<add> nativeEvent: 'dragleave',
<add> dispatch(node) {
<add> node.dispatchEvent(
<add> new MouseEvent('dragleave', {
<add> bubbles: true,
<add> cancelable: true,
<add> }),
<add> );
<add> },
<add> });
<add> });
<add>
<add> it('onDragOver', () => {
<add> testNativeBubblingEvent({
<add> type: 'div',
<add> reactEvent: 'onDragOver',
<add> nativeEvent: 'dragover',
<add> dispatch(node) {
<add> node.dispatchEvent(
<add> new MouseEvent('dragover', {
<add> bubbles: true,
<add> cancelable: true,
<add> }),
<add> );
<add> },
<add> });
<add> });
<add>
<add> it('onDragStart', () => {
<add> testNativeBubblingEvent({
<add> type: 'div',
<add> reactEvent: 'onDragStart',
<add> nativeEvent: 'dragstart',
<add> dispatch(node) {
<add> node.dispatchEvent(
<add> new MouseEvent('dragstart', {
<add> bubbles: true,
<add> cancelable: true,
<add> }),
<add> );
<add> },
<add> });
<add> });
<add>
<add> it('onDrop', () => {
<add> testNativeBubblingEvent({
<add> type: 'div',
<add> reactEvent: 'onDrop',
<add> nativeEvent: 'drop',
<add> dispatch(node) {
<add> node.dispatchEvent(
<add> new MouseEvent('drop', {
<add> bubbles: true,
<add> cancelable: true,
<add> }),
<add> );
<add> },
<add> });
<add> });
<add>
<add> it('onFocus', () => {
<add> testNativeBubblingEvent({
<add> type: 'input',
<add> reactEvent: 'onFocus',
<add> nativeEvent: 'focusin',
<add> dispatch(node) {
<add> const e = new Event('focusin', {
<add> bubbles: true,
<add> cancelable: true,
<add> });
<add> node.dispatchEvent(e);
<add> },
<add> });
<add> });
<add>
<add> // TODO: this has regressed. Fix me.
<add> it.skip('onGotPointerCapture', () => {
<add> testNativeBubblingEvent({
<add> type: 'div',
<add> reactEvent: 'onGotPointerCapture',
<add> nativeEvent: 'gotpointercapture',
<add> dispatch(node) {
<add> node.dispatchEvent(
<add> new Event('gotpointercapture', {
<add> bubbles: true,
<add> cancelable: true,
<add> }),
<add> );
<add> },
<add> });
<add> });
<add>
<add> it('onKeyDown', () => {
<add> testNativeBubblingEvent({
<add> type: 'input',
<add> reactEvent: 'onKeyDown',
<add> nativeEvent: 'keydown',
<add> dispatch(node) {
<add> node.dispatchEvent(
<add> new KeyboardEvent('keydown', {
<add> bubbles: true,
<add> cancelable: true,
<add> }),
<add> );
<add> },
<add> });
<add> });
<add>
<add> it('onKeyPress', () => {
<add> testNativeBubblingEvent({
<add> type: 'input',
<add> reactEvent: 'onKeyPress',
<add> nativeEvent: 'keypress',
<add> dispatch(node) {
<add> node.dispatchEvent(
<add> new KeyboardEvent('keypress', {
<add> keyCode: 13,
<add> bubbles: true,
<add> cancelable: true,
<add> }),
<add> );
<add> },
<add> });
<add> });
<add>
<add> it('onKeyUp', () => {
<add> testNativeBubblingEvent({
<add> type: 'input',
<add> reactEvent: 'onKeyUp',
<add> nativeEvent: 'keyup',
<add> dispatch(node) {
<add> node.dispatchEvent(
<add> new KeyboardEvent('keyup', {
<add> bubbles: true,
<add> cancelable: true,
<add> }),
<add> );
<add> },
<add> });
<add> });
<add>
<add> // TODO: this has regressed. Fix me.
<add> it.skip('onLostPointerCapture', () => {
<add> testNativeBubblingEvent({
<add> type: 'div',
<add> reactEvent: 'onLostPointerCapture',
<add> nativeEvent: 'lostpointercapture',
<add> dispatch(node) {
<add> node.dispatchEvent(
<add> new Event('lostpointercapture', {
<add> bubbles: true,
<add> cancelable: true,
<add> }),
<add> );
<add> },
<add> });
<add> });
<add>
<add> it('onMouseDown', () => {
<add> testNativeBubblingEvent({
<add> type: 'div',
<add> reactEvent: 'onMouseDown',
<add> nativeEvent: 'mousedown',
<add> dispatch(node) {
<add> node.dispatchEvent(
<add> new MouseEvent('mousedown', {
<add> bubbles: true,
<add> cancelable: true,
<add> }),
<add> );
<add> },
<add> });
<add> });
<add>
<add> it('onMouseOut', () => {
<add> testNativeBubblingEvent({
<add> type: 'div',
<add> reactEvent: 'onMouseOut',
<add> nativeEvent: 'mouseout',
<add> dispatch(node) {
<add> node.dispatchEvent(
<add> new MouseEvent('mouseout', {
<add> bubbles: true,
<add> cancelable: true,
<add> }),
<add> );
<add> },
<add> });
<add> });
<add>
<add> it('onMouseOver', () => {
<add> testNativeBubblingEvent({
<add> type: 'div',
<add> reactEvent: 'onMouseOver',
<add> nativeEvent: 'mouseover',
<add> dispatch(node) {
<add> node.dispatchEvent(
<add> new MouseEvent('mouseover', {
<add> bubbles: true,
<add> cancelable: true,
<add> }),
<add> );
<add> },
<add> });
<add> });
<add>
<add> it('onMouseUp', () => {
<add> testNativeBubblingEvent({
<add> type: 'div',
<add> reactEvent: 'onMouseUp',
<add> nativeEvent: 'mouseup',
<add> dispatch(node) {
<add> node.dispatchEvent(
<add> new MouseEvent('mouseup', {
<add> bubbles: true,
<add> cancelable: true,
<add> }),
<add> );
<add> },
<add> });
<add> });
<add>
<add> it('onPaste', () => {
<add> testNativeBubblingEvent({
<add> type: 'div',
<add> reactEvent: 'onPaste',
<add> nativeEvent: 'paste',
<add> dispatch(node) {
<add> node.dispatchEvent(
<add> new Event('paste', {
<add> bubbles: true,
<add> cancelable: true,
<add> }),
<add> );
<add> },
<add> });
<add> });
<add>
<add> it('onPointerCancel', () => {
<add> testNativeBubblingEvent({
<add> type: 'div',
<add> reactEvent: 'onPointerCancel',
<add> nativeEvent: 'pointercancel',
<add> dispatch(node) {
<add> node.dispatchEvent(
<add> new Event('pointercancel', {
<add> bubbles: true,
<add> cancelable: true,
<add> }),
<add> );
<add> },
<add> });
<add> });
<add>
<add> it('onPointerDown', () => {
<add> testNativeBubblingEvent({
<add> type: 'div',
<add> reactEvent: 'onPointerDown',
<add> nativeEvent: 'pointerdown',
<add> dispatch(node) {
<add> node.dispatchEvent(
<add> new Event('pointerdown', {
<add> bubbles: true,
<add> cancelable: true,
<add> }),
<add> );
<add> },
<add> });
<add> });
<add>
<add> it('onPointerMove', () => {
<add> testNativeBubblingEvent({
<add> type: 'div',
<add> reactEvent: 'onPointerMove',
<add> nativeEvent: 'pointermove',
<add> dispatch(node) {
<add> node.dispatchEvent(
<add> new Event('pointermove', {
<add> bubbles: true,
<add> cancelable: true,
<add> }),
<add> );
<add> },
<add> });
<add> });
<add>
<add> it('onPointerOut', () => {
<add> testNativeBubblingEvent({
<add> type: 'div',
<add> reactEvent: 'onPointerOut',
<add> nativeEvent: 'pointerout',
<add> dispatch(node) {
<add> node.dispatchEvent(
<add> new Event('pointerout', {
<add> bubbles: true,
<add> cancelable: true,
<add> }),
<add> );
<add> },
<add> });
<add> });
<add>
<add> it('onPointerOver', () => {
<add> testNativeBubblingEvent({
<add> type: 'div',
<add> reactEvent: 'onPointerOver',
<add> nativeEvent: 'pointerover',
<add> dispatch(node) {
<add> node.dispatchEvent(
<add> new Event('pointerover', {
<add> bubbles: true,
<add> cancelable: true,
<add> }),
<add> );
<add> },
<add> });
<add> });
<add>
<add> it('onPointerUp', () => {
<add> testNativeBubblingEvent({
<add> type: 'div',
<add> reactEvent: 'onPointerUp',
<add> nativeEvent: 'pointerup',
<add> dispatch(node) {
<add> node.dispatchEvent(
<add> new Event('pointerup', {
<add> bubbles: true,
<add> cancelable: true,
<add> }),
<add> );
<add> },
<add> });
<add> });
<add>
<add> it('onReset', () => {
<add> testNativeBubblingEvent({
<add> type: 'form',
<add> reactEvent: 'onReset',
<add> nativeEvent: 'reset',
<add> dispatch(node) {
<add> const e = new Event('reset', {
<add> bubbles: true,
<add> cancelable: true,
<add> });
<add> node.dispatchEvent(e);
<add> },
<add> });
<add> });
<add>
<add> it('onSubmit', () => {
<add> testNativeBubblingEvent({
<add> type: 'form',
<add> reactEvent: 'onSubmit',
<add> nativeEvent: 'submit',
<add> dispatch(node) {
<add> const e = new Event('submit', {
<add> bubbles: true,
<add> cancelable: true,
<add> });
<add> node.dispatchEvent(e);
<add> },
<add> });
<add> });
<add>
<add> it('onTouchCancel', () => {
<add> testNativeBubblingEvent({
<add> type: 'div',
<add> reactEvent: 'onTouchCancel',
<add> nativeEvent: 'touchcancel',
<add> dispatch(node) {
<add> node.dispatchEvent(
<add> new Event('touchcancel', {
<add> bubbles: true,
<add> cancelable: true,
<add> }),
<add> );
<add> },
<add> });
<add> });
<add>
<add> it('onTouchEnd', () => {
<add> testNativeBubblingEvent({
<add> type: 'div',
<add> reactEvent: 'onTouchEnd',
<add> nativeEvent: 'touchend',
<add> dispatch(node) {
<add> node.dispatchEvent(
<add> new Event('touchend', {
<add> bubbles: true,
<add> cancelable: true,
<add> }),
<add> );
<add> },
<add> });
<add> });
<add>
<add> it('onTouchMove', () => {
<add> testNativeBubblingEvent({
<add> type: 'div',
<add> reactEvent: 'onTouchMove',
<add> nativeEvent: 'touchmove',
<add> dispatch(node) {
<add> node.dispatchEvent(
<add> new Event('touchmove', {
<add> bubbles: true,
<add> cancelable: true,
<add> }),
<add> );
<add> },
<add> });
<add> });
<add>
<add> it('onTouchStart', () => {
<add> testNativeBubblingEvent({
<add> type: 'div',
<add> reactEvent: 'onTouchStart',
<add> nativeEvent: 'touchstart',
<add> dispatch(node) {
<add> node.dispatchEvent(
<add> new Event('touchstart', {
<add> bubbles: true,
<add> cancelable: true,
<add> }),
<add> );
<add> },
<add> });
<add> });
<add>
<add> it('onTransitionEnd', () => {
<add> testNativeBubblingEvent({
<add> type: 'div',
<add> reactEvent: 'onTransitionEnd',
<add> nativeEvent: 'transitionend',
<add> dispatch(node) {
<add> node.dispatchEvent(
<add> new Event('transitionend', {
<add> bubbles: true,
<add> cancelable: true,
<add> }),
<add> );
<add> },
<add> });
<add> });
<add>
<add> it('onWheel', () => {
<add> testNativeBubblingEvent({
<add> type: 'div',
<add> reactEvent: 'onWheel',
<add> nativeEvent: 'wheel',
<add> dispatch(node) {
<add> node.dispatchEvent(
<add> new Event('wheel', {
<add> bubbles: true,
<add> cancelable: true,
<add> }),
<add> );
<add> },
<add> });
<add> });
<add> });
<add>
<add> describe('non-bubbling events that bubble in React', () => {
<add> it('onAbort', () => {
<add> testEmulatedBubblingEvent({
<add> type: 'video',
<add> reactEvent: 'onAbort',
<add> nativeEvent: 'abort',
<add> dispatch(node) {
<add> const e = new Event('abort', {
<add> bubbles: false,
<add> cancelable: true,
<add> });
<add> node.dispatchEvent(e);
<add> },
<add> });
<add> });
<add>
<add> it('onCancel', () => {
<add> testEmulatedBubblingEvent({
<add> type: 'dialog',
<add> reactEvent: 'onCancel',
<add> nativeEvent: 'cancel',
<add> dispatch(node) {
<add> const e = new Event('cancel', {
<add> bubbles: false,
<add> cancelable: true,
<add> });
<add> node.dispatchEvent(e);
<add> },
<add> });
<add> });
<add>
<add> it('onCanPlay', () => {
<add> testEmulatedBubblingEvent({
<add> type: 'video',
<add> reactEvent: 'onCanPlay',
<add> nativeEvent: 'canplay',
<add> dispatch(node) {
<add> const e = new Event('canplay', {
<add> bubbles: false,
<add> cancelable: true,
<add> });
<add> node.dispatchEvent(e);
<add> },
<add> });
<add> });
<add>
<add> it('onCanPlayThrough', () => {
<add> testEmulatedBubblingEvent({
<add> type: 'video',
<add> reactEvent: 'onCanPlayThrough',
<add> nativeEvent: 'canplaythrough',
<add> dispatch(node) {
<add> const e = new Event('canplaythrough', {
<add> bubbles: false,
<add> cancelable: true,
<add> });
<add> node.dispatchEvent(e);
<add> },
<add> });
<add> });
<add>
<add> it('onClose', () => {
<add> testEmulatedBubblingEvent({
<add> type: 'dialog',
<add> reactEvent: 'onClose',
<add> nativeEvent: 'close',
<add> dispatch(node) {
<add> const e = new Event('close', {
<add> bubbles: false,
<add> cancelable: true,
<add> });
<add> node.dispatchEvent(e);
<add> },
<add> });
<add> });
<add>
<add> it('onDurationChange', () => {
<add> testEmulatedBubblingEvent({
<add> type: 'video',
<add> reactEvent: 'onDurationChange',
<add> nativeEvent: 'durationchange',
<add> dispatch(node) {
<add> const e = new Event('durationchange', {
<add> bubbles: false,
<add> cancelable: true,
<add> });
<add> node.dispatchEvent(e);
<add> },
<add> });
<add> });
<add>
<add> it('onEmptied', () => {
<add> testEmulatedBubblingEvent({
<add> type: 'video',
<add> reactEvent: 'onEmptied',
<add> nativeEvent: 'emptied',
<add> dispatch(node) {
<add> const e = new Event('emptied', {
<add> bubbles: false,
<add> cancelable: true,
<add> });
<add> node.dispatchEvent(e);
<add> },
<add> });
<add> });
<add>
<add> it('onEncrypted', () => {
<add> testEmulatedBubblingEvent({
<add> type: 'video',
<add> reactEvent: 'onEncrypted',
<add> nativeEvent: 'encrypted',
<add> dispatch(node) {
<add> const e = new Event('encrypted', {
<add> bubbles: false,
<add> cancelable: true,
<add> });
<add> node.dispatchEvent(e);
<add> },
<add> });
<add> });
<add>
<add> it('onEnded', () => {
<add> testEmulatedBubblingEvent({
<add> type: 'video',
<add> reactEvent: 'onEnded',
<add> nativeEvent: 'ended',
<add> dispatch(node) {
<add> const e = new Event('ended', {
<add> bubbles: false,
<add> cancelable: true,
<add> });
<add> node.dispatchEvent(e);
<ide> },
<ide> });
<ide> });
<ide>
<del> it('onKeyPress', () => {
<del> testNativeBubblingEvent({
<add> it('onError', () => {
<add> testEmulatedBubblingEvent({
<add> type: 'img',
<add> reactEvent: 'onError',
<add> nativeEvent: 'error',
<add> dispatch(node) {
<add> const e = new Event('error', {
<add> bubbles: false,
<add> cancelable: true,
<add> });
<add> node.dispatchEvent(e);
<add> },
<add> });
<add> });
<add>
<add> it('onInvalid', () => {
<add> testEmulatedBubblingEvent({
<ide> type: 'input',
<del> reactEvent: 'onKeyPress',
<del> nativeEvent: 'keypress',
<add> reactEvent: 'onInvalid',
<add> nativeEvent: 'invalid',
<ide> dispatch(node) {
<del> node.dispatchEvent(
<del> new KeyboardEvent('keypress', {
<del> keyCode: 13,
<del> bubbles: true,
<del> cancelable: true,
<del> }),
<del> );
<add> const e = new Event('invalid', {
<add> bubbles: false,
<add> cancelable: true,
<add> });
<add> node.dispatchEvent(e);
<ide> },
<ide> });
<ide> });
<ide>
<del> it('onMouseDown', () => {
<del> testNativeBubblingEvent({
<del> type: 'button',
<del> reactEvent: 'onMouseDown',
<del> nativeEvent: 'mousedown',
<add> it('onLoad', () => {
<add> testEmulatedBubblingEvent({
<add> type: 'img',
<add> reactEvent: 'onLoad',
<add> nativeEvent: 'load',
<ide> dispatch(node) {
<del> node.dispatchEvent(
<del> new MouseEvent('mousedown', {
<del> bubbles: true,
<del> cancelable: true,
<del> }),
<del> );
<add> const e = new Event('load', {
<add> bubbles: false,
<add> cancelable: true,
<add> });
<add> node.dispatchEvent(e);
<ide> },
<ide> });
<ide> });
<ide>
<del> it('onTouchStart', () => {
<del> testNativeBubblingEvent({
<del> type: 'div',
<del> reactEvent: 'onTouchStart',
<del> nativeEvent: 'touchstart',
<add> it('onLoadedData', () => {
<add> testEmulatedBubblingEvent({
<add> type: 'video',
<add> reactEvent: 'onLoadedData',
<add> nativeEvent: 'loadeddata',
<ide> dispatch(node) {
<del> node.dispatchEvent(
<del> new Event('touchstart', {
<del> bubbles: true,
<del> cancelable: true,
<del> }),
<del> );
<add> const e = new Event('loadeddata', {
<add> bubbles: false,
<add> cancelable: true,
<add> });
<add> node.dispatchEvent(e);
<ide> },
<ide> });
<ide> });
<ide>
<del> it('onWheel', () => {
<del> testNativeBubblingEvent({
<del> type: 'div',
<del> reactEvent: 'onWheel',
<del> nativeEvent: 'wheel',
<add> it('onLoadedMetadata', () => {
<add> testEmulatedBubblingEvent({
<add> type: 'video',
<add> reactEvent: 'onLoadedMetadata',
<add> nativeEvent: 'loadedmetadata',
<ide> dispatch(node) {
<del> node.dispatchEvent(
<del> new Event('wheel', {
<del> bubbles: true,
<del> cancelable: true,
<del> }),
<del> );
<add> const e = new Event('loadedmetadata', {
<add> bubbles: false,
<add> cancelable: true,
<add> });
<add> node.dispatchEvent(e);
<ide> },
<ide> });
<ide> });
<ide>
<del> it('onSubmit', () => {
<del> testNativeBubblingEvent({
<del> type: 'form',
<del> reactEvent: 'onSubmit',
<del> nativeEvent: 'submit',
<add> it('onLoadStart', () => {
<add> testEmulatedBubblingEvent({
<add> type: 'video',
<add> reactEvent: 'onLoadStart',
<add> nativeEvent: 'loadstart',
<ide> dispatch(node) {
<del> const e = new Event('submit', {
<del> bubbles: true,
<add> const e = new Event('loadstart', {
<add> bubbles: false,
<ide> cancelable: true,
<ide> });
<ide> node.dispatchEvent(e);
<ide> },
<ide> });
<ide> });
<ide>
<del> it('onReset', () => {
<del> testNativeBubblingEvent({
<del> type: 'form',
<del> reactEvent: 'onReset',
<del> nativeEvent: 'reset',
<add> it('onPause', () => {
<add> testEmulatedBubblingEvent({
<add> type: 'video',
<add> reactEvent: 'onPause',
<add> nativeEvent: 'pause',
<ide> dispatch(node) {
<del> const e = new Event('reset', {
<del> bubbles: true,
<add> const e = new Event('pause', {
<add> bubbles: false,
<ide> cancelable: true,
<ide> });
<ide> node.dispatchEvent(e);
<ide> },
<ide> });
<ide> });
<ide>
<del> it('onFocus', () => {
<del> testNativeBubblingEvent({
<del> type: 'input',
<del> reactEvent: 'onFocus',
<del> nativeEvent: 'focusin',
<add> it('onPlay', () => {
<add> testEmulatedBubblingEvent({
<add> type: 'video',
<add> reactEvent: 'onPlay',
<add> nativeEvent: 'play',
<ide> dispatch(node) {
<del> const e = new Event('focusin', {
<del> bubbles: true,
<add> const e = new Event('play', {
<add> bubbles: false,
<ide> cancelable: true,
<ide> });
<ide> node.dispatchEvent(e);
<ide> },
<ide> });
<ide> });
<ide>
<del> it('onBlur', () => {
<del> testNativeBubblingEvent({
<del> type: 'input',
<del> reactEvent: 'onBlur',
<del> nativeEvent: 'focusout',
<add> it('onPlaying', () => {
<add> testEmulatedBubblingEvent({
<add> type: 'video',
<add> reactEvent: 'onPlaying',
<add> nativeEvent: 'playing',
<ide> dispatch(node) {
<del> const e = new Event('focusout', {
<del> bubbles: true,
<add> const e = new Event('playing', {
<add> bubbles: false,
<ide> cancelable: true,
<ide> });
<ide> node.dispatchEvent(e);
<ide> },
<ide> });
<ide> });
<del> });
<ide>
<del> describe('non-bubbling events that bubble in React', () => {
<del> it('onInvalid', () => {
<add> it('onProgress', () => {
<ide> testEmulatedBubblingEvent({
<del> type: 'input',
<del> reactEvent: 'onInvalid',
<del> nativeEvent: 'invalid',
<add> type: 'video',
<add> reactEvent: 'onProgress',
<add> nativeEvent: 'progress',
<ide> dispatch(node) {
<del> const e = new Event('invalid', {
<add> const e = new Event('progress', {
<ide> bubbles: false,
<ide> cancelable: true,
<ide> });
<ide> describe('ReactDOMEventListener', () => {
<ide> });
<ide> });
<ide>
<del> it('onLoad', () => {
<add> it('onRateChange', () => {
<ide> testEmulatedBubblingEvent({
<del> type: 'img',
<del> reactEvent: 'onLoad',
<del> nativeEvent: 'load',
<add> type: 'video',
<add> reactEvent: 'onRateChange',
<add> nativeEvent: 'ratechange',
<ide> dispatch(node) {
<del> const e = new Event('load', {
<add> const e = new Event('ratechange', {
<ide> bubbles: false,
<ide> cancelable: true,
<ide> });
<ide> describe('ReactDOMEventListener', () => {
<ide> });
<ide> });
<ide>
<del> it('onError', () => {
<add> it('onSeeked', () => {
<ide> testEmulatedBubblingEvent({
<del> type: 'img',
<del> reactEvent: 'onError',
<del> nativeEvent: 'error',
<add> type: 'video',
<add> reactEvent: 'onSeeked',
<add> nativeEvent: 'seeked',
<ide> dispatch(node) {
<del> const e = new Event('error', {
<add> const e = new Event('seeked', {
<ide> bubbles: false,
<ide> cancelable: true,
<ide> });
<ide> describe('ReactDOMEventListener', () => {
<ide> });
<ide> });
<ide>
<del> it('onClose', () => {
<add> it('onSeeking', () => {
<ide> testEmulatedBubblingEvent({
<del> type: 'dialog',
<del> reactEvent: 'onClose',
<del> nativeEvent: 'close',
<add> type: 'video',
<add> reactEvent: 'onSeeking',
<add> nativeEvent: 'seeking',
<ide> dispatch(node) {
<del> const e = new Event('close', {
<add> const e = new Event('seeking', {
<ide> bubbles: false,
<ide> cancelable: true,
<ide> });
<ide> describe('ReactDOMEventListener', () => {
<ide> });
<ide> });
<ide>
<del> it('onCancel', () => {
<add> it('onStalled', () => {
<ide> testEmulatedBubblingEvent({
<del> type: 'dialog',
<del> reactEvent: 'onCancel',
<del> nativeEvent: 'cancel',
<add> type: 'video',
<add> reactEvent: 'onStalled',
<add> nativeEvent: 'stalled',
<ide> dispatch(node) {
<del> const e = new Event('cancel', {
<add> const e = new Event('stalled', {
<ide> bubbles: false,
<ide> cancelable: true,
<ide> });
<ide> describe('ReactDOMEventListener', () => {
<ide> });
<ide> });
<ide>
<del> it('onPlay', () => {
<add> it('onSuspend', () => {
<ide> testEmulatedBubblingEvent({
<ide> type: 'video',
<del> reactEvent: 'onPlay',
<del> nativeEvent: 'play',
<add> reactEvent: 'onSuspend',
<add> nativeEvent: 'suspend',
<ide> dispatch(node) {
<del> const e = new Event('play', {
<add> const e = new Event('suspend', {
<add> bubbles: false,
<add> cancelable: true,
<add> });
<add> node.dispatchEvent(e);
<add> },
<add> });
<add> });
<add>
<add> it('onTimeUpdate', () => {
<add> testEmulatedBubblingEvent({
<add> type: 'video',
<add> reactEvent: 'onTimeUpdate',
<add> nativeEvent: 'timeupdate',
<add> dispatch(node) {
<add> const e = new Event('timeupdate', {
<add> bubbles: false,
<add> cancelable: true,
<add> });
<add> node.dispatchEvent(e);
<add> },
<add> });
<add> });
<add>
<add> it('onToggle', () => {
<add> testEmulatedBubblingEvent({
<add> type: 'details',
<add> reactEvent: 'onToggle',
<add> nativeEvent: 'toggle',
<add> dispatch(node) {
<add> const e = new Event('toggle', {
<add> bubbles: false,
<add> cancelable: true,
<add> });
<add> node.dispatchEvent(e);
<add> },
<add> });
<add> });
<add>
<add> it('onVolumeChange', () => {
<add> testEmulatedBubblingEvent({
<add> type: 'video',
<add> reactEvent: 'onVolumeChange',
<add> nativeEvent: 'volumechange',
<add> dispatch(node) {
<add> const e = new Event('volumechange', {
<add> bubbles: false,
<add> cancelable: true,
<add> });
<add> node.dispatchEvent(e);
<add> },
<add> });
<add> });
<add>
<add> it('onWaiting', () => {
<add> testEmulatedBubblingEvent({
<add> type: 'video',
<add> reactEvent: 'onWaiting',
<add> nativeEvent: 'waiting',
<add> dispatch(node) {
<add> const e = new Event('waiting', {
<ide> bubbles: false,
<ide> cancelable: true,
<ide> });
<ide> describe('ReactDOMEventListener', () => {
<ide> });
<ide> });
<ide>
<add> // The tests for these events are currently very limited
<add> // because they are fully synthetic, and so they don't
<add> // work very well across different roots. For now, we'll
<add> // just document the current state in these tests.
<add> describe('enter/leave events', () => {
<add> it('onMouseEnter and onMouseLeave', () => {
<add> const log = [];
<add> const targetRef = React.createRef();
<add> render(
<add> <Fixture
<add> type="div"
<add> targetRef={targetRef}
<add> targetProps={{
<add> onMouseEnter: e => {
<add> log.push('---- inner enter');
<add> },
<add> onMouseLeave: e => {
<add> log.push('---- inner leave');
<add> },
<add> }}
<add> parentProps={{
<add> onMouseEnter: e => {
<add> log.push('--- inner parent enter');
<add> },
<add> onMouseLeave: e => {
<add> log.push('--- inner parent leave');
<add> },
<add> }}
<add> outerProps={{
<add> onMouseEnter: e => {
<add> log.push('-- outer enter');
<add> },
<add> onMouseLeave: e => {
<add> log.push('-- outer leave');
<add> },
<add> }}
<add> outerParentProps={{
<add> onMouseEnter: e => {
<add> log.push('- outer parent enter');
<add> },
<add> onMouseLeave: e => {
<add> log.push('- outer parent leave');
<add> },
<add> }}
<add> />,
<add> );
<add> expect(log.length).toBe(0);
<add> targetRef.current.dispatchEvent(
<add> new MouseEvent('mouseover', {
<add> bubbles: true,
<add> cancelable: true,
<add> relatedTarget: null,
<add> }),
<add> );
<add> // This order isn't ideal because each root
<add> // has a separate traversal.
<add> expect(log).toEqual(unindent`
<add> --- inner parent enter
<add> ---- inner enter
<add> - outer parent enter
<add> -- outer enter
<add> `);
<add> log.length = 0;
<add> targetRef.current.dispatchEvent(
<add> new MouseEvent('mouseout', {
<add> bubbles: true,
<add> cancelable: true,
<add> relatedTarget: document.body,
<add> }),
<add> );
<add> expect(log).toEqual(unindent`
<add> ---- inner leave
<add> --- inner parent leave
<add> -- outer leave
<add> - outer parent leave
<add> `);
<add> });
<add>
<add> it('onPointerEnter and onPointerLeave', () => {
<add> const log = [];
<add> const targetRef = React.createRef();
<add> render(
<add> <Fixture
<add> type="div"
<add> targetRef={targetRef}
<add> targetProps={{
<add> onPointerEnter: e => {
<add> log.push('---- inner enter');
<add> },
<add> onPointerLeave: e => {
<add> log.push('---- inner leave');
<add> },
<add> }}
<add> parentProps={{
<add> onPointerEnter: e => {
<add> log.push('--- inner parent enter');
<add> },
<add> onPointerLeave: e => {
<add> log.push('--- inner parent leave');
<add> },
<add> }}
<add> outerProps={{
<add> onPointerEnter: e => {
<add> log.push('-- outer enter');
<add> },
<add> onPointerLeave: e => {
<add> log.push('-- outer leave');
<add> },
<add> }}
<add> outerParentProps={{
<add> onPointerEnter: e => {
<add> log.push('- outer parent enter');
<add> },
<add> onPointerLeave: e => {
<add> log.push('- outer parent leave');
<add> },
<add> }}
<add> />,
<add> );
<add> expect(log.length).toBe(0);
<add> targetRef.current.dispatchEvent(
<add> new Event('pointerover', {
<add> bubbles: true,
<add> cancelable: true,
<add> relatedTarget: null,
<add> }),
<add> );
<add> // This order isn't ideal because each root
<add> // has a separate traversal.
<add> expect(log).toEqual(unindent`
<add> --- inner parent enter
<add> ---- inner enter
<add> - outer parent enter
<add> -- outer enter
<add> `);
<add> log.length = 0;
<add> targetRef.current.dispatchEvent(
<add> new Event('pointerout', {
<add> bubbles: true,
<add> cancelable: true,
<add> relatedTarget: document.body,
<add> }),
<add> );
<add> expect(log).toEqual(unindent`
<add> ---- inner leave
<add> --- inner parent leave
<add> -- outer leave
<add> - outer parent leave
<add> `);
<add> });
<add> });
<add>
<add> const setUntrackedValue = Object.getOwnPropertyDescriptor(
<add> HTMLInputElement.prototype,
<add> 'value',
<add> ).set;
<add>
<add> // The tests for these events are currently very limited
<add> // because they are fully synthetic, and so they don't
<add> // work very well across different roots. For now, we'll
<add> // just document the current state in these tests.
<add> describe('polyfilled events', () => {
<add> it('onBeforeInput', () => {
<add> const log = [];
<add> const targetRef = React.createRef();
<add> render(
<add> <Fixture
<add> type="input"
<add> targetRef={targetRef}
<add> targetProps={{
<add> onBeforeInput: e => {
<add> log.push('---- inner');
<add> },
<add> onBeforeInputCapture: e => {
<add> log.push('---- inner capture');
<add> },
<add> }}
<add> parentProps={{
<add> onBeforeInput: e => {
<add> log.push('--- inner parent');
<add> },
<add> onBeforeInputCapture: e => {
<add> log.push('--- inner parent capture');
<add> },
<add> }}
<add> outerProps={{
<add> onBeforeInput: e => {
<add> log.push('-- outer');
<add> },
<add> onBeforeInputCapture: e => {
<add> log.push('-- outer capture');
<add> },
<add> }}
<add> outerParentProps={{
<add> onBeforeInput: e => {
<add> log.push('- outer parent');
<add> },
<add> onBeforeInputCapture: e => {
<add> log.push('- outer parent capture');
<add> },
<add> }}
<add> />,
<add> );
<add> expect(log.length).toBe(0);
<add> const e = new Event('textInput', {
<add> bubbles: true,
<add> });
<add> e.data = 'abcd';
<add> targetRef.current.dispatchEvent(e);
<add> // Since this is a polyfilled event,
<add> // the capture and bubble phases are
<add> // emulated, and don't align between roots.
<add> expect(log).toEqual(unindent`
<add> --- inner parent capture
<add> ---- inner capture
<add> ---- inner
<add> --- inner parent
<add> - outer parent capture
<add> -- outer capture
<add> -- outer
<add> - outer parent
<add> `);
<add> });
<add>
<add> it('onChange', () => {
<add> const log = [];
<add> const targetRef = React.createRef();
<add> render(
<add> <Fixture
<add> type="input"
<add> targetRef={targetRef}
<add> targetProps={{
<add> onChange: e => {
<add> log.push('---- inner');
<add> },
<add> onChangeCapture: e => {
<add> log.push('---- inner capture');
<add> },
<add> }}
<add> parentProps={{
<add> onChange: e => {
<add> log.push('--- inner parent');
<add> },
<add> onChangeCapture: e => {
<add> log.push('--- inner parent capture');
<add> },
<add> }}
<add> outerProps={{
<add> onChange: e => {
<add> log.push('-- outer');
<add> },
<add> onChangeCapture: e => {
<add> log.push('-- outer capture');
<add> },
<add> }}
<add> outerParentProps={{
<add> onChange: e => {
<add> log.push('- outer parent');
<add> },
<add> onChangeCapture: e => {
<add> log.push('- outer parent capture');
<add> },
<add> }}
<add> />,
<add> );
<add> expect(log.length).toBe(0);
<add> setUntrackedValue.call(targetRef.current, 'hello');
<add> targetRef.current.dispatchEvent(
<add> new Event('input', {
<add> bubbles: true,
<add> }),
<add> );
<add> // The outer React doesn't receive the event at all
<add> // because it is not responsible for this input.
<add> expect(log).toEqual(unindent`
<add> --- inner parent capture
<add> ---- inner capture
<add> ---- inner
<add> --- inner parent
<add> `);
<add> });
<add>
<add> it('onCompositionStart', () => {
<add> const log = [];
<add> const targetRef = React.createRef();
<add> render(
<add> <Fixture
<add> type="input"
<add> targetRef={targetRef}
<add> targetProps={{
<add> onCompositionStart: e => {
<add> log.push('---- inner');
<add> },
<add> onCompositionStartCapture: e => {
<add> log.push('---- inner capture');
<add> },
<add> }}
<add> parentProps={{
<add> onCompositionStart: e => {
<add> log.push('--- inner parent');
<add> },
<add> onCompositionStartCapture: e => {
<add> log.push('--- inner parent capture');
<add> },
<add> }}
<add> outerProps={{
<add> onCompositionStart: e => {
<add> log.push('-- outer');
<add> },
<add> onCompositionStartCapture: e => {
<add> log.push('-- outer capture');
<add> },
<add> }}
<add> outerParentProps={{
<add> onCompositionStart: e => {
<add> log.push('- outer parent');
<add> },
<add> onCompositionStartCapture: e => {
<add> log.push('- outer parent capture');
<add> },
<add> }}
<add> />,
<add> );
<add> expect(log.length).toBe(0);
<add> const e = new Event('compositionstart', {
<add> bubbles: true,
<add> });
<add> targetRef.current.dispatchEvent(e);
<add> // Since this is a polyfilled event,
<add> // the capture and bubble phases are
<add> // emulated, and don't align between roots.
<add> expect(log).toEqual(unindent`
<add> --- inner parent capture
<add> ---- inner capture
<add> ---- inner
<add> --- inner parent
<add> - outer parent capture
<add> -- outer capture
<add> -- outer
<add> - outer parent
<add> `);
<add> });
<add>
<add> it('onCompositionEnd', () => {
<add> const log = [];
<add> const targetRef = React.createRef();
<add> render(
<add> <Fixture
<add> type="input"
<add> targetRef={targetRef}
<add> targetProps={{
<add> onCompositionEnd: e => {
<add> log.push('---- inner');
<add> },
<add> onCompositionEndCapture: e => {
<add> log.push('---- inner capture');
<add> },
<add> }}
<add> parentProps={{
<add> onCompositionEnd: e => {
<add> log.push('--- inner parent');
<add> },
<add> onCompositionEndCapture: e => {
<add> log.push('--- inner parent capture');
<add> },
<add> }}
<add> outerProps={{
<add> onCompositionEnd: e => {
<add> log.push('-- outer');
<add> },
<add> onCompositionEndCapture: e => {
<add> log.push('-- outer capture');
<add> },
<add> }}
<add> outerParentProps={{
<add> onCompositionEnd: e => {
<add> log.push('- outer parent');
<add> },
<add> onCompositionEndCapture: e => {
<add> log.push('- outer parent capture');
<add> },
<add> }}
<add> />,
<add> );
<add> expect(log.length).toBe(0);
<add> const e = new Event('compositionend', {
<add> bubbles: true,
<add> });
<add> targetRef.current.dispatchEvent(e);
<add> // Since this is a polyfilled event,
<add> // the capture and bubble phases are
<add> // emulated, and don't align between roots.
<add> expect(log).toEqual(unindent`
<add> --- inner parent capture
<add> ---- inner capture
<add> ---- inner
<add> --- inner parent
<add> - outer parent capture
<add> -- outer capture
<add> -- outer
<add> - outer parent
<add> `);
<add> });
<add>
<add> it('onCompositionUpdate', () => {
<add> const log = [];
<add> const targetRef = React.createRef();
<add> render(
<add> <Fixture
<add> type="input"
<add> targetRef={targetRef}
<add> targetProps={{
<add> onCompositionUpdate: e => {
<add> log.push('---- inner');
<add> },
<add> onCompositionUpdateCapture: e => {
<add> log.push('---- inner capture');
<add> },
<add> }}
<add> parentProps={{
<add> onCompositionUpdate: e => {
<add> log.push('--- inner parent');
<add> },
<add> onCompositionUpdateCapture: e => {
<add> log.push('--- inner parent capture');
<add> },
<add> }}
<add> outerProps={{
<add> onCompositionUpdate: e => {
<add> log.push('-- outer');
<add> },
<add> onCompositionUpdateCapture: e => {
<add> log.push('-- outer capture');
<add> },
<add> }}
<add> outerParentProps={{
<add> onCompositionUpdate: e => {
<add> log.push('- outer parent');
<add> },
<add> onCompositionUpdateCapture: e => {
<add> log.push('- outer parent capture');
<add> },
<add> }}
<add> />,
<add> );
<add> expect(log.length).toBe(0);
<add> const e = new Event('compositionupdate', {
<add> bubbles: true,
<add> });
<add> targetRef.current.dispatchEvent(e);
<add> // Since this is a polyfilled event,
<add> // the capture and bubble phases are
<add> // emulated, and don't align between roots.
<add> expect(log).toEqual(unindent`
<add> --- inner parent capture
<add> ---- inner capture
<add> ---- inner
<add> --- inner parent
<add> - outer parent capture
<add> -- outer capture
<add> -- outer
<add> - outer parent
<add> `);
<add> });
<add>
<add> it('onSelect', () => {
<add> const log = [];
<add> const targetRef = React.createRef();
<add> render(
<add> <Fixture
<add> type="input"
<add> targetRef={targetRef}
<add> targetProps={{
<add> onSelect: e => {
<add> log.push('---- inner');
<add> },
<add> onSelectCapture: e => {
<add> log.push('---- inner capture');
<add> },
<add> }}
<add> parentProps={{
<add> onSelect: e => {
<add> log.push('--- inner parent');
<add> },
<add> onSelectCapture: e => {
<add> log.push('--- inner parent capture');
<add> },
<add> }}
<add> outerProps={{
<add> onSelect: e => {
<add> log.push('-- outer');
<add> },
<add> onSelectCapture: e => {
<add> log.push('-- outer capture');
<add> },
<add> }}
<add> outerParentProps={{
<add> onSelect: e => {
<add> log.push('- outer parent');
<add> },
<add> onSelectCapture: e => {
<add> log.push('- outer parent capture');
<add> },
<add> }}
<add> />,
<add> );
<add> expect(log.length).toBe(0);
<add> targetRef.current.focus();
<add> targetRef.current.dispatchEvent(
<add> new Event('keydown', {
<add> bubbles: true,
<add> }),
<add> );
<add> // The outer React doesn't receive the event at all
<add> // because it is not responsible for this input.
<add> expect(log).toEqual(unindent`
<add> --- inner parent capture
<add> ---- inner capture
<add> ---- inner
<add> --- inner parent
<add> `);
<add> });
<add> });
<add>
<ide> // Events that bubble in React and in the browser.
<ide> // React delegates them to the root.
<ide> function testNativeBubblingEvent(config) { | 1 |
Ruby | Ruby | fix exception in raw_params method | d7516f471a6f03f86e378d54dcebef8ce860ff26 | <ide><path>actionpack/lib/action_controller/metal/http_authentication.rb
<ide> def rewrite_param_values(array_params)
<ide> def raw_params(auth)
<ide> _raw_params = auth.sub(TOKEN_REGEX, "").split(/\s*#{AUTHN_PAIR_DELIMITERS}\s*/)
<ide>
<del> if !_raw_params.first.start_with?(TOKEN_KEY)
<add> if !_raw_params.first&.start_with?(TOKEN_KEY)
<ide> _raw_params[0] = "#{TOKEN_KEY}#{_raw_params.first}"
<ide> end
<ide>
<ide><path>actionpack/test/controller/http_token_authentication_test.rb
<ide> def authenticate_long_credentials
<ide> assert_equal(expected, actual)
<ide> end
<ide>
<del> test "token_and_options returns correct token with nounce option" do
<add> test "token_and_options returns correct token with nonce option" do
<ide> token = "rcHu+HzSFw89Ypyhn/896A="
<ide> nonce_hash = { nonce: "123abc" }
<ide> actual = ActionController::HttpAuthentication::Token.token_and_options(sample_request(token, nonce_hash))
<ide> def authenticate_long_credentials
<ide> assert_equal(expected, actual)
<ide> end
<ide>
<add> test "raw_params returns a tuple of key value pair strings when auth does not contain a token key" do
<add> auth = sample_request_without_token_key("rcHu+HzSFw89Ypyhn/896A=").authorization.to_s
<add> actual = ActionController::HttpAuthentication::Token.raw_params(auth)
<add> expected = ["token=rcHu+HzSFw89Ypyhn/896A="]
<add> assert_equal(expected, actual)
<add> end
<add>
<add> test "raw_params returns a tuple of key strings when auth does not contain a token key and value" do
<add> auth = sample_request_without_token_key(nil).authorization.to_s
<add> actual = ActionController::HttpAuthentication::Token.raw_params(auth)
<add> expected = ["token="]
<add> assert_equal(expected, actual)
<add> end
<add>
<ide> test "token_and_options returns right token when token key is not specified in header" do
<ide> token = "rcHu+HzSFw89Ypyhn/896A="
<ide> | 2 |
Ruby | Ruby | use better assertion methods for testing | b4629528866446aa59f663a1162edbdacee85600 | <ide><path>actionmailer/test/base_test.rb
<ide> def give_a_greeting
<ide>
<ide> # Class level API with method missing
<ide> test "should respond to action methods" do
<del> assert BaseMailer.respond_to?(:welcome)
<del> assert BaseMailer.respond_to?(:implicit_multipart)
<add> assert_respond_to BaseMailer, :welcome
<add> assert_respond_to BaseMailer, :implicit_multipart
<ide> assert !BaseMailer.respond_to?(:mail)
<ide> assert !BaseMailer.respond_to?(:headers)
<ide> end
<ide><path>actionmailer/test/old_base/asset_host_test.rb
<ide> def teardown
<ide>
<ide> def test_asset_host_as_string
<ide> mail = AssetHostMailer.email_with_asset
<del> assert_equal "<img alt=\"Somelogo\" src=\"http://www.example.com/images/somelogo.png\" />", mail.body.to_s.strip
<add> assert_equal %Q{<img alt="Somelogo" src="http://www.example.com/images/somelogo.png" />}, mail.body.to_s.strip
<ide> end
<ide>
<ide> def test_asset_host_as_one_arguement_proc
<ide> def test_asset_host_as_one_arguement_proc
<ide> end
<ide> }
<ide> mail = AssetHostMailer.email_with_asset
<del> assert_equal "<img alt=\"Somelogo\" src=\"http://images.example.com/images/somelogo.png\" />", mail.body.to_s.strip
<add> assert_equal %Q{<img alt="Somelogo" src="http://images.example.com/images/somelogo.png" />}, mail.body.to_s.strip
<ide> end
<ide>
<ide> def test_asset_host_as_two_arguement_proc
<ide> def test_asset_host_as_two_arguement_proc
<ide> }
<ide> mail = nil
<ide> assert_nothing_raised { mail = AssetHostMailer.email_with_asset }
<del> assert_equal "<img alt=\"Somelogo\" src=\"http://www.example.com/images/somelogo.png\" />", mail.body.to_s.strip
<add> assert_equal %Q{<img alt="Somelogo" src="http://www.example.com/images/somelogo.png" />}, mail.body.to_s.strip
<ide> end
<del>end
<ide>\ No newline at end of file
<add>end
<ide><path>actionmailer/test/old_base/mail_render_test.rb
<ide> def test_file_template
<ide>
<ide> def test_rxml_template
<ide> mail = RenderMailer.rxml_template.deliver
<del> assert_equal "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<test/>", mail.body.to_s.strip
<add> assert_equal %(<?xml version="1.0" encoding="UTF-8"?>\n<test/>), mail.body.to_s.strip
<ide> end
<ide>
<ide> def test_included_subtemplate
<ide><path>actionmailer/test/old_base/mail_service_test.rb
<ide> def headers_with_nonalpha_chars(recipient)
<ide> from "One: Two <[email protected]>"
<ide> cc "Three: Four <[email protected]>"
<ide> bcc "Five: Six <[email protected]>"
<del> body "testing"
<add> body "testing"
<ide> end
<ide>
<ide> def custom_content_type_attributes
<ide> recipients "[email protected]"
<ide> subject "custom content types"
<ide> from "[email protected]"
<ide> content_type "text/plain; format=flowed"
<del> body "testing"
<add> body "testing"
<ide> end
<ide>
<ide> def return_path
<ide> recipients "[email protected]"
<ide> subject "return path test"
<ide> from "[email protected]"
<ide> headers["return-path"] = "[email protected]"
<del> body "testing"
<add> body "testing"
<ide> end
<ide>
<ide> def subject_with_i18n(recipient)
<ide> def test_signed_up
<ide> end
<ide>
<ide> def test_custom_template
<del> expected = new_mail
<add> expected = new_mail
<ide> expected.to = @recipient
<ide> expected.subject = "[Signed up] Welcome #{@recipient}"
<ide> expected.body = "Hello there, \n\nMr. #{@recipient}"
<ide> def test_custom_templating_extension
<ide> assert ActionView::Template.template_handler_extensions.include?("haml"), "haml extension was not registered"
<ide>
<ide> # N.b., custom_templating_extension.text.plain.haml is expected to be in fixtures/test_mailer directory
<del> expected = new_mail
<add> expected = new_mail
<ide> expected.to = @recipient
<ide> expected.subject = "[Signed up] Welcome #{@recipient}"
<ide> expected.body = "Hello there, \n\nMr. #{@recipient}"
<ide> def test_custom_templating_extension
<ide> end
<ide>
<ide> def test_cancelled_account
<del> expected = new_mail
<add> expected = new_mail
<ide> expected.to = @recipient
<ide> expected.subject = "[Cancelled] Goodbye #{@recipient}"
<ide> expected.body = "Goodbye, Mr. #{@recipient}"
<ide> def test_cancelled_account
<ide> end
<ide>
<ide> def test_cc_bcc
<del> expected = new_mail
<add> expected = new_mail
<ide> expected.to = @recipient
<ide> expected.subject = "testing bcc/cc"
<ide> expected.body = "Nothing to see here."
<ide> def test_iso_charset
<ide>
<ide> def test_unencoded_subject
<ide> TestMailer.delivery_method = :test
<del> expected = new_mail
<add> expected = new_mail
<ide> expected.to = @recipient
<ide> expected.subject = "testing unencoded subject"
<ide> expected.body = "Nothing to see here."
<ide> def teardown
<ide> end
<ide>
<ide> def test_should_respond_to_new
<del> assert RespondToMailer.respond_to?(:new)
<add> assert_respond_to RespondToMailer, :new
<ide> end
<ide>
<ide> def test_should_respond_to_create_with_template_suffix
<del> assert RespondToMailer.respond_to?(:create_any_old_template)
<add> assert_respond_to RespondToMailer, :create_any_old_template
<ide> end
<ide>
<ide> def test_should_respond_to_deliver_with_template_suffix
<del> assert RespondToMailer.respond_to?(:deliver_any_old_template)
<add> assert_respond_to RespondToMailer, :deliver_any_old_template
<ide> end
<ide>
<ide> def test_should_not_respond_to_new_with_template_suffix
<ide><path>actionmailer/test/test_helper_test.rb
<ide> def test_setup_sets_right_action_mailer_options
<ide> end
<ide>
<ide> def test_setup_creates_the_expected_mailer
<del> assert @expected.is_a?(Mail::Message)
<add> assert_kind_of Mail::Message, @expected
<ide> assert_equal "1.0", @expected.mime_version
<ide> assert_equal "text/plain", @expected.mime_type
<ide> end
<ide> def setup
<ide> end
<ide>
<ide> def test_setup_shouldnt_conflict_with_mailer_setup
<del> assert @expected.is_a?(Mail::Message)
<add> assert_kind_of Mail::Message, @expected
<ide> assert_equal 'a value', @test_var
<ide> end
<ide> end
<ide><path>actionpack/test/controller/filters_test.rb
<ide> def test_running_anomolous_yet_valid_condition_filters
<ide> assert assigns["ran_proc_filter2"]
<ide>
<ide> test_process(AnomolousYetValidConditionController, "show_without_filter")
<del> assert_equal nil, assigns["ran_filter"]
<add> assert_nil assigns["ran_filter"]
<ide> assert !assigns["ran_class_filter"]
<ide> assert !assigns["ran_proc_filter1"]
<ide> assert !assigns["ran_proc_filter2"]
<ide> def test_running_collection_condition_filters
<ide> test_process(ConditionalCollectionFilterController)
<ide> assert_equal %w( ensure_login ), assigns["ran_filter"]
<ide> test_process(ConditionalCollectionFilterController, "show_without_filter")
<del> assert_equal nil, assigns["ran_filter"]
<add> assert_nil assigns["ran_filter"]
<ide> test_process(ConditionalCollectionFilterController, "another_action")
<del> assert_equal nil, assigns["ran_filter"]
<add> assert_nil assigns["ran_filter"]
<ide> end
<ide>
<ide> def test_running_only_condition_filters
<ide> test_process(OnlyConditionSymController)
<ide> assert_equal %w( ensure_login ), assigns["ran_filter"]
<ide> test_process(OnlyConditionSymController, "show_without_filter")
<del> assert_equal nil, assigns["ran_filter"]
<add> assert_nil assigns["ran_filter"]
<ide>
<ide> test_process(OnlyConditionProcController)
<ide> assert assigns["ran_proc_filter"]
<ide> def test_running_except_condition_filters
<ide> test_process(ExceptConditionSymController)
<ide> assert_equal %w( ensure_login ), assigns["ran_filter"]
<ide> test_process(ExceptConditionSymController, "show_without_filter")
<del> assert_equal nil, assigns["ran_filter"]
<add> assert_nil assigns["ran_filter"]
<ide>
<ide> test_process(ExceptConditionProcController)
<ide> assert assigns["ran_proc_filter"]
<ide> def test_running_before_and_after_condition_filters
<ide> test_process(BeforeAndAfterConditionController)
<ide> assert_equal %w( ensure_login clean_up_tmp), assigns["ran_filter"]
<ide> test_process(BeforeAndAfterConditionController, "show_without_filter")
<del> assert_equal nil, assigns["ran_filter"]
<add> assert_nil assigns["ran_filter"]
<ide> end
<ide>
<ide> def test_around_filter
<ide> def test_condition_skipping_of_filters_when_siblings_also_have_conditions
<ide>
<ide> def test_changing_the_requirements
<ide> test_process(ChangingTheRequirementsController, "go_wild")
<del> assert_equal nil, assigns['ran_filter']
<add> assert_nil assigns['ran_filter']
<ide> end
<ide>
<ide> def test_a_rescuing_around_filter
<ide><path>actionpack/test/controller/new_base/bare_metal_test.rb
<ide> class BareTest < ActiveSupport::TestCase
<ide> string << part
<ide> end
<ide>
<del> assert headers.is_a?(Hash), "Headers must be a Hash"
<add> assert_kind_of Hash, headers, "Headers must be a Hash"
<ide> assert headers["Content-Type"], "Content-Type must exist"
<ide>
<ide> assert_equal "Hello world", string
<ide> end
<ide> end
<del>end
<ide>\ No newline at end of file
<add>end
<ide><path>activemodel/test/cases/attribute_methods_test.rb
<ide> class AttributeMethodsTest < ActiveModel::TestCase
<ide> ModelWithAttributes.define_attribute_methods([:foo])
<ide>
<ide> assert ModelWithAttributes.attribute_methods_generated?
<del> assert ModelWithAttributes.new.respond_to?(:foo)
<add> assert_respond_to ModelWithAttributes.new, :foo
<ide> assert_equal "value of foo", ModelWithAttributes.new.foo
<ide> end
<ide>
<ide><path>activemodel/test/cases/callbacks_test.rb
<ide> def create
<ide> test "only selects which types of callbacks should be created" do
<ide> assert !ModelCallbacks.respond_to?(:before_initialize)
<ide> assert !ModelCallbacks.respond_to?(:around_initialize)
<del> assert ModelCallbacks.respond_to?(:after_initialize)
<add> assert_respond_to ModelCallbacks, :after_initialize
<ide> end
<ide> end
<ide><path>activemodel/test/cases/dirty_test.rb
<ide> def name=(val)
<ide> test "changes accessible through both strings and symbols" do
<ide> model = DirtyModel.new
<ide> model.name = "David"
<del> assert !model.changes[:name].nil?
<del> assert !model.changes['name'].nil?
<add> assert_not_nil model.changes[:name]
<add> assert_not_nil model.changes['name']
<ide> end
<ide>
<ide> end
<ide><path>activemodel/test/cases/serializeration/xml_serialization_test.rb
<ide> def setup
<ide>
<ide> test "should allow skipped types" do
<ide> @xml = @contact.to_xml :skip_types => true
<del> assert %r{<age>25</age>}.match(@xml)
<add> assert_match %r{<age>25</age>}, @xml
<ide> end
<ide>
<ide> test "should include yielded additions" do
<ide><path>activerecord/test/cases/aggregations_test.rb
<ide> def test_reloaded_instance_refreshes_aggregations
<ide> end
<ide>
<ide> def test_gps_equality
<del> assert GpsLocation.new('39x110') == GpsLocation.new('39x110')
<add> assert_equal GpsLocation.new('39x110'), GpsLocation.new('39x110')
<ide> end
<ide>
<ide> def test_gps_inequality
<del> assert GpsLocation.new('39x110') != GpsLocation.new('39x111')
<add> assert_not_equal GpsLocation.new('39x110'), GpsLocation.new('39x111')
<ide> end
<ide>
<ide> def test_allow_nil_gps_is_nil
<del> assert_equal nil, customers(:zaphod).gps_location
<add> assert_nil customers(:zaphod).gps_location
<ide> end
<ide>
<ide> def test_allow_nil_gps_set_to_nil
<ide> customers(:david).gps_location = nil
<ide> customers(:david).save
<ide> customers(:david).reload
<del> assert_equal nil, customers(:david).gps_location
<add> assert_nil customers(:david).gps_location
<ide> end
<ide>
<ide> def test_allow_nil_set_address_attributes_to_nil
<ide> customers(:zaphod).address = nil
<del> assert_equal nil, customers(:zaphod).attributes[:address_street]
<del> assert_equal nil, customers(:zaphod).attributes[:address_city]
<del> assert_equal nil, customers(:zaphod).attributes[:address_country]
<add> assert_nil customers(:zaphod).attributes[:address_street]
<add> assert_nil customers(:zaphod).attributes[:address_city]
<add> assert_nil customers(:zaphod).attributes[:address_country]
<ide> end
<ide>
<ide> def test_allow_nil_address_set_to_nil
<ide> customers(:zaphod).address = nil
<ide> customers(:zaphod).save
<ide> customers(:zaphod).reload
<del> assert_equal nil, customers(:zaphod).address
<add> assert_nil customers(:zaphod).address
<ide> end
<ide>
<ide> def test_nil_raises_error_when_allow_nil_is_false
<ide> def test_allow_nil_address_loaded_when_only_some_attributes_are_nil
<ide>
<ide> def test_nil_assignment_results_in_nil
<ide> customers(:david).gps_location = GpsLocation.new('39x111')
<del> assert_not_equal nil, customers(:david).gps_location
<add> assert_not_nil customers(:david).gps_location
<ide> customers(:david).gps_location = nil
<del> assert_equal nil, customers(:david).gps_location
<add> assert_nil customers(:david).gps_location
<ide> end
<ide>
<ide> def test_custom_constructor
<ide><path>activerecord/test/cases/associations/belongs_to_associations_test.rb
<ide> def test_polymorphic_assignment_updates_foreign_id_field_for_new_and_saved_recor
<ide> assert_equal saved_member.id, sponsor.sponsorable_id
<ide>
<ide> sponsor.sponsorable = new_member
<del> assert_equal nil, sponsor.sponsorable_id
<add> assert_nil sponsor.sponsorable_id
<ide> end
<ide>
<ide> def test_polymorphic_assignment_with_primary_key_updates_foreign_id_field_for_new_and_saved_records
<ide> def test_polymorphic_assignment_with_primary_key_updates_foreign_id_field_for_ne
<ide> assert_equal saved_writer.name, essay.writer_id
<ide>
<ide> essay.writer = new_writer
<del> assert_equal nil, essay.writer_id
<add> assert_nil essay.writer_id
<ide> end
<ide>
<ide> def test_belongs_to_proxy_should_not_respond_to_private_methods
<ide><path>activerecord/test/cases/associations/eager_load_includes_full_sti_class_test.rb
<ide> def test_class_names
<ide>
<ide> ActiveRecord::Base.store_full_sti_class = true
<ide> post = Namespaced::Post.find_by_title( 'Great stuff', :include => :tagging )
<del> assert_equal 'Tagging', post.tagging.class.name
<add> assert_instance_of Tagging, post.tagging
<ide> ensure
<ide> ActiveRecord::Base.store_full_sti_class = old
<ide> end
<ide><path>activerecord/test/cases/associations/eager_test.rb
<ide> def test_finding_with_includes_on_has_many_association_with_same_include_include
<ide> author = assert_queries(3) { Author.find(author_id, :include => {:posts_with_comments => :comments}) } # find the author, then find the posts, then find the comments
<ide> author.posts_with_comments.each do |post_with_comments|
<ide> assert_equal post_with_comments.comments.length, post_with_comments.comments.count
<del> assert_equal nil, post_with_comments.comments.uniq!
<add> assert_nil post_with_comments.comments.uniq!
<ide> end
<ide> end
<ide>
<ide><path>activerecord/test/cases/associations/has_many_associations_test.rb
<ide> def test_belongs_to_sanity
<ide> c = Client.new
<ide> assert_nil c.firm
<ide>
<del> if c.firm
<del> assert false, "belongs_to failed if check"
<del> end
<del>
<del> unless c.firm
<del> else
<del> assert false, "belongs_to failed unless check"
<del> end
<add> flunk "belongs_to failed if check" if c.firm
<ide> end
<ide>
<ide> def test_find_ids
<ide> def test_clearing_an_exclusively_dependent_association_collection
<ide> assert_equal [], Client.destroyed_client_ids[firm.id]
<ide>
<ide> # Should be destroyed since the association is exclusively dependent.
<del> assert Client.find_by_id(client_id).nil?
<add> assert_nil Client.find_by_id(client_id)
<ide> end
<ide>
<ide> def test_dependent_association_respects_optional_conditions_on_delete
<ide> def test_delete_all_association_with_primary_key_deletes_correct_records
<ide> old_record = firm.clients_using_primary_key_with_delete_all.first
<ide> firm = Firm.find(:first)
<ide> firm.destroy
<del> assert Client.find_by_id(old_record.id).nil?
<add> assert_nil Client.find_by_id(old_record.id)
<ide> end
<ide>
<ide> def test_creation_respects_hash_condition
<ide><path>activerecord/test/cases/associations/has_many_through_associations_test.rb
<ide> def test_associate_new_by_building
<ide> assert_queries(1) { posts(:thinking) }
<ide>
<ide> assert_queries(0) do
<del> posts(:thinking).people.build(:first_name=>"Bob")
<del> posts(:thinking).people.new(:first_name=>"Ted")
<add> posts(:thinking).people.build(:first_name => "Bob")
<add> posts(:thinking).people.new(:first_name => "Ted")
<ide> end
<ide>
<ide> # Should only need to load the association once
<ide><path>activerecord/test/cases/associations/has_one_associations_test.rb
<ide> def test_dependence
<ide> num_accounts = Account.count
<ide>
<ide> firm = Firm.find(1)
<del> assert !firm.account.nil?
<add> assert_not_nil firm.account
<ide> account_id = firm.account.id
<ide> assert_equal [], Account.destroyed_account_ids[firm.id]
<ide>
<ide> def test_exclusive_dependence
<ide> num_accounts = Account.count
<ide>
<ide> firm = ExclusivelyDependentFirm.find(9)
<del> assert !firm.account.nil?
<add> assert_not_nil firm.account
<ide> account_id = firm.account.id
<ide> assert_equal [], Account.destroyed_account_ids[firm.id]
<ide>
<ide> def test_dependence_with_restrict
<ide> firm = RestrictedFirm.new(:name => 'restrict')
<ide> firm.save!
<ide> account = firm.create_account(:credit_limit => 10)
<del> assert !firm.account.nil?
<add> assert_not_nil firm.account
<ide> assert_raise(ActiveRecord::DeleteRestrictionError) { firm.destroy }
<ide> end
<ide>
<ide> def test_create_before_save
<ide> def test_dependence_with_missing_association
<ide> Account.destroy_all
<ide> firm = Firm.find(1)
<del> assert firm.account.nil?
<add> assert_nil firm.account
<ide> firm.destroy
<ide> end
<ide>
<ide><path>activerecord/test/cases/associations/inverse_associations_test.rb
<ide> def test_should_allow_for_inverse_of_options_in_associations
<ide>
<ide> def test_should_be_able_to_ask_a_reflection_if_it_has_an_inverse
<ide> has_one_with_inverse_ref = Man.reflect_on_association(:face)
<del> assert has_one_with_inverse_ref.respond_to?(:has_inverse?)
<add> assert_respond_to has_one_with_inverse_ref, :has_inverse?
<ide> assert has_one_with_inverse_ref.has_inverse?
<ide>
<ide> has_many_with_inverse_ref = Man.reflect_on_association(:interests)
<del> assert has_many_with_inverse_ref.respond_to?(:has_inverse?)
<add> assert_respond_to has_many_with_inverse_ref, :has_inverse?
<ide> assert has_many_with_inverse_ref.has_inverse?
<ide>
<ide> belongs_to_with_inverse_ref = Face.reflect_on_association(:man)
<del> assert belongs_to_with_inverse_ref.respond_to?(:has_inverse?)
<add> assert_respond_to belongs_to_with_inverse_ref, :has_inverse?
<ide> assert belongs_to_with_inverse_ref.has_inverse?
<ide>
<ide> has_one_without_inverse_ref = Club.reflect_on_association(:sponsor)
<del> assert has_one_without_inverse_ref.respond_to?(:has_inverse?)
<add> assert_respond_to has_one_without_inverse_ref, :has_inverse?
<ide> assert !has_one_without_inverse_ref.has_inverse?
<ide>
<ide> has_many_without_inverse_ref = Club.reflect_on_association(:memberships)
<del> assert has_many_without_inverse_ref.respond_to?(:has_inverse?)
<add> assert_respond_to has_many_without_inverse_ref, :has_inverse?
<ide> assert !has_many_without_inverse_ref.has_inverse?
<ide>
<ide> belongs_to_without_inverse_ref = Sponsor.reflect_on_association(:sponsor_club)
<del> assert belongs_to_without_inverse_ref.respond_to?(:has_inverse?)
<add> assert_respond_to belongs_to_without_inverse_ref, :has_inverse?
<ide> assert !belongs_to_without_inverse_ref.has_inverse?
<ide> end
<ide>
<ide> def test_should_be_able_to_ask_a_reflection_what_it_is_the_inverse_of
<ide> has_one_ref = Man.reflect_on_association(:face)
<del> assert has_one_ref.respond_to?(:inverse_of)
<add> assert_respond_to has_one_ref, :inverse_of
<ide>
<ide> has_many_ref = Man.reflect_on_association(:interests)
<del> assert has_many_ref.respond_to?(:inverse_of)
<add> assert_respond_to has_many_ref, :inverse_of
<ide>
<ide> belongs_to_ref = Face.reflect_on_association(:man)
<del> assert belongs_to_ref.respond_to?(:inverse_of)
<add> assert_respond_to belongs_to_ref, :inverse_of
<ide> end
<ide>
<ide> def test_inverse_of_method_should_supply_the_actual_reflection_instance_it_is_the_inverse_of
<ide><path>activerecord/test/cases/associations/join_model_test.rb
<ide> def test_has_many_with_hash_conditions
<ide>
<ide> def test_has_many_find_conditions
<ide> assert_equal categories(:general), authors(:david).categories.find(:first, :conditions => "categories.name = 'General'")
<del> assert_equal nil, authors(:david).categories.find(:first, :conditions => "categories.name = 'Technology'")
<add> assert_nil authors(:david).categories.find(:first, :conditions => "categories.name = 'Technology'")
<ide> end
<ide>
<ide> def test_has_many_class_methods_called_by_method_missing
<ide> assert_equal categories(:general), authors(:david).categories.find_all_by_name('General').first
<del> assert_equal nil, authors(:david).categories.find_by_name('Technology')
<add> assert_nil authors(:david).categories.find_by_name('Technology')
<ide> end
<ide>
<ide> def test_has_many_array_methods_called_by_method_missing
<ide><path>activerecord/test/cases/attribute_methods_test.rb
<ide> def title; "private!"; end
<ide> end
<ide> assert [email protected]_method_already_implemented?(:title)
<ide> topic = @target.new
<del> assert_equal nil, topic.title
<add> assert_nil topic.title
<ide>
<ide> Object.send(:undef_method, :title) # remove test method from object
<ide> end
<ide><path>activerecord/test/cases/autosave_association_test.rb
<ide> def setup
<ide> end
<ide>
<ide> test "should generate validation methods for has_many associations" do
<del> assert @pirate.respond_to?(:validate_associated_records_for_birds)
<add> assert_respond_to @pirate, :validate_associated_records_for_birds
<ide> end
<ide>
<ide> test "should generate validation methods for has_one associations with :validate => true" do
<del> assert @pirate.respond_to?(:validate_associated_records_for_ship)
<add> assert_respond_to @pirate, :validate_associated_records_for_ship
<ide> end
<ide>
<ide> test "should not generate validation methods for has_one associations without :validate => true" do
<ide> assert [email protected]_to?(:validate_associated_records_for_non_validated_ship)
<ide> end
<ide>
<ide> test "should generate validation methods for belongs_to associations with :validate => true" do
<del> assert @pirate.respond_to?(:validate_associated_records_for_parrot)
<add> assert_respond_to @pirate, :validate_associated_records_for_parrot
<ide> end
<ide>
<ide> test "should not generate validation methods for belongs_to associations without :validate => true" do
<ide> assert [email protected]_to?(:validate_associated_records_for_non_validated_parrot)
<ide> end
<ide>
<ide> test "should generate validation methods for HABTM associations with :validate => true" do
<del> assert @pirate.respond_to?(:validate_associated_records_for_parrots)
<add> assert_respond_to @pirate, :validate_associated_records_for_parrots
<ide> end
<ide>
<ide> test "should not generate validation methods for HABTM associations without :validate => true" do
<ide><path>activerecord/test/cases/base_test.rb
<ide> def test_set_attributes_with_block
<ide>
<ide> def test_respond_to?
<ide> topic = Topic.find(1)
<del> assert topic.respond_to?("title")
<del> assert topic.respond_to?("title?")
<del> assert topic.respond_to?("title=")
<del> assert topic.respond_to?(:title)
<del> assert topic.respond_to?(:title?)
<del> assert topic.respond_to?(:title=)
<del> assert topic.respond_to?("author_name")
<del> assert topic.respond_to?("attribute_names")
<add> assert_respond_to topic, "title"
<add> assert_respond_to topic, "title?"
<add> assert_respond_to topic, "title="
<add> assert_respond_to topic, :title
<add> assert_respond_to topic, :title?
<add> assert_respond_to topic, :title=
<add> assert_respond_to topic, "author_name"
<add> assert_respond_to topic, "attribute_names"
<ide> assert !topic.respond_to?("nothingness")
<ide> assert !topic.respond_to?(:nothingness)
<ide> end
<ide> def test_mass_assignment_protection
<ide> def test_mass_assignment_protection_against_class_attribute_writers
<ide> [:logger, :configurations, :primary_key_prefix_type, :table_name_prefix, :table_name_suffix, :pluralize_table_names,
<ide> :default_timezone, :schema_format, :lock_optimistically, :record_timestamps].each do |method|
<del> assert Task.respond_to?(method)
<del> assert Task.respond_to?("#{method}=")
<del> assert Task.new.respond_to?(method)
<add> assert_respond_to Task, method
<add> assert_respond_to Task, "#{method}="
<add> assert_respond_to Task.new, method
<ide> assert !Task.new.respond_to?("#{method}=")
<ide> end
<ide> end
<ide> def test_boolean_cast_from_string
<ide> end
<ide>
<ide> def test_new_record_returns_boolean
<del> assert_equal Topic.new.new_record?, true
<del> assert_equal Topic.find(1).new_record?, false
<add> assert_equal true, Topic.new.new_record?
<add> assert_equal false, Topic.find(1).new_record?
<ide> end
<ide>
<ide> def test_destroyed_returns_boolean
<ide> developer = Developer.first
<del> assert_equal developer.destroyed?, false
<add> assert_equal false, developer.destroyed?
<ide> developer.destroy
<del> assert_equal developer.destroyed?, true
<add> assert_equal true, developer.destroyed?
<ide>
<ide> developer = Developer.last
<del> assert_equal developer.destroyed?, false
<add> assert_equal false, developer.destroyed?
<ide> developer.delete
<del> assert_equal developer.destroyed?, true
<add> assert_equal true, developer.destroyed?
<ide> end
<ide>
<ide> def test_persisted_returns_boolean
<ide> developer = Developer.new(:name => "Jose")
<del> assert_equal developer.persisted?, false
<add> assert_equal false, developer.persisted?
<ide> developer.save!
<del> assert_equal developer.persisted?, true
<add> assert_equal true, developer.persisted?
<ide>
<ide> developer = Developer.first
<del> assert_equal developer.persisted?, true
<add> assert_equal true, developer.persisted?
<ide> developer.destroy
<del> assert_equal developer.persisted?, false
<add> assert_equal false, developer.persisted?
<ide>
<ide> developer = Developer.last
<del> assert_equal developer.persisted?, true
<add> assert_equal true, developer.persisted?
<ide> developer.delete
<del> assert_equal developer.persisted?, false
<add> assert_equal false, developer.persisted?
<ide> end
<ide>
<ide> def test_clone
<ide> def test_clone
<ide> # test if saved clone object differs from original
<ide> cloned_topic.save
<ide> assert !cloned_topic.new_record?
<del> assert cloned_topic.id != topic.id
<add> assert_not_equal cloned_topic.id, topic.id
<ide> end
<ide>
<ide> def test_clone_with_aggregate_of_same_name_as_attribute
<ide> def test_clone_with_aggregate_of_same_name_as_attribute
<ide>
<ide> assert clone.save
<ide> assert !clone.new_record?
<del> assert clone.id != dev.id
<add> assert_not_equal clone.id, dev.id
<ide> end
<ide>
<ide> def test_clone_preserves_subtype
<ide><path>activerecord/test/cases/column_definition_test.rb
<ide> def test_has_default_should_return_false_for_blog_and_test_data_types
<ide> if current_adapter?(:PostgreSQLAdapter)
<ide> def test_bigint_column_should_map_to_integer
<ide> bigint_column = ActiveRecord::ConnectionAdapters::PostgreSQLColumn.new('number', nil, "bigint")
<del> assert_equal bigint_column.type, :integer
<add> assert_equal :integer, bigint_column.type
<ide> end
<ide>
<ide> def test_smallint_column_should_map_to_integer
<ide> smallint_column = ActiveRecord::ConnectionAdapters::PostgreSQLColumn.new('number', nil, "smallint")
<del> assert_equal smallint_column.type, :integer
<add> assert_equal :integer, smallint_column.type
<ide> end
<ide>
<ide> def test_uuid_column_should_map_to_string
<ide> uuid_column = ActiveRecord::ConnectionAdapters::PostgreSQLColumn.new('unique_id', nil, "uuid")
<del> assert_equal uuid_column.type, :string
<add> assert_equal :string, uuid_column.type
<ide> end
<ide> end
<ide> end
<ide><path>activerecord/test/cases/defaults_test.rb
<ide> def test_mysql_text_not_null_defaults
<ide> assert_equal '', klass.columns_hash['non_null_blob'].default
<ide> assert_equal '', klass.columns_hash['non_null_text'].default
<ide>
<del> assert_equal nil, klass.columns_hash['null_blob'].default
<del> assert_equal nil, klass.columns_hash['null_text'].default
<add> assert_nil klass.columns_hash['null_blob'].default
<add> assert_nil klass.columns_hash['null_text'].default
<ide>
<ide> assert_nothing_raised do
<ide> instance = klass.create!
<ide><path>activerecord/test/cases/dirty_test.rb
<ide> def test_time_attributes_changes_without_time_zone_by_skip
<ide> assert pirate.created_on_changed?
<ide> # kind_of does not work because
<ide> # ActiveSupport::TimeWithZone.name == 'Time'
<del> assert_equal Time, pirate.created_on_was.class
<add> assert_instance_of Time, pirate.created_on_was
<ide> assert_equal old_created_on, pirate.created_on_was
<ide> end
<ide> end
<ide> def test_time_attributes_changes_without_time_zone
<ide> assert pirate.created_on_changed?
<ide> # kind_of does not work because
<ide> # ActiveSupport::TimeWithZone.name == 'Time'
<del> assert_equal Time, pirate.created_on_was.class
<add> assert_instance_of Time, pirate.created_on_was
<ide> assert_equal old_created_on, pirate.created_on_was
<ide> end
<ide>
<ide><path>activerecord/test/cases/finder_respond_to_test.rb
<ide> class FinderRespondToTest < ActiveRecord::TestCase
<ide>
<ide> def test_should_preserve_normal_respond_to_behaviour_and_respond_to_newly_added_method
<ide> class << Topic; self; end.send(:define_method, :method_added_for_finder_respond_to_test) { }
<del> assert Topic.respond_to?(:method_added_for_finder_respond_to_test)
<add> assert_respond_to Topic, :method_added_for_finder_respond_to_test
<ide> ensure
<ide> class << Topic; self; end.send(:remove_method, :method_added_for_finder_respond_to_test)
<ide> end
<ide>
<ide> def test_should_preserve_normal_respond_to_behaviour_and_respond_to_standard_object_method
<del> assert Topic.respond_to?(:to_s)
<add> assert_respond_to Topic, :to_s
<ide> end
<ide>
<ide> def test_should_respond_to_find_by_one_attribute_before_caching
<ide> ensure_topic_method_is_not_cached(:find_by_title)
<del> assert Topic.respond_to?(:find_by_title)
<add> assert_respond_to Topic, :find_by_title
<ide> end
<ide>
<ide> def test_should_respond_to_find_all_by_one_attribute
<ide> ensure_topic_method_is_not_cached(:find_all_by_title)
<del> assert Topic.respond_to?(:find_all_by_title)
<add> assert_respond_to Topic, :find_all_by_title
<ide> end
<ide>
<ide> def test_should_respond_to_find_all_by_two_attributes
<ide> ensure_topic_method_is_not_cached(:find_all_by_title_and_author_name)
<del> assert Topic.respond_to?(:find_all_by_title_and_author_name)
<add> assert_respond_to Topic, :find_all_by_title_and_author_name
<ide> end
<ide>
<ide> def test_should_respond_to_find_by_two_attributes
<ide> ensure_topic_method_is_not_cached(:find_by_title_and_author_name)
<del> assert Topic.respond_to?(:find_by_title_and_author_name)
<add> assert_respond_to Topic, :find_by_title_and_author_name
<ide> end
<ide>
<ide> def test_should_respond_to_find_or_initialize_from_one_attribute
<ide> ensure_topic_method_is_not_cached(:find_or_initialize_by_title)
<del> assert Topic.respond_to?(:find_or_initialize_by_title)
<add> assert_respond_to Topic, :find_or_initialize_by_title
<ide> end
<ide>
<ide> def test_should_respond_to_find_or_initialize_from_two_attributes
<ide> ensure_topic_method_is_not_cached(:find_or_initialize_by_title_and_author_name)
<del> assert Topic.respond_to?(:find_or_initialize_by_title_and_author_name)
<add> assert_respond_to Topic, :find_or_initialize_by_title_and_author_name
<ide> end
<ide>
<ide> def test_should_respond_to_find_or_create_from_one_attribute
<ide> ensure_topic_method_is_not_cached(:find_or_create_by_title)
<del> assert Topic.respond_to?(:find_or_create_by_title)
<add> assert_respond_to Topic, :find_or_create_by_title
<ide> end
<ide>
<ide> def test_should_respond_to_find_or_create_from_two_attributes
<ide> ensure_topic_method_is_not_cached(:find_or_create_by_title_and_author_name)
<del> assert Topic.respond_to?(:find_or_create_by_title_and_author_name)
<add> assert_respond_to Topic, :find_or_create_by_title_and_author_name
<ide> end
<ide>
<ide> def test_should_not_respond_to_find_by_one_missing_attribute
<ide> def ensure_topic_method_is_not_cached(method_id)
<ide> class << Topic; self; end.send(:remove_method, method_id) if Topic.public_methods.any? { |m| m.to_s == method_id.to_s }
<ide> end
<ide>
<del>end
<ide>\ No newline at end of file
<add>end | 27 |
Go | Go | fix typo in container.go | 2f57eb04102c2ef08e478d3977fc3682672473af | <ide><path>container.go
<ide> func (container *Container) createVolumes() error {
<ide> return err
<ide> }
<ide> // Change the source volume's ownership if it differs from the root
<del> // files that where just copied
<add> // files that were just copied
<ide> if stat.Uid != srcStat.Uid || stat.Gid != srcStat.Gid {
<ide> if err := os.Chown(srcPath, int(stat.Uid), int(stat.Gid)); err != nil {
<ide> return err
<ide> func (container *Container) applyExternalVolumes() error {
<ide> mountRW = false
<ide> case "rw": // mountRW is already true
<ide> default:
<del> return fmt.Errorf("Malformed volumes-from speficication: %s", containerSpec)
<add> return fmt.Errorf("Malformed volumes-from specification: %s", containerSpec)
<ide> }
<ide> }
<ide> c := container.runtime.Get(specParts[0]) | 1 |
Javascript | Javascript | add example of string literals in format string | 42f28751e0dea552457da3f32b4d107ec6fc8818 | <ide><path>src/ng/filter/filters.js
<ide> var DATE_FORMATS_SPLIT = /((?:[^yMdHhmsaZEw']+)|(?:'(?:[^']|'')*')|(?:E+|y+|M+|d
<ide> * * `'mediumTime'`: equivalent to `'h:mm:ss a'` for en_US locale (e.g. 12:05:08 pm)
<ide> * * `'shortTime'`: equivalent to `'h:mm a'` for en_US locale (e.g. 12:05 pm)
<ide> *
<del> * `format` string can contain literal values. These need to be quoted with single quotes (e.g.
<del> * `"h 'in the morning'"`). In order to output single quote, use two single quotes in a sequence
<add> * `format` string can contain literal values. These need to be escaped by surrounding with single quotes (e.g.
<add> * `"h 'in the morning'"`). In order to output a single quote, escape it - i.e., two single quotes in a sequence
<ide> * (e.g. `"h 'o''clock'"`).
<ide> *
<ide> * @param {(Date|number|string)} date Date to format either as Date object, milliseconds (string or
<ide> var DATE_FORMATS_SPLIT = /((?:[^yMdHhmsaZEw']+)|(?:'(?:[^']|'')*')|(?:E+|y+|M+|d
<ide> <span>{{1288323623006 | date:'yyyy-MM-dd HH:mm:ss Z'}}</span><br>
<ide> <span ng-non-bindable>{{1288323623006 | date:'MM/dd/yyyy @ h:mma'}}</span>:
<ide> <span>{{'1288323623006' | date:'MM/dd/yyyy @ h:mma'}}</span><br>
<add> <span ng-non-bindable>{{1288323623006 | date:"MM/dd/yyyy 'at' h:mma"}}</span>:
<add> <span>{{'1288323623006' | date:"MM/dd/yyyy 'at' h:mma"}}</span><br>
<ide> </file>
<ide> <file name="protractor.js" type="protractor">
<ide> it('should format date', function() {
<ide> var DATE_FORMATS_SPLIT = /((?:[^yMdHhmsaZEw']+)|(?:'(?:[^']|'')*')|(?:E+|y+|M+|d
<ide> toMatch(/2010\-10\-2\d \d{2}:\d{2}:\d{2} (\-|\+)?\d{4}/);
<ide> expect(element(by.binding("'1288323623006' | date:'MM/dd/yyyy @ h:mma'")).getText()).
<ide> toMatch(/10\/2\d\/2010 @ \d{1,2}:\d{2}(AM|PM)/);
<add> expect(element(by.binding("'1288323623006' | date:\"MM/dd/yyyy 'at' h:mma\"")).getText()).
<add> toMatch(/10\/2\d\/2010 at \d{1,2}:\d{2}(AM|PM)/);
<ide> });
<ide> </file>
<ide> </example> | 1 |
Go | Go | fix race condition in api commit test | cd4f507b42e800d148b211ca2c780d01192a9041 | <ide><path>integration-cli/docker_api_containers_test.go
<ide> func (s *DockerSuite) TestContainerApiTop(c *check.C) {
<ide> }
<ide>
<ide> func (s *DockerSuite) TestContainerApiCommit(c *check.C) {
<del> out, err := exec.Command(dockerBinary, "run", "-d", "busybox", "/bin/sh", "-c", "touch /test").CombinedOutput()
<add> cName := "testapicommit"
<add> out, err := exec.Command(dockerBinary, "run", "--name="+cName, "busybox", "/bin/sh", "-c", "touch /test").CombinedOutput()
<ide> if err != nil {
<ide> c.Fatal(err, out)
<ide> }
<del> id := strings.TrimSpace(string(out))
<ide>
<ide> name := "testcommit" + stringid.GenerateRandomID()
<del> status, b, err := sockRequest("POST", "/commit?repo="+name+"&testtag=tag&container="+id, nil)
<add> status, b, err := sockRequest("POST", "/commit?repo="+name+"&testtag=tag&container="+cName, nil)
<ide> c.Assert(status, check.Equals, http.StatusCreated)
<ide> c.Assert(err, check.IsNil)
<ide> | 1 |
Python | Python | add some comments | 3ad0f70a11b00a2fae9a8f6fc2ecd4ead202e6b8 | <ide><path>keras/engine/training.py
<ide> def potentially_variable_concat(tensors, axis=0):
<ide> return tf.concat(tensors, axis=axis)
<ide> # First, identify constant inner dimensions by finding the rightmost dimension that is not constant
<ide> constant_inner_dimensions = constant_dims.numpy().tolist()[::-1].index(False)
<add> # If there are constant inner dimensions, define a constant inner shape
<ide> if constant_inner_dimensions == 0:
<ide> constant_inner_shape = None
<ide> else: | 1 |
Python | Python | lowercase the input | 466575bee60d2575dc5fb69c6e19e1fab3fd6803 | <ide><path>rest_framework/fields.py
<ide> class IPAddressField(CharField):
<ide> }
<ide>
<ide> def __init__(self, protocol='both', unpack_ipv4=False, **kwargs):
<del> self.protocol = protocol
<add> self.protocol = protocol.lower()
<ide> self.unpack_ipv4 = unpack_ipv4
<ide> super(IPAddressField, self).__init__(**kwargs)
<ide> validators, error_message = ip_address_validators(protocol, unpack_ipv4) | 1 |
Javascript | Javascript | update data uri test cases | f4abe4a550236dd8a558b083799101b0c861b020 | <ide><path>test/cases/resolving/data-uri/index.js
<ide> it("should import js module from base64 data-uri", function() {
<ide> });
<ide>
<ide> it("should require coffee module from base64 data-uri", function() {
<del> const mod = require('coffee-loader!data:text/javascript;charset=utf-8;base64,bW9kdWxlLmV4cG9ydHMgPQogIG51bWJlcjogNDIKICBmbjogKCkgLT4gIkhlbGxvIHdvcmxkIg==');
<add> const mod = require('coffee-loader!Data:text/javascript;charset=utf-8;base64,bW9kdWxlLmV4cG9ydHMgPQogIG51bWJlcjogNDIKICBmbjogKCkgLT4gIkhlbGxvIHdvcmxkIg==');
<ide> expect(mod.number).toBe(42);
<ide> expect(mod.fn()).toBe("Hello world");
<ide> });
<ide>
<ide> it("should require json module from base64 data-uri", function() {
<del> const mod = require('data:application/json;charset=utf-8;base64,ewogICJpdCI6ICJ3b3JrcyIsCiAgIm51bWJlciI6IDQyCn0K');
<add> const mod = require('DATA:application/json;charset=utf-8;base64,ewogICJpdCI6ICJ3b3JrcyIsCiAgIm51bWJlciI6IDQyCn0K');
<ide> expect(mod.it).toBe("works");
<ide> expect(mod.number).toBe(42);
<ide> }) | 1 |
Python | Python | fix failing test | e10aab8e102c2ed1481feed4f3b3459da3c43a09 | <ide><path>libcloud/test/compute/test_ssh_client.py
<ide> def test_consume_stdout_chunk_contains_part_of_multi_byte_utf8_character(self):
<ide> chan.recv.side_effect = ['\xF0', '\x90', '\x8D', '\x88']
<ide>
<ide> stdout = client._consume_stdout(chan).getvalue()
<del> self.assertEqual('\xf0\x90\x8d\x88', stdout.encode('utf-8'))
<del> self.assertTrue(len(stdout) in [1, 2])
<add> self.assertEqual('ð\x90\x8d\x88', stdout)
<add> self.assertEqual(len(stdout), 4)
<ide>
<ide> def test_consume_stderr_chunk_contains_part_of_multi_byte_utf8_character(self):
<ide> conn_params = {'hostname': 'dummy.host.org',
<ide> def test_consume_stderr_chunk_contains_part_of_multi_byte_utf8_character(self):
<ide> chan.recv_stderr.side_effect = ['\xF0', '\x90', '\x8D', '\x88']
<ide>
<ide> stderr = client._consume_stderr(chan).getvalue()
<del> self.assertEqual('\xf0\x90\x8d\x88', stderr.encode('utf-8'))
<del> self.assertTrue(len(stderr) in [1, 2])
<add> self.assertEqual('ð\x90\x8d\x88', stderr)
<add> self.assertEqual(len(stderr), 4)
<ide>
<ide>
<ide> class ShellOutSSHClientTests(LibcloudTestCase): | 1 |
Go | Go | move layer mount refcounts to mountedlayer | 563d0711f83952e561a0d7d5c48fef9810b4f010 | <ide><path>daemon/commit.go
<ide> func (daemon *Daemon) exportContainerRw(container *container.Container) (archive
<ide>
<ide> archive, err := container.RWLayer.TarStream()
<ide> if err != nil {
<add> daemon.Unmount(container) // logging is already handled in the `Unmount` function
<ide> return nil, err
<ide> }
<ide> return ioutils.NewReadCloserWrapper(archive, func() error {
<ide><path>daemon/graphdriver/aufs/aufs.go
<ide> import (
<ide> "os"
<ide> "os/exec"
<ide> "path"
<add> "path/filepath"
<ide> "strings"
<ide> "sync"
<ide> "syscall"
<ide> func init() {
<ide> graphdriver.Register("aufs", Init)
<ide> }
<ide>
<del>type data struct {
<del> referenceCount int
<del> path string
<del>}
<del>
<ide> // Driver contains information about the filesystem mounted.
<del>// root of the filesystem
<del>// sync.Mutex to protect against concurrent modifications
<del>// active maps mount id to the count
<ide> type Driver struct {
<del> root string
<del> uidMaps []idtools.IDMap
<del> gidMaps []idtools.IDMap
<del> sync.Mutex // Protects concurrent modification to active
<del> active map[string]*data
<add> root string
<add> uidMaps []idtools.IDMap
<add> gidMaps []idtools.IDMap
<add> pathCacheLock sync.Mutex
<add> pathCache map[string]string
<ide> }
<ide>
<ide> // Init returns a new AUFS driver.
<ide> func Init(root string, options []string, uidMaps, gidMaps []idtools.IDMap) (grap
<ide> }
<ide>
<ide> a := &Driver{
<del> root: root,
<del> active: make(map[string]*data),
<del> uidMaps: uidMaps,
<del> gidMaps: gidMaps,
<add> root: root,
<add> uidMaps: uidMaps,
<add> gidMaps: gidMaps,
<add> pathCache: make(map[string]string),
<ide> }
<ide>
<ide> rootUID, rootGID, err := idtools.GetRootUIDGID(uidMaps, gidMaps)
<ide> func (a *Driver) Create(id, parent, mountLabel string) error {
<ide> }
<ide> }
<ide> }
<del> a.Lock()
<del> a.active[id] = &data{}
<del> a.Unlock()
<add>
<ide> return nil
<ide> }
<ide>
<ide> func (a *Driver) createDirsFor(id string) error {
<ide>
<ide> // Remove will unmount and remove the given id.
<ide> func (a *Driver) Remove(id string) error {
<del> // Protect the a.active from concurrent access
<del> a.Lock()
<del> defer a.Unlock()
<del>
<del> m := a.active[id]
<del> if m != nil {
<del> if m.referenceCount > 0 {
<del> return nil
<del> }
<del> // Make sure the dir is umounted first
<del> if err := a.unmount(m); err != nil {
<del> return err
<del> }
<add> a.pathCacheLock.Lock()
<add> mountpoint, exists := a.pathCache[id]
<add> a.pathCacheLock.Unlock()
<add> if !exists {
<add> mountpoint = a.getMountpoint(id)
<ide> }
<del> tmpDirs := []string{
<del> "mnt",
<del> "diff",
<add> if err := a.unmount(mountpoint); err != nil {
<add> // no need to return here, we can still try to remove since the `Rename` will fail below if still mounted
<add> logrus.Debugf("aufs: error while unmounting %s: %v", mountpoint, err)
<ide> }
<ide>
<ide> // Atomically remove each directory in turn by first moving it out of the
<ide> // way (so that docker doesn't find it anymore) before doing removal of
<ide> // the whole tree.
<del> for _, p := range tmpDirs {
<del> realPath := path.Join(a.rootPath(), p, id)
<del> tmpPath := path.Join(a.rootPath(), p, fmt.Sprintf("%s-removing", id))
<del> if err := os.Rename(realPath, tmpPath); err != nil && !os.IsNotExist(err) {
<del> return err
<del> }
<del> defer os.RemoveAll(tmpPath)
<add> tmpMntPath := path.Join(a.mntPath(), fmt.Sprintf("%s-removing", id))
<add> if err := os.Rename(mountpoint, tmpMntPath); err != nil && !os.IsNotExist(err) {
<add> return err
<add> }
<add> defer os.RemoveAll(tmpMntPath)
<add>
<add> tmpDiffpath := path.Join(a.diffPath(), fmt.Sprintf("%s-removing", id))
<add> if err := os.Rename(a.getDiffPath(id), tmpDiffpath); err != nil && !os.IsNotExist(err) {
<add> return err
<ide> }
<add> defer os.RemoveAll(tmpDiffpath)
<add>
<ide> // Remove the layers file for the id
<ide> if err := os.Remove(path.Join(a.rootPath(), "layers", id)); err != nil && !os.IsNotExist(err) {
<ide> return err
<ide> }
<del> if m != nil {
<del> delete(a.active, id)
<del> }
<add>
<add> a.pathCacheLock.Lock()
<add> delete(a.pathCache, id)
<add> a.pathCacheLock.Unlock()
<ide> return nil
<ide> }
<ide>
<ide> // Get returns the rootfs path for the id.
<ide> // This will mount the dir at it's given path
<ide> func (a *Driver) Get(id, mountLabel string) (string, error) {
<del> // Protect the a.active from concurrent access
<del> a.Lock()
<del> defer a.Unlock()
<del>
<del> m := a.active[id]
<del> if m == nil {
<del> m = &data{}
<del> a.active[id] = m
<del> }
<del>
<ide> parents, err := a.getParentLayerPaths(id)
<ide> if err != nil && !os.IsNotExist(err) {
<ide> return "", err
<ide> }
<ide>
<add> a.pathCacheLock.Lock()
<add> m, exists := a.pathCache[id]
<add> a.pathCacheLock.Unlock()
<add>
<add> if !exists {
<add> m = a.getDiffPath(id)
<add> if len(parents) > 0 {
<add> m = a.getMountpoint(id)
<add> }
<add> }
<add>
<ide> // If a dir does not have a parent ( no layers )do not try to mount
<ide> // just return the diff path to the data
<del> m.path = path.Join(a.rootPath(), "diff", id)
<ide> if len(parents) > 0 {
<del> m.path = path.Join(a.rootPath(), "mnt", id)
<del> if m.referenceCount == 0 {
<del> if err := a.mount(id, m, mountLabel, parents); err != nil {
<del> return "", err
<del> }
<add> if err := a.mount(id, m, mountLabel, parents); err != nil {
<add> return "", err
<ide> }
<ide> }
<del> m.referenceCount++
<del> return m.path, nil
<add>
<add> a.pathCacheLock.Lock()
<add> a.pathCache[id] = m
<add> a.pathCacheLock.Unlock()
<add> return m, nil
<ide> }
<ide>
<ide> // Put unmounts and updates list of active mounts.
<ide> func (a *Driver) Put(id string) error {
<del> // Protect the a.active from concurrent access
<del> a.Lock()
<del> defer a.Unlock()
<del>
<del> m := a.active[id]
<del> if m == nil {
<del> // but it might be still here
<del> if a.Exists(id) {
<del> path := path.Join(a.rootPath(), "mnt", id)
<del> err := Unmount(path)
<del> if err != nil {
<del> logrus.Debugf("Failed to unmount %s aufs: %v", id, err)
<del> }
<del> }
<del> return nil
<add> a.pathCacheLock.Lock()
<add> m, exists := a.pathCache[id]
<add> if !exists {
<add> m = a.getMountpoint(id)
<add> a.pathCache[id] = m
<ide> }
<del> if count := m.referenceCount; count > 1 {
<del> m.referenceCount = count - 1
<del> } else {
<del> ids, _ := getParentIds(a.rootPath(), id)
<del> // We only mounted if there are any parents
<del> if ids != nil && len(ids) > 0 {
<del> a.unmount(m)
<del> }
<del> delete(a.active, id)
<add> a.pathCacheLock.Unlock()
<add>
<add> err := a.unmount(m)
<add> if err != nil {
<add> logrus.Debugf("Failed to unmount %s aufs: %v", id, err)
<ide> }
<del> return nil
<add> return err
<ide> }
<ide>
<ide> // Diff produces an archive of the changes between the specified
<ide> func (a *Driver) getParentLayerPaths(id string) ([]string, error) {
<ide> return layers, nil
<ide> }
<ide>
<del>func (a *Driver) mount(id string, m *data, mountLabel string, layers []string) error {
<add>func (a *Driver) mount(id string, target string, mountLabel string, layers []string) error {
<ide> // If the id is mounted or we get an error return
<del> if mounted, err := a.mounted(m); err != nil || mounted {
<add> if mounted, err := a.mounted(target); err != nil || mounted {
<ide> return err
<ide> }
<ide>
<del> var (
<del> target = m.path
<del> rw = path.Join(a.rootPath(), "diff", id)
<del> )
<add> rw := a.getDiffPath(id)
<ide>
<ide> if err := a.aufsMount(layers, rw, target, mountLabel); err != nil {
<ide> return fmt.Errorf("error creating aufs mount to %s: %v", target, err)
<ide> }
<ide> return nil
<ide> }
<ide>
<del>func (a *Driver) unmount(m *data) error {
<del> if mounted, err := a.mounted(m); err != nil || !mounted {
<add>func (a *Driver) unmount(mountPath string) error {
<add> if mounted, err := a.mounted(mountPath); err != nil || !mounted {
<add> return err
<add> }
<add> if err := Unmount(mountPath); err != nil {
<ide> return err
<ide> }
<del> return Unmount(m.path)
<add> return nil
<ide> }
<ide>
<del>func (a *Driver) mounted(m *data) (bool, error) {
<del> var buf syscall.Statfs_t
<del> if err := syscall.Statfs(m.path, &buf); err != nil {
<del> return false, nil
<del> }
<del> return graphdriver.FsMagic(buf.Type) == graphdriver.FsMagicAufs, nil
<add>func (a *Driver) mounted(mountpoint string) (bool, error) {
<add> return graphdriver.Mounted(graphdriver.FsMagicAufs, mountpoint)
<ide> }
<ide>
<ide> // Cleanup aufs and unmount all mountpoints
<ide> func (a *Driver) Cleanup() error {
<del> for id, m := range a.active {
<add> var dirs []string
<add> if err := filepath.Walk(a.mntPath(), func(path string, info os.FileInfo, err error) error {
<add> if err != nil {
<add> return err
<add> }
<add> if !info.IsDir() {
<add> return nil
<add> }
<add> dirs = append(dirs, path)
<add> return nil
<add> }); err != nil {
<add> return err
<add> }
<add>
<add> for _, m := range dirs {
<ide> if err := a.unmount(m); err != nil {
<del> logrus.Errorf("Unmounting %s: %s", stringid.TruncateID(id), err)
<add> logrus.Debugf("aufs error unmounting %s: %s", stringid.TruncateID(m), err)
<ide> }
<ide> }
<ide> return mountpk.Unmount(a.root)
<ide><path>daemon/graphdriver/aufs/aufs_test.go
<ide> func TestMountedFalseResponse(t *testing.T) {
<ide> t.Fatal(err)
<ide> }
<ide>
<del> response, err := d.mounted(d.active["1"])
<add> response, err := d.mounted(d.getDiffPath("1"))
<ide> if err != nil {
<ide> t.Fatal(err)
<ide> }
<ide> func TestMountedTrueReponse(t *testing.T) {
<ide> t.Fatal(err)
<ide> }
<ide>
<del> response, err := d.mounted(d.active["2"])
<add> response, err := d.mounted(d.pathCache["2"])
<ide> if err != nil {
<ide> t.Fatal(err)
<ide> }
<ide> func TestRemoveMountedDir(t *testing.T) {
<ide> t.Fatal("mntPath should not be empty string")
<ide> }
<ide>
<del> mounted, err := d.mounted(d.active["2"])
<add> mounted, err := d.mounted(d.pathCache["2"])
<ide> if err != nil {
<ide> t.Fatal(err)
<ide> }
<ide><path>daemon/graphdriver/aufs/dirs.go
<ide> func getParentIds(root, id string) ([]string, error) {
<ide> }
<ide> return out, s.Err()
<ide> }
<add>
<add>func (a *Driver) getMountpoint(id string) string {
<add> return path.Join(a.mntPath(), id)
<add>}
<add>
<add>func (a *Driver) mntPath() string {
<add> return path.Join(a.rootPath(), "mnt")
<add>}
<add>
<add>func (a *Driver) getDiffPath(id string) string {
<add> return path.Join(a.diffPath(), id)
<add>}
<add>
<add>func (a *Driver) diffPath() string {
<add> return path.Join(a.rootPath(), "diff")
<add>}
<ide><path>daemon/graphdriver/devmapper/deviceset.go
<ide> type devInfo struct {
<ide> Deleted bool `json:"deleted"`
<ide> devices *DeviceSet
<ide>
<del> mountCount int
<del> mountPath string
<del>
<ide> // The global DeviceSet lock guarantees that we serialize all
<ide> // the calls to libdevmapper (which is not threadsafe), but we
<ide> // sometimes release that lock while sleeping. In that case
<ide> func (devices *DeviceSet) DeleteDevice(hash string, syncDelete bool) error {
<ide> devices.Lock()
<ide> defer devices.Unlock()
<ide>
<del> // If mountcount is not zero, that means devices is still in use
<del> // or has not been Put() properly. Fail device deletion.
<del>
<del> if info.mountCount != 0 {
<del> return fmt.Errorf("devmapper: Can't delete device %v as it is still mounted. mntCount=%v", info.Hash, info.mountCount)
<del> }
<del>
<ide> return devices.deleteDevice(info, syncDelete)
<ide> }
<ide>
<ide> func (devices *DeviceSet) cancelDeferredRemoval(info *devInfo) error {
<ide> }
<ide>
<ide> // Shutdown shuts down the device by unmounting the root.
<del>func (devices *DeviceSet) Shutdown() error {
<add>func (devices *DeviceSet) Shutdown(home string) error {
<ide> logrus.Debugf("devmapper: [deviceset %s] Shutdown()", devices.devicePrefix)
<ide> logrus.Debugf("devmapper: Shutting down DeviceSet: %s", devices.root)
<ide> defer logrus.Debugf("devmapper: [deviceset %s] Shutdown() END", devices.devicePrefix)
<ide>
<del> var devs []*devInfo
<del>
<ide> // Stop deletion worker. This should start delivering new events to
<ide> // ticker channel. That means no new instance of cleanupDeletedDevice()
<ide> // will run after this call. If one instance is already running at
<ide> func (devices *DeviceSet) Shutdown() error {
<ide> // metadata. Hence save this early before trying to deactivate devices.
<ide> devices.saveDeviceSetMetaData()
<ide>
<del> for _, info := range devices.Devices {
<del> devs = append(devs, info)
<add> // ignore the error since it's just a best effort to not try to unmount something that's mounted
<add> mounts, _ := mount.GetMounts()
<add> mounted := make(map[string]bool, len(mounts))
<add> for _, mnt := range mounts {
<add> mounted[mnt.Mountpoint] = true
<ide> }
<del> devices.Unlock()
<ide>
<del> for _, info := range devs {
<del> info.lock.Lock()
<del> if info.mountCount > 0 {
<add> if err := filepath.Walk(path.Join(home, "mnt"), func(p string, info os.FileInfo, err error) error {
<add> if err != nil {
<add> return err
<add> }
<add> if !info.IsDir() {
<add> return nil
<add> }
<add>
<add> if mounted[p] {
<ide> // We use MNT_DETACH here in case it is still busy in some running
<ide> // container. This means it'll go away from the global scope directly,
<ide> // and the device will be released when that container dies.
<del> if err := syscall.Unmount(info.mountPath, syscall.MNT_DETACH); err != nil {
<del> logrus.Debugf("devmapper: Shutdown unmounting %s, error: %s", info.mountPath, err)
<add> if err := syscall.Unmount(p, syscall.MNT_DETACH); err != nil {
<add> logrus.Debugf("devmapper: Shutdown unmounting %s, error: %s", p, err)
<ide> }
<add> }
<ide>
<del> devices.Lock()
<del> if err := devices.deactivateDevice(info); err != nil {
<del> logrus.Debugf("devmapper: Shutdown deactivate %s , error: %s", info.Hash, err)
<add> if devInfo, err := devices.lookupDevice(path.Base(p)); err != nil {
<add> logrus.Debugf("devmapper: Shutdown lookup device %s, error: %s", path.Base(p), err)
<add> } else {
<add> if err := devices.deactivateDevice(devInfo); err != nil {
<add> logrus.Debugf("devmapper: Shutdown deactivate %s , error: %s", devInfo.Hash, err)
<ide> }
<del> devices.Unlock()
<ide> }
<del> info.lock.Unlock()
<add>
<add> return nil
<add> }); err != nil && !os.IsNotExist(err) {
<add> devices.Unlock()
<add> return err
<ide> }
<ide>
<add> devices.Unlock()
<add>
<ide> info, _ := devices.lookupDeviceWithLock("")
<ide> if info != nil {
<ide> info.lock.Lock()
<ide> func (devices *DeviceSet) MountDevice(hash, path, mountLabel string) error {
<ide> devices.Lock()
<ide> defer devices.Unlock()
<ide>
<del> if info.mountCount > 0 {
<del> if path != info.mountPath {
<del> return fmt.Errorf("devmapper: Trying to mount devmapper device in multiple places (%s, %s)", info.mountPath, path)
<del> }
<del>
<del> info.mountCount++
<del> return nil
<del> }
<del>
<ide> if err := devices.activateDeviceIfNeeded(info, false); err != nil {
<ide> return fmt.Errorf("devmapper: Error activating devmapper device for '%s': %s", hash, err)
<ide> }
<ide> func (devices *DeviceSet) MountDevice(hash, path, mountLabel string) error {
<ide> return fmt.Errorf("devmapper: Error mounting '%s' on '%s': %s", info.DevName(), path, err)
<ide> }
<ide>
<del> info.mountCount = 1
<del> info.mountPath = path
<del>
<ide> return nil
<ide> }
<ide>
<ide> func (devices *DeviceSet) UnmountDevice(hash, mountPath string) error {
<ide> devices.Lock()
<ide> defer devices.Unlock()
<ide>
<del> // If there are running containers when daemon crashes, during daemon
<del> // restarting, it will kill running containers and will finally call
<del> // Put() without calling Get(). So info.MountCount may become negative.
<del> // if info.mountCount goes negative, we do the unmount and assign
<del> // it to 0.
<del>
<del> info.mountCount--
<del> if info.mountCount > 0 {
<del> return nil
<del> } else if info.mountCount < 0 {
<del> logrus.Warnf("devmapper: Mount count of device went negative. Put() called without matching Get(). Resetting count to 0")
<del> info.mountCount = 0
<del> }
<del>
<ide> logrus.Debugf("devmapper: Unmount(%s)", mountPath)
<ide> if err := syscall.Unmount(mountPath, syscall.MNT_DETACH); err != nil {
<ide> return err
<ide> func (devices *DeviceSet) UnmountDevice(hash, mountPath string) error {
<ide> return err
<ide> }
<ide>
<del> info.mountPath = ""
<del>
<ide> return nil
<ide> }
<ide>
<ide><path>daemon/graphdriver/devmapper/driver.go
<ide> func (d *Driver) GetMetadata(id string) (map[string]string, error) {
<ide>
<ide> // Cleanup unmounts a device.
<ide> func (d *Driver) Cleanup() error {
<del> err := d.DeviceSet.Shutdown()
<add> err := d.DeviceSet.Shutdown(d.home)
<ide>
<ide> if err2 := mount.Unmount(d.home); err == nil {
<ide> err = err2
<ide><path>daemon/graphdriver/driver_freebsd.go
<ide> package graphdriver
<ide>
<add>import "syscall"
<add>
<ide> var (
<ide> // Slice of drivers that should be used in an order
<ide> priority = []string{
<ide> "zfs",
<ide> }
<ide> )
<add>
<add>// Mounted checks if the given path is mounted as the fs type
<add>func Mounted(fsType FsMagic, mountPath string) (bool, error) {
<add> var buf syscall.Statfs_t
<add> if err := syscall.Statfs(mountPath, &buf); err != nil {
<add> return false, err
<add> }
<add> return FsMagic(buf.Type) == fsType, nil
<add>}
<ide><path>daemon/graphdriver/driver_linux.go
<ide> const (
<ide> FsMagicXfs = FsMagic(0x58465342)
<ide> // FsMagicZfs filesystem id for Zfs
<ide> FsMagicZfs = FsMagic(0x2fc12fc1)
<add> // FsMagicOverlay filesystem id for overlay
<add> FsMagicOverlay = FsMagic(0x794C7630)
<ide> )
<ide>
<ide> var (
<ide> func GetFSMagic(rootpath string) (FsMagic, error) {
<ide> }
<ide> return FsMagic(buf.Type), nil
<ide> }
<add>
<add>// Mounted checks if the given path is mounted as the fs type
<add>func Mounted(fsType FsMagic, mountPath string) (bool, error) {
<add> var buf syscall.Statfs_t
<add> if err := syscall.Statfs(mountPath, &buf); err != nil {
<add> return false, err
<add> }
<add> return FsMagic(buf.Type) == fsType, nil
<add>}
<ide><path>daemon/graphdriver/overlay/overlay.go
<ide> func (d *naiveDiffDriverWithApply) ApplyDiff(id, parent string, diff archive.Rea
<ide> // of that. This means all child images share file (but not directory)
<ide> // data with the parent.
<ide>
<del>// ActiveMount contains information about the count, path and whether is mounted or not.
<del>// This information is part of the Driver, that contains list of active mounts that are part of this overlay.
<del>type ActiveMount struct {
<del> count int
<del> path string
<del> mounted bool
<del>}
<del>
<ide> // Driver contains information about the home directory and the list of active mounts that are created using this driver.
<ide> type Driver struct {
<del> home string
<del> sync.Mutex // Protects concurrent modification to active
<del> active map[string]*ActiveMount
<del> uidMaps []idtools.IDMap
<del> gidMaps []idtools.IDMap
<add> home string
<add> pathCacheLock sync.Mutex
<add> pathCache map[string]string
<add> uidMaps []idtools.IDMap
<add> gidMaps []idtools.IDMap
<ide> }
<ide>
<ide> var backingFs = "<unknown>"
<ide> func Init(home string, options []string, uidMaps, gidMaps []idtools.IDMap) (grap
<ide> }
<ide>
<ide> d := &Driver{
<del> home: home,
<del> active: make(map[string]*ActiveMount),
<del> uidMaps: uidMaps,
<del> gidMaps: gidMaps,
<add> home: home,
<add> pathCache: make(map[string]string),
<add> uidMaps: uidMaps,
<add> gidMaps: gidMaps,
<ide> }
<ide>
<ide> return NaiveDiffDriverWithApply(d, uidMaps, gidMaps), nil
<ide> func (d *Driver) Remove(id string) error {
<ide> if err := os.RemoveAll(d.dir(id)); err != nil && !os.IsNotExist(err) {
<ide> return err
<ide> }
<add> d.pathCacheLock.Lock()
<add> delete(d.pathCache, id)
<add> d.pathCacheLock.Unlock()
<ide> return nil
<ide> }
<ide>
<ide> // Get creates and mounts the required file system for the given id and returns the mount path.
<ide> func (d *Driver) Get(id string, mountLabel string) (string, error) {
<del> // Protect the d.active from concurrent access
<del> d.Lock()
<del> defer d.Unlock()
<del>
<del> mount := d.active[id]
<del> if mount != nil {
<del> mount.count++
<del> return mount.path, nil
<del> }
<del>
<del> mount = &ActiveMount{count: 1}
<del>
<ide> dir := d.dir(id)
<ide> if _, err := os.Stat(dir); err != nil {
<ide> return "", err
<ide> func (d *Driver) Get(id string, mountLabel string) (string, error) {
<ide> // If id has a root, just return it
<ide> rootDir := path.Join(dir, "root")
<ide> if _, err := os.Stat(rootDir); err == nil {
<del> mount.path = rootDir
<del> d.active[id] = mount
<del> return mount.path, nil
<add> d.pathCacheLock.Lock()
<add> d.pathCache[id] = rootDir
<add> d.pathCacheLock.Unlock()
<add> return rootDir, nil
<ide> }
<ide>
<ide> lowerID, err := ioutil.ReadFile(path.Join(dir, "lower-id"))
<ide> func (d *Driver) Get(id string, mountLabel string) (string, error) {
<ide> mergedDir := path.Join(dir, "merged")
<ide>
<ide> opts := fmt.Sprintf("lowerdir=%s,upperdir=%s,workdir=%s", lowerDir, upperDir, workDir)
<add>
<add> // if it's mounted already, just return
<add> if mounted, err := d.mounted(mergedDir); err != nil || mounted {
<add> return "", err
<add> }
<add>
<ide> if err := syscall.Mount("overlay", mergedDir, "overlay", 0, label.FormatMountLabel(opts, mountLabel)); err != nil {
<ide> return "", fmt.Errorf("error creating overlay mount to %s: %v", mergedDir, err)
<ide> }
<ide> func (d *Driver) Get(id string, mountLabel string) (string, error) {
<ide> if err := os.Chown(path.Join(workDir, "work"), rootUID, rootGID); err != nil {
<ide> return "", err
<ide> }
<del> mount.path = mergedDir
<del> mount.mounted = true
<del> d.active[id] = mount
<ide>
<del> return mount.path, nil
<add> d.pathCacheLock.Lock()
<add> d.pathCache[id] = mergedDir
<add> d.pathCacheLock.Unlock()
<add>
<add> return mergedDir, nil
<add>}
<add>
<add>func (d *Driver) mounted(dir string) (bool, error) {
<add> return graphdriver.Mounted(graphdriver.FsMagicOverlay, dir)
<ide> }
<ide>
<ide> // Put unmounts the mount path created for the give id.
<ide> func (d *Driver) Put(id string) error {
<del> // Protect the d.active from concurrent access
<del> d.Lock()
<del> defer d.Unlock()
<add> d.pathCacheLock.Lock()
<add> mountpoint, exists := d.pathCache[id]
<add> d.pathCacheLock.Unlock()
<ide>
<del> mount := d.active[id]
<del> if mount == nil {
<add> if !exists {
<ide> logrus.Debugf("Put on a non-mounted device %s", id)
<ide> // but it might be still here
<ide> if d.Exists(id) {
<del> mergedDir := path.Join(d.dir(id), "merged")
<del> err := syscall.Unmount(mergedDir, 0)
<del> if err != nil {
<del> logrus.Debugf("Failed to unmount %s overlay: %v", id, err)
<del> }
<add> mountpoint = path.Join(d.dir(id), "merged")
<ide> }
<del> return nil
<del> }
<ide>
<del> mount.count--
<del> if mount.count > 0 {
<del> return nil
<add> d.pathCacheLock.Lock()
<add> d.pathCache[id] = mountpoint
<add> d.pathCacheLock.Unlock()
<ide> }
<ide>
<del> defer delete(d.active, id)
<del> if mount.mounted {
<del> err := syscall.Unmount(mount.path, 0)
<del> if err != nil {
<add> if mounted, err := d.mounted(mountpoint); mounted || err != nil {
<add> if err = syscall.Unmount(mountpoint, 0); err != nil {
<ide> logrus.Debugf("Failed to unmount %s overlay: %v", id, err)
<ide> }
<ide> return err
<ide><path>daemon/graphdriver/windows/windows.go
<ide> import (
<ide> "path"
<ide> "path/filepath"
<ide> "strings"
<del> "sync"
<ide> "syscall"
<ide> "time"
<ide>
<ide> const (
<ide> type Driver struct {
<ide> // info stores the shim driver information
<ide> info hcsshim.DriverInfo
<del> // Mutex protects concurrent modification to active
<del> sync.Mutex
<del> // active stores references to the activated layers
<del> active map[string]int
<ide> }
<ide>
<ide> var _ graphdriver.DiffGetterDriver = &Driver{}
<ide> func InitFilter(home string, options []string, uidMaps, gidMaps []idtools.IDMap)
<ide> HomeDir: home,
<ide> Flavour: filterDriver,
<ide> },
<del> active: make(map[string]int),
<ide> }
<ide> return d, nil
<ide> }
<ide> func InitDiff(home string, options []string, uidMaps, gidMaps []idtools.IDMap) (
<ide> HomeDir: home,
<ide> Flavour: diffDriver,
<ide> },
<del> active: make(map[string]int),
<ide> }
<ide> return d, nil
<ide> }
<ide> func (d *Driver) Get(id, mountLabel string) (string, error) {
<ide> logrus.Debugf("WindowsGraphDriver Get() id %s mountLabel %s", id, mountLabel)
<ide> var dir string
<ide>
<del> d.Lock()
<del> defer d.Unlock()
<del>
<ide> rID, err := d.resolveID(id)
<ide> if err != nil {
<ide> return "", err
<ide> func (d *Driver) Get(id, mountLabel string) (string, error) {
<ide> return "", err
<ide> }
<ide>
<del> if d.active[rID] == 0 {
<del> if err := hcsshim.ActivateLayer(d.info, rID); err != nil {
<del> return "", err
<del> }
<del> if err := hcsshim.PrepareLayer(d.info, rID, layerChain); err != nil {
<del> if err2 := hcsshim.DeactivateLayer(d.info, rID); err2 != nil {
<del> logrus.Warnf("Failed to Deactivate %s: %s", id, err)
<del> }
<del> return "", err
<add> if err := hcsshim.ActivateLayer(d.info, rID); err != nil {
<add> return "", err
<add> }
<add> if err := hcsshim.PrepareLayer(d.info, rID, layerChain); err != nil {
<add> if err2 := hcsshim.DeactivateLayer(d.info, rID); err2 != nil {
<add> logrus.Warnf("Failed to Deactivate %s: %s", id, err)
<ide> }
<add> return "", err
<ide> }
<ide>
<ide> mountPath, err := hcsshim.GetLayerMountPath(d.info, rID)
<ide> func (d *Driver) Get(id, mountLabel string) (string, error) {
<ide> return "", err
<ide> }
<ide>
<del> d.active[rID]++
<del>
<ide> // If the layer has a mount path, use that. Otherwise, use the
<ide> // folder path.
<ide> if mountPath != "" {
<ide> func (d *Driver) Put(id string) error {
<ide> return err
<ide> }
<ide>
<del> d.Lock()
<del> defer d.Unlock()
<del>
<del> if d.active[rID] > 1 {
<del> d.active[rID]--
<del> } else if d.active[rID] == 1 {
<del> if err := hcsshim.UnprepareLayer(d.info, rID); err != nil {
<del> return err
<del> }
<del> if err := hcsshim.DeactivateLayer(d.info, rID); err != nil {
<del> return err
<del> }
<del> delete(d.active, rID)
<add> if err := hcsshim.UnprepareLayer(d.info, rID); err != nil {
<add> return err
<ide> }
<del>
<del> return nil
<add> return hcsshim.DeactivateLayer(d.info, rID)
<ide> }
<ide>
<ide> // Cleanup ensures the information the driver stores is properly removed.
<ide> func (d *Driver) Cleanup() error {
<ide>
<ide> // Diff produces an archive of the changes between the specified
<ide> // layer and its parent layer which may be "".
<add>// The layer should be mounted when calling this function
<ide> func (d *Driver) Diff(id, parent string) (_ archive.Archive, err error) {
<ide> rID, err := d.resolveID(id)
<ide> if err != nil {
<ide> return
<ide> }
<ide>
<del> // Getting the layer paths must be done outside of the lock.
<ide> layerChain, err := d.getLayerChain(rID)
<ide> if err != nil {
<ide> return
<ide> }
<ide>
<del> var undo func()
<del>
<del> d.Lock()
<del>
<del> // To support export, a layer must be activated but not prepared.
<del> if d.info.Flavour == filterDriver {
<del> if d.active[rID] == 0 {
<del> if err = hcsshim.ActivateLayer(d.info, rID); err != nil {
<del> d.Unlock()
<del> return
<del> }
<del> undo = func() {
<del> if err := hcsshim.DeactivateLayer(d.info, rID); err != nil {
<del> logrus.Warnf("Failed to Deactivate %s: %s", rID, err)
<del> }
<del> }
<del> } else {
<del> if err = hcsshim.UnprepareLayer(d.info, rID); err != nil {
<del> d.Unlock()
<del> return
<del> }
<del> undo = func() {
<del> if err := hcsshim.PrepareLayer(d.info, rID, layerChain); err != nil {
<del> logrus.Warnf("Failed to re-PrepareLayer %s: %s", rID, err)
<del> }
<del> }
<del> }
<add> // this is assuming that the layer is unmounted
<add> if err := hcsshim.UnprepareLayer(d.info, rID); err != nil {
<add> return nil, err
<ide> }
<del>
<del> d.Unlock()
<add> defer func() {
<add> if err := hcsshim.PrepareLayer(d.info, rID, layerChain); err != nil {
<add> logrus.Warnf("Failed to Deactivate %s: %s", rID, err)
<add> }
<add> }()
<ide>
<ide> arch, err := d.exportLayer(rID, layerChain)
<ide> if err != nil {
<del> undo()
<ide> return
<ide> }
<ide> return ioutils.NewReadCloserWrapper(arch, func() error {
<del> defer undo()
<ide> return arch.Close()
<ide> }), nil
<ide> }
<ide>
<ide> // Changes produces a list of changes between the specified layer
<ide> // and its parent layer. If parent is "", then all changes will be ADD changes.
<add>// The layer should be mounted when calling this function
<ide> func (d *Driver) Changes(id, parent string) ([]archive.Change, error) {
<ide> rID, err := d.resolveID(id)
<ide> if err != nil {
<ide> func (d *Driver) Changes(id, parent string) ([]archive.Change, error) {
<ide> return nil, err
<ide> }
<ide>
<del> d.Lock()
<del> if d.info.Flavour == filterDriver {
<del> if d.active[rID] == 0 {
<del> if err = hcsshim.ActivateLayer(d.info, rID); err != nil {
<del> d.Unlock()
<del> return nil, err
<del> }
<del> defer func() {
<del> if err := hcsshim.DeactivateLayer(d.info, rID); err != nil {
<del> logrus.Warnf("Failed to Deactivate %s: %s", rID, err)
<del> }
<del> }()
<del> } else {
<del> if err = hcsshim.UnprepareLayer(d.info, rID); err != nil {
<del> d.Unlock()
<del> return nil, err
<del> }
<del> defer func() {
<del> if err := hcsshim.PrepareLayer(d.info, rID, parentChain); err != nil {
<del> logrus.Warnf("Failed to re-PrepareLayer %s: %s", rID, err)
<del> }
<del> }()
<del> }
<add> // this is assuming that the layer is unmounted
<add> if err := hcsshim.UnprepareLayer(d.info, rID); err != nil {
<add> return nil, err
<ide> }
<del> d.Unlock()
<add> defer func() {
<add> if err := hcsshim.PrepareLayer(d.info, rID, parentChain); err != nil {
<add> logrus.Warnf("Failed to Deactivate %s: %s", rID, err)
<add> }
<add> }()
<ide>
<ide> r, err := hcsshim.NewLayerReader(d.info, id, parentChain)
<ide> if err != nil {
<ide> func (d *Driver) Changes(id, parent string) ([]archive.Change, error) {
<ide> // ApplyDiff extracts the changeset from the given diff into the
<ide> // layer with the specified id and parent, returning the size of the
<ide> // new layer in bytes.
<add>// The layer should not be mounted when calling this function
<ide> func (d *Driver) ApplyDiff(id, parent string, diff archive.Reader) (size int64, err error) {
<ide> rPId, err := d.resolveID(parent)
<ide> if err != nil {
<ide><path>daemon/graphdriver/zfs/zfs.go
<ide> import (
<ide> "github.com/opencontainers/runc/libcontainer/label"
<ide> )
<ide>
<del>type activeMount struct {
<del> count int
<del> path string
<del> mounted bool
<del>}
<del>
<ide> type zfsOptions struct {
<ide> fsName string
<ide> mountPath string
<ide> func Init(base string, opt []string, uidMaps, gidMaps []idtools.IDMap) (graphdri
<ide> dataset: rootDataset,
<ide> options: options,
<ide> filesystemsCache: filesystemsCache,
<del> active: make(map[string]*activeMount),
<ide> uidMaps: uidMaps,
<ide> gidMaps: gidMaps,
<ide> }
<ide> type Driver struct {
<ide> options zfsOptions
<ide> sync.Mutex // protects filesystem cache against concurrent access
<ide> filesystemsCache map[string]bool
<del> active map[string]*activeMount
<ide> uidMaps []idtools.IDMap
<ide> gidMaps []idtools.IDMap
<ide> }
<ide> func (d *Driver) Remove(id string) error {
<ide>
<ide> // Get returns the mountpoint for the given id after creating the target directories if necessary.
<ide> func (d *Driver) Get(id, mountLabel string) (string, error) {
<del> d.Lock()
<del> defer d.Unlock()
<del>
<del> mnt := d.active[id]
<del> if mnt != nil {
<del> mnt.count++
<del> return mnt.path, nil
<del> }
<del>
<del> mnt = &activeMount{count: 1}
<del>
<ide> mountpoint := d.mountPath(id)
<ide> filesystem := d.zfsPath(id)
<ide> options := label.FormatMountLabel("", mountLabel)
<ide> func (d *Driver) Get(id, mountLabel string) (string, error) {
<ide> if err := os.Chown(mountpoint, rootUID, rootGID); err != nil {
<ide> return "", fmt.Errorf("error modifying zfs mountpoint (%s) directory ownership: %v", mountpoint, err)
<ide> }
<del> mnt.path = mountpoint
<del> mnt.mounted = true
<del> d.active[id] = mnt
<ide>
<ide> return mountpoint, nil
<ide> }
<ide>
<ide> // Put removes the existing mountpoint for the given id if it exists.
<ide> func (d *Driver) Put(id string) error {
<del> d.Lock()
<del> defer d.Unlock()
<del>
<del> mnt := d.active[id]
<del> if mnt == nil {
<del> logrus.Debugf("[zfs] Put on a non-mounted device %s", id)
<del> // but it might be still here
<del> if d.Exists(id) {
<del> err := mount.Unmount(d.mountPath(id))
<del> if err != nil {
<del> logrus.Debugf("[zfs] Failed to unmount %s zfs fs: %v", id, err)
<del> }
<del> }
<del> return nil
<del> }
<del>
<del> mnt.count--
<del> if mnt.count > 0 {
<del> return nil
<add> mountpoint := d.mountPath(id)
<add> mounted, err := graphdriver.Mounted(graphdriver.FsMagicZfs, mountpoint)
<add> if err != nil || !mounted {
<add> return err
<ide> }
<ide>
<del> defer delete(d.active, id)
<del> if mnt.mounted {
<del> logrus.Debugf(`[zfs] unmount("%s")`, mnt.path)
<add> logrus.Debugf(`[zfs] unmount("%s")`, mountpoint)
<ide>
<del> if err := mount.Unmount(mnt.path); err != nil {
<del> return fmt.Errorf("error unmounting to %s: %v", mnt.path, err)
<del> }
<add> if err := mount.Unmount(mountpoint); err != nil {
<add> return fmt.Errorf("error unmounting to %s: %v", mountpoint, err)
<ide> }
<ide> return nil
<ide> }
<ide>
<ide> // Exists checks to see if the cache entry exists for the given id.
<ide> func (d *Driver) Exists(id string) bool {
<add> d.Lock()
<add> defer d.Unlock()
<ide> return d.filesystemsCache[d.zfsPath(id)] == true
<ide> }
<ide><path>integration-cli/benchmark_test.go
<add>package main
<add>
<add>import (
<add> "fmt"
<add> "io/ioutil"
<add> "os"
<add> "runtime"
<add> "strings"
<add> "sync"
<add>
<add> "github.com/docker/docker/pkg/integration/checker"
<add> "github.com/go-check/check"
<add>)
<add>
<add>func (s *DockerSuite) BenchmarkConcurrentContainerActions(c *check.C) {
<add> maxConcurrency := runtime.GOMAXPROCS(0)
<add> numIterations := c.N
<add> outerGroup := &sync.WaitGroup{}
<add> outerGroup.Add(maxConcurrency)
<add> chErr := make(chan error, numIterations*2*maxConcurrency)
<add>
<add> for i := 0; i < maxConcurrency; i++ {
<add> go func() {
<add> defer outerGroup.Done()
<add> innerGroup := &sync.WaitGroup{}
<add> innerGroup.Add(2)
<add>
<add> go func() {
<add> defer innerGroup.Done()
<add> for i := 0; i < numIterations; i++ {
<add> args := []string{"run", "-d", defaultSleepImage}
<add> args = append(args, defaultSleepCommand...)
<add> out, _, err := dockerCmdWithError(args...)
<add> if err != nil {
<add> chErr <- fmt.Errorf(out)
<add> return
<add> }
<add>
<add> id := strings.TrimSpace(out)
<add> tmpDir, err := ioutil.TempDir("", "docker-concurrent-test-"+id)
<add> if err != nil {
<add> chErr <- err
<add> return
<add> }
<add> defer os.RemoveAll(tmpDir)
<add> out, _, err = dockerCmdWithError("cp", id+":/tmp", tmpDir)
<add> if err != nil {
<add> chErr <- fmt.Errorf(out)
<add> return
<add> }
<add>
<add> out, _, err = dockerCmdWithError("kill", id)
<add> if err != nil {
<add> chErr <- fmt.Errorf(out)
<add> }
<add>
<add> out, _, err = dockerCmdWithError("start", id)
<add> if err != nil {
<add> chErr <- fmt.Errorf(out)
<add> }
<add>
<add> out, _, err = dockerCmdWithError("kill", id)
<add> if err != nil {
<add> chErr <- fmt.Errorf(out)
<add> }
<add>
<add> // don't do an rm -f here since it can potentially ignore errors from the graphdriver
<add> out, _, err = dockerCmdWithError("rm", id)
<add> if err != nil {
<add> chErr <- fmt.Errorf(out)
<add> }
<add> }
<add> }()
<add>
<add> go func() {
<add> defer innerGroup.Done()
<add> for i := 0; i < numIterations; i++ {
<add> out, _, err := dockerCmdWithError("ps")
<add> if err != nil {
<add> chErr <- fmt.Errorf(out)
<add> }
<add> }
<add> }()
<add>
<add> innerGroup.Wait()
<add> }()
<add> }
<add>
<add> outerGroup.Wait()
<add> close(chErr)
<add>
<add> for err := range chErr {
<add> c.Assert(err, checker.IsNil)
<add> }
<add>}
<ide><path>layer/layer.go
<ide> var (
<ide> // to be created which would result in a layer depth
<ide> // greater than the 125 max.
<ide> ErrMaxDepthExceeded = errors.New("max depth exceeded")
<add>
<add> // ErrNotSupported is used when the action is not supppoted
<add> // on the current platform
<add> ErrNotSupported = errors.New("not support on this platform")
<ide> )
<ide>
<ide> // ChainID is the content-addressable ID of a layer.
<ide><path>layer/mounted_layer.go
<ide> type mountedLayer struct {
<ide> mountID string
<ide> initID string
<ide> parent *roLayer
<add> path string
<ide> layerStore *layerStore
<ide>
<ide> references map[RWLayer]*referencedRWLayer
<ide> func (rl *referencedRWLayer) Mount(mountLabel string) (string, error) {
<ide> return "", ErrLayerNotRetained
<ide> }
<ide>
<del> rl.activityCount++
<del> return rl.mountedLayer.Mount(mountLabel)
<add> if rl.activityCount > 0 {
<add> rl.activityCount++
<add> return rl.path, nil
<add> }
<add>
<add> m, err := rl.mountedLayer.Mount(mountLabel)
<add> if err == nil {
<add> rl.activityCount++
<add> rl.path = m
<add> }
<add> return m, err
<ide> }
<ide>
<add>// Unmount decrements the activity count and unmounts the underlying layer
<add>// Callers should only call `Unmount` once per call to `Mount`, even on error.
<ide> func (rl *referencedRWLayer) Unmount() error {
<ide> rl.activityL.Lock()
<ide> defer rl.activityL.Unlock()
<ide> func (rl *referencedRWLayer) Unmount() error {
<ide> if rl.activityCount == -1 {
<ide> return ErrLayerNotRetained
<ide> }
<add>
<ide> rl.activityCount--
<add> if rl.activityCount > 0 {
<add> return nil
<add> }
<ide>
<ide> return rl.mountedLayer.Unmount()
<ide> } | 14 |
Text | Text | fix typo and logic bug in handleremove | c5cc145538e9becc4fc442629d5957f9cc0d451b | <ide><path>docs/docs/09-addons.md
<ide> var TodoList = React.createClass({
<ide> },
<ide> handleRemove: function(i) {
<ide> var newItems = this.state.items;
<del> newItems.splice(i, 0)
<add> newItems.splice(i, 1)
<ide> this.setState({items: newItems});
<ide> },
<ide> render: function() {
<ide> var items = this.state.items.map(function(item, i) {
<ide> return (
<ide> <div key={i} onClick={this.handleRemove.bind(this, i)}>
<del> {item}}
<add> {item}
<ide> </div>
<ide> );
<ide> }.bind(this)); | 1 |
PHP | PHP | integrate plugin hooks in http & routing | e5322b050f8a61485930cc3dfa83d8b173034ce9 | <ide><path>src/Http/BaseApplication.php
<ide> abstract class BaseApplication implements
<ide> * Constructor
<ide> *
<ide> * @param string $configDir The directory the bootstrap configuration is held in.
<del> * @param string|null $pluginRegistry Plugin Registry Object
<ide> */
<del> public function __construct($configDir, $pluginRegistry = null)
<add> public function __construct($configDir)
<ide> {
<ide> $this->configDir = $configDir;
<ide> $this->plugins = new PluginCollection();
<ide> public function addPlugin($name, array $config = [])
<ide> public function bootstrap()
<ide> {
<ide> require_once $this->configDir . '/bootstrap.php';
<del>
<del> $this->pluginRegistry()->bootstrap();
<ide> }
<ide>
<ide> /**
<ide> public function routes($routes)
<ide> public function pluginRoutes($routes)
<ide> {
<ide> foreach ($this->plugins->with('routes') as $plugin) {
<del> $routes = $plugin->routes($routes);
<add> $plugin->routes($routes);
<ide> }
<ide>
<ide> return $routes;
<ide> public function pluginRoutes($routes)
<ide> */
<ide> public function console($commands)
<ide> {
<del> $commands->addMany($commands->autoDiscover());
<del>
<del> return $this->pluginRegistry()->console($commands);
<add> return $commands->addMany($commands->autoDiscover());
<ide> }
<ide>
<ide> /**
<ide><path>src/Http/Server.php
<ide> namespace Cake\Http;
<ide>
<ide> use Cake\Core\HttpApplicationInterface;
<add>use Cake\Core\PluginApplicationInterface;
<ide> use Cake\Event\EventDispatcherTrait;
<ide> use Psr\Http\Message\ResponseInterface;
<ide> use Psr\Http\Message\ServerRequestInterface;
<ide> public function __construct(HttpApplicationInterface $app)
<ide> public function run(ServerRequestInterface $request = null, ResponseInterface $response = null)
<ide> {
<ide> $this->app->bootstrap();
<add> $hasPlugins = $this->app instanceof PluginApplicationInterface;
<add> if ($hasPlugins) {
<add> $this->app->pluginBootstrap();
<add> }
<ide>
<ide> $response = $response ?: new Response();
<ide> $request = $request ?: ServerRequestFactory::fromGlobals();
<ide>
<ide> $middleware = $this->app->middleware(new MiddlewareQueue());
<add> if ($hasPlugins) {
<add> $middleware = $this->app->pluginMiddleware($middleware);
<add> }
<add>
<ide> if (!($middleware instanceof MiddlewareQueue)) {
<ide> throw new RuntimeException('The application `middleware` method did not return a middleware queue.');
<ide> }
<ide><path>src/Routing/Middleware/RoutingMiddleware.php
<ide> */
<ide> namespace Cake\Routing\Middleware;
<ide>
<add>use Cake\Core\PluginApplicationInterface;
<ide> use Cake\Http\BaseApplication;
<ide> use Cake\Http\MiddlewareQueue;
<ide> use Cake\Http\Runner;
<ide> public function __construct(BaseApplication $app = null)
<ide> */
<ide> protected function loadRoutes()
<ide> {
<del> if ($this->app) {
<del> $builder = Router::createRouteBuilder('/');
<del> $this->app->routes($builder);
<add> if (!$this->app) {
<add> return;
<add> }
<add> $builder = Router::createRouteBuilder('/');
<add> $this->app->routes($builder);
<add> if ($this->app instanceof PluginApplicationInterface) {
<add> $this->app->pluginRoutes($builder);
<ide> }
<ide> }
<ide>
<ide><path>tests/TestCase/Http/ServerTest.php
<ide>
<ide> use Cake\Event\Event;
<ide> use Cake\Http\CallbackStream;
<add>use Cake\Http\MiddlewareQueue;
<ide> use Cake\Http\Server;
<ide> use Cake\TestSuite\TestCase;
<ide> use TestApp\Http\BadResponseApplication;
<ide> public function testRunWithRequestAndResponse()
<ide> );
<ide> }
<ide>
<add> /**
<add> * test run calling plugin hooks
<add> *
<add> * @return void
<add> */
<add> public function testRunCallingPluginHooks()
<add> {
<add> $response = new Response('php://memory', 200, ['X-testing' => 'source header']);
<add> $request = ServerRequestFactory::fromGlobals();
<add> $request = $request->withHeader('X-pass', 'request header');
<add>
<add> $app = $this->getMockBuilder(MiddlewareApplication::class)
<add> ->setMethods(['pluginBootstrap', 'pluginMiddleware'])
<add> ->setConstructorArgs([$this->config])
<add> ->getMock();
<add> $app->expects($this->once())
<add> ->method('pluginBootstrap');
<add> $app->expects($this->once())
<add> ->method('pluginMiddleware')
<add> ->with($this->isInstanceOf(MiddlewareQueue::class))
<add> ->will($this->returnCallback(function ($middleware) {
<add> return $middleware;
<add> }));
<add>
<add> $server = new Server($app);
<add> $res = $server->run($request, $response);
<add> $this->assertEquals(
<add> 'source header',
<add> $res->getHeaderLine('X-testing'),
<add> 'Input response is carried through out middleware'
<add> );
<add> $this->assertEquals(
<add> 'request header',
<add> $res->getHeaderLine('X-pass'),
<add> 'Request is used in middleware'
<add> );
<add> }
<add>
<ide> /**
<ide> * test run building a request from globals.
<ide> *
<ide><path>tests/TestCase/Routing/Middleware/RoutingMiddlewareTest.php
<ide> namespace Cake\Test\TestCase\Routing\Middleware;
<ide>
<ide> use Cake\Routing\Middleware\RoutingMiddleware;
<add>use Cake\Routing\RouteBuilder;
<ide> use Cake\Routing\Router;
<ide> use Cake\TestSuite\TestCase;
<ide> use TestApp\Application;
<ide> public function testRoutesHookInvokedOnApp()
<ide> $middleware($request, $response, $next);
<ide> }
<ide>
<add> /**
<add> * Test that pluginRoutes hook is called
<add> *
<add> * @return void
<add> */
<add> public function testRoutesHookCallsPluginHook()
<add> {
<add> Router::reload();
<add> $this->assertFalse(Router::$initialized, 'Router precondition failed');
<add>
<add> $request = ServerRequestFactory::fromGlobals(['REQUEST_URI' => '/app/articles']);
<add> $response = new Response();
<add> $next = function ($req, $res) {
<add> return $res;
<add> };
<add> $app = $this->getMockBuilder(Application::class)
<add> ->setMethods(['pluginRoutes'])
<add> ->setConstructorArgs([CONFIG])
<add> ->getMock();
<add> $app->expects($this->once())
<add> ->method('pluginRoutes')
<add> ->with($this->isInstanceOf(RouteBuilder::class));
<add> $middleware = new RoutingMiddleware($app);
<add> $middleware($request, $response, $next);
<add> }
<add>
<ide> /**
<ide> * Test that routing is not applied if a controller exists already
<ide> * | 5 |
PHP | PHP | use a boolean option instead of yes/no | 9f4a0c4f0f2c9b8c70909942c7d5d07fb57f0d97 | <ide><path>src/Shell/Task/ExtractTask.php
<ide> public function main()
<ide> $this->_merge = strtolower($response) === 'y';
<ide> }
<ide>
<del> if (isset($this->params['relative-paths'])) {
<del> $this->_relativePaths = !(strtolower($this->params['relative-paths']) === 'no');
<del> }
<add> $this->_relativePaths = $this->param('relative-paths');
<ide>
<ide> if (empty($this->_files)) {
<ide> $this->_searchFiles();
<ide> public function getOptionParser()
<ide> 'choices' => ['yes', 'no']
<ide> ])->addOption('relative-paths', [
<ide> 'help' => 'Use relative paths in the .pot file',
<del> 'choices' => ['yes', 'no']
<add> 'boolean' => true,
<add> 'default' => false,
<ide> ])->addOption('output', [
<ide> 'help' => 'Full path to output directory.'
<ide> ])->addOption('files', [ | 1 |
Javascript | Javascript | avoid .valueof to close | 2e948e0d91360e4763594854be84347737e4b1f6 | <ide><path>packages/react-reconciler/src/ReactChildFiber.new.js
<ide> function coerceRef(
<ide>
<ide> function throwOnInvalidObjectType(returnFiber: Fiber, newChild: Object) {
<ide> if (returnFiber.type !== 'textarea') {
<add> const childString = Object.prototype.toString.call(newChild);
<ide> invariant(
<ide> false,
<ide> 'Objects are not valid as a React child (found: %s). ' +
<ide> 'If you meant to render a collection of children, use an array ' +
<ide> 'instead.',
<del> Object.prototype.toString.call(newChild) === '[object Object]'
<add> childString === '[object Object]'
<ide> ? 'object with keys {' + Object.keys(newChild).join(', ') + '}'
<del> : newChild,
<add> : childString,
<ide> );
<ide> }
<ide> }
<ide><path>packages/react-reconciler/src/ReactChildFiber.old.js
<ide> function coerceRef(
<ide>
<ide> function throwOnInvalidObjectType(returnFiber: Fiber, newChild: Object) {
<ide> if (returnFiber.type !== 'textarea') {
<add> const childString = Object.prototype.toString.call(newChild);
<ide> invariant(
<ide> false,
<ide> 'Objects are not valid as a React child (found: %s). ' +
<ide> 'If you meant to render a collection of children, use an array ' +
<ide> 'instead.',
<del> Object.prototype.toString.call(newChild) === '[object Object]'
<add> childString === '[object Object]'
<ide> ? 'object with keys {' + Object.keys(newChild).join(', ') + '}'
<del> : newChild,
<add> : childString,
<ide> );
<ide> }
<ide> } | 2 |
Javascript | Javascript | add userselect style equivalent to selectable | fc42d5bbb9906c37c2f62d26c46f6e3191cccd01 | <ide><path>Libraries/Components/View/ReactNativeStyleAttributes.js
<ide> const ReactNativeStyleAttributes: {[string]: AnyAttributeType, ...} = {
<ide> textShadowOffset: true,
<ide> textShadowRadius: true,
<ide> textTransform: true,
<add> userSelect: true,
<ide> writingDirection: true,
<ide>
<ide> /**
<ide><path>Libraries/StyleSheet/StyleSheetTypes.js
<ide> export type ____TextStyle_InternalCore = $ReadOnly<{
<ide> textDecorationStyle?: 'solid' | 'double' | 'dotted' | 'dashed',
<ide> textDecorationColor?: ____ColorValue_Internal,
<ide> textTransform?: 'none' | 'capitalize' | 'uppercase' | 'lowercase',
<add> userSelect?: 'auto' | 'text' | 'none' | 'contain' | 'all',
<ide> writingDirection?: 'auto' | 'ltr' | 'rtl',
<ide> }>;
<ide>
<ide><path>Libraries/Text/Text.js
<ide> import {NativeText, NativeVirtualText} from './TextNativeComponent';
<ide> import {type TextProps} from './TextProps';
<ide> import * as React from 'react';
<ide> import {useContext, useMemo, useState} from 'react';
<add>import flattenStyle from '../StyleSheet/flattenStyle';
<ide>
<ide> /**
<ide> * Text is the fundamental component for displaying text.
<ide> const Text: React.AbstractComponent<
<ide> ? null
<ide> : processColor(restProps.selectionColor);
<ide>
<del> let style = restProps.style;
<add> let style = flattenStyle(restProps.style);
<add>
<add> let _selectable = restProps.selectable;
<add> if (style?.userSelect != null) {
<add> _selectable = userSelectToSelectableMap[style.userSelect];
<add> }
<add>
<ide> if (__DEV__) {
<ide> if (PressabilityDebug.isEnabled() && onPress != null) {
<ide> style = StyleSheet.compose(restProps.style, {
<ide> const Text: React.AbstractComponent<
<ide> {...eventHandlersForText}
<ide> isHighlighted={isHighlighted}
<ide> isPressable={isPressable}
<add> selectable={_selectable}
<ide> numberOfLines={numberOfLines}
<ide> selectionColor={selectionColor}
<ide> style={style}
<ide> const Text: React.AbstractComponent<
<ide> {...restProps}
<ide> {...eventHandlersForText}
<ide> disabled={_disabled}
<add> selectable={_selectable}
<ide> accessible={_accessible}
<ide> accessibilityState={_accessibilityState}
<ide> allowFontScaling={allowFontScaling !== false}
<ide> function useLazyInitialization(newValue: boolean): boolean {
<ide> return oldValue;
<ide> }
<ide>
<add>const userSelectToSelectableMap = {
<add> auto: true,
<add> text: true,
<add> none: false,
<add> contain: true,
<add> all: true,
<add>};
<add>
<ide> module.exports = Text;
<ide><path>packages/rn-tester/js/examples/Text/TextExample.android.js
<ide> exports.examples = [
<ide> return <TextBaseLineLayoutExample />;
<ide> },
<ide> },
<add> {
<add> title: 'Selectable Text',
<add> render: function (): React.Node {
<add> return (
<add> <View>
<add> <Text style={{userSelect: 'auto'}}>Text element is selectable</Text>
<add> </View>
<add> );
<add> },
<add> },
<ide> ];
<ide><path>packages/rn-tester/js/examples/Text/TextExample.ios.js
<ide> exports.examples = [
<ide> );
<ide> },
<ide> },
<add> {
<add> title: 'Selectable Text',
<add> render: function (): React.Node {
<add> return (
<add> <View>
<add> <Text style={{userSelect: 'auto'}}>Text element is selectable</Text>
<add> </View>
<add> );
<add> },
<add> },
<ide> ]; | 5 |
Java | Java | fix failing test after previous commit | 3895d21b7ddc5ce378d31ca4befdc83450e16521 | <ide><path>spring-websocket/src/test/java/org/springframework/web/socket/messaging/WebSocketStompClientTests.java
<ide> import org.springframework.web.socket.WebSocketHandler;
<ide> import org.springframework.web.socket.WebSocketSession;
<ide> import org.springframework.web.socket.client.WebSocketClient;
<add>import org.springframework.web.socket.handler.WebSocketHandlerDecorator;
<ide>
<ide> import static org.assertj.core.api.Assertions.assertThat;
<ide> import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
<ide> private WebSocketHandler connect() {
<ide>
<ide> @SuppressWarnings("unchecked")
<ide> private TcpConnection<byte[]> getTcpConnection() throws Exception {
<del> WebSocketHandler webSocketHandler = connect();
<del> webSocketHandler.afterConnectionEstablished(this.webSocketSession);
<del> return (TcpConnection<byte[]>) webSocketHandler;
<add> WebSocketHandler handler = connect();
<add> handler.afterConnectionEstablished(this.webSocketSession);
<add> if (handler instanceof WebSocketHandlerDecorator) {
<add> handler = ((WebSocketHandlerDecorator) handler).getLastHandler();
<add> }
<add> return (TcpConnection<byte[]>) handler;
<ide> }
<ide>
<ide> private void testInactivityTaskScheduling(Runnable runnable, long delay, long sleepTime) | 1 |
Javascript | Javascript | remove trailing slash from os.tmpdir() | b57cc51d8d3f4ad279591ae8fa6584ee22773b97 | <ide><path>lib/os.js
<ide> exports.platform = function() {
<ide> };
<ide>
<ide> exports.tmpdir = function() {
<add> var path;
<ide> if (isWindows) {
<del> return process.env.TEMP ||
<add> path = process.env.TEMP ||
<ide> process.env.TMP ||
<ide> (process.env.SystemRoot || process.env.windir) + '\\temp';
<ide> } else {
<del> return process.env.TMPDIR ||
<add> path = process.env.TMPDIR ||
<ide> process.env.TMP ||
<ide> process.env.TEMP ||
<ide> '/tmp';
<ide> }
<add> if (/[\\\/]$/.test(path))
<add> path = path.slice(0, -1);
<add> return path;
<ide> };
<ide>
<ide> exports.tmpDir = exports.tmpdir;
<ide><path>test/parallel/test-os.js
<ide> if (process.platform === 'win32') {
<ide> process.env.TMP = '';
<ide> var expected = (process.env.SystemRoot || process.env.windir) + '\\temp';
<ide> assert.equal(os.tmpdir(), expected);
<add> process.env.TEMP = '\\temp\\';
<add> assert.equal(os.tmpdir(), '\\temp');
<ide> } else {
<ide> assert.equal(os.tmpdir(), '/tmpdir');
<ide> process.env.TMPDIR = '';
<ide> if (process.platform === 'win32') {
<ide> assert.equal(os.tmpdir(), '/temp');
<ide> process.env.TEMP = '';
<ide> assert.equal(os.tmpdir(), '/tmp');
<add> process.env.TMPDIR = '/tmpdir/';
<add> assert.equal(os.tmpdir(), '/tmpdir');
<ide> }
<ide>
<ide> var endianness = os.endianness(); | 2 |
Go | Go | keep pause state when restoring container's status | 977c4046fd2147d7c04f4b513a94138013ca0dd6 | <ide><path>container/state.go
<ide> func (s *State) SetRunning(pid int, initial bool) {
<ide> s.ErrorMsg = ""
<ide> s.Running = true
<ide> s.Restarting = false
<del> s.Paused = false
<add> if initial {
<add> s.Paused = false
<add> }
<ide> s.ExitCodeValue = 0
<ide> s.Pid = pid
<ide> if initial { | 1 |
Ruby | Ruby | keep column defaults in type cast form | ed559d4b00fbd7c6f86e75fd2d18a40e16b98281 | <ide><path>activerecord/lib/active_record/connection_adapters/column.rb
<ide> def human_name
<ide> end
<ide>
<ide> def extract_default(default)
<del> type_cast_for_write(type_cast(default))
<add> type_cast(default)
<ide> end
<ide> end
<ide> end
<ide><path>activerecord/lib/active_record/core.rb
<ide> def relation #:nodoc:
<ide> # # Instantiates a single new object
<ide> # User.new(first_name: 'Jamie')
<ide> def initialize(attributes = nil, options = {})
<del> defaults = self.class.column_defaults.dup
<add> defaults = self.class.raw_column_defaults.dup
<ide> defaults.each { |k, v| defaults[k] = v.dup if v.duplicable? }
<ide>
<ide> @raw_attributes = defaults
<ide><path>activerecord/lib/active_record/model_schema.rb
<ide> def column_defaults
<ide> @column_defaults ||= Hash[columns.map { |c| [c.name, c.default] }]
<ide> end
<ide>
<add> # Returns a hash where the keys are the column names and the values
<add> # are the default values suitable for use in `@raw_attriubtes`
<add> def raw_column_defaults # :nodoc:
<add> @raw_column_defauts ||= Hash[column_defaults.map { |name, default|
<add> [name, columns_hash[name].type_cast_for_write(default)]
<add> }]
<add> end
<add>
<ide> # Returns an array of column names as strings.
<ide> def column_names
<ide> @column_names ||= columns.map { |column| column.name }
<ide> def reset_column_information
<ide>
<ide> @arel_engine = nil
<ide> @column_defaults = nil
<add> @raw_column_defauts = nil
<ide> @column_names = nil
<ide> @column_types = nil
<ide> @content_columns = nil
<ide><path>activerecord/lib/active_record/properties.rb
<ide> def clear_caches_calculated_from_columns
<ide> @columns_hash = nil
<ide> @column_types = nil
<ide> @column_defaults = nil
<add> @raw_column_defaults = nil
<ide> @column_names = nil
<ide> @content_columns = nil
<ide> end
<ide><path>activerecord/test/cases/dirty_test.rb
<ide> def test_datetime_attribute_doesnt_change_if_zone_is_modified_in_string
<ide> end
<ide> end
<ide>
<add> test "defaults with type that implements `type_cast_for_write`" do
<add> type = Class.new(ActiveRecord::Type::Value) do
<add> def type_cast(value)
<add> value.to_i
<add> end
<add>
<add> def type_cast_for_write(value)
<add> value.to_s
<add> end
<add>
<add> alias type_cast_for_database type_cast_for_write
<add> end
<add>
<add> model_class = Class.new(ActiveRecord::Base) do
<add> self.table_name = 'numeric_data'
<add> property :foo, type.new, default: 1
<add> end
<add>
<add> model = model_class.new
<add> assert_not model.foo_changed?
<add>
<add> model = model_class.new(foo: 1)
<add> assert_not model.foo_changed?
<add>
<add> model = model_class.new(foo: '1')
<add> assert_not model.foo_changed?
<add> end
<add>
<ide> private
<ide> def with_partial_writes(klass, on = true)
<ide> old = klass.partial_writes? | 5 |
Text | Text | add guides on writing tests involving promises | df16d20f7569f6538eb6558ea63c614e3b139abc | <ide><path>doc/guides/writing-tests.md
<ide> countdown.dec();
<ide> countdown.dec(); // The countdown callback will be invoked now.
<ide> ```
<ide>
<add>#### Testing promises
<add>
<add>When writing tests involving promises, either make sure that the
<add>`onFulfilled` or the `onRejected` handler is wrapped in
<add>`common.mustCall()` or `common.mustNotCall()` accordingly, or
<add>call `common.crashOnUnhandledRejection()` in the top level of the
<add>test to make sure that unhandled rejections would result in a test
<add>failure. For example:
<add>
<add>```javascript
<add>const common = require('../common');
<add>const assert = require('assert');
<add>const fs = require('fs').promises;
<add>
<add>// Use `common.crashOnUnhandledRejection()` to make sure unhandled rejections
<add>// will fail the test.
<add>common.crashOnUnhandledRejection();
<add>
<add>// Or, wrap the `onRejected` handler in `common.mustNotCall()`.
<add>fs.writeFile('test-file', 'test').catch(common.mustNotCall());
<add>
<add>// Or, wrap the `onFulfilled` handler in `common.mustCall()`.
<add>// If there are assertions in the `onFulfilled` handler, wrap
<add>// the next `onRejected` handler in `common.mustNotCall()`
<add>// to handle potential failures.
<add>fs.readFile('test-file').then(
<add> common.mustCall(
<add> (content) => assert.strictEqual(content.toString(), 'test2')
<add> ))
<add> .catch(common.mustNotCall());
<add>```
<ide>
<ide> ### Flags
<ide> | 1 |
Ruby | Ruby | convert `variant` to a keyword arg | c0c1441144aa5e477b3419b033e43c94adf7cc0c | <ide><path>actionview/lib/action_view/template.rb
<ide> def self.finalize_compiled_template_methods=(_)
<ide> attr_reader :source, :identifier, :handler, :original_encoding, :updated_at
<ide> attr_reader :variable, :format
<ide>
<del> def initialize(source, identifier, handler, format: nil, **details)
<add> def initialize(source, identifier, handler, format: nil, variant: nil, **details)
<ide> unless format
<ide> ActiveSupport::Deprecation.warn "ActionView::Template#initialize requires a format parameter"
<ide> format = :html
<ide> def initialize(source, identifier, handler, format: nil, **details)
<ide>
<ide> @updated_at = details[:updated_at] || Time.now
<ide> @format = format
<del> @variants = [details[:variant]]
<add> @variants = [variant]
<ide> @compile_mutex = Mutex.new
<ide> end
<ide> | 1 |
PHP | PHP | add test for saveassociated and expression objects | 016c3aed44f890b8ff605b24a4392c4acd3464fa | <ide><path>lib/Cake/Test/Case/Model/ModelWriteTest.php
<ide> public function testSaveAssociatedEmptyData() {
<ide> $this->assertFalse($result);
<ide> }
<ide>
<add>/**
<add> * Test that saveAssociated will accept expression object values when saving.
<add> *
<add> * @return void
<add> */
<add> public function testSaveAssociatedExpressionObjects() {
<add> $this->loadFixtures('Post', 'Author', 'Comment', 'Attachment', 'Article', 'User');
<add> $TestModel = new Post();
<add> $db = $TestModel->getDataSource();
<add>
<add> $TestModel->saveAssociated(array(
<add> 'Post' => array(
<add> 'title' => $db->expression('(SELECT "Post with Author")'),
<add> 'body' => 'This post will be saved with an author'
<add> ),
<add> 'Author' => array(
<add> 'user' => 'bob',
<add> 'password' => '5f4dcc3b5aa765d61d8327deb882cf90'
<add> )));
<add>
<add> $result = $TestModel->find('first', array(
<add> 'order' => array('Post.id ' => 'DESC')
<add> ));
<add> $this->assertEquals('Post with Author', $result['Post']['title']);
<add> }
<add>
<ide> /**
<ide> * testUpdateWithCalculation method
<ide> * | 1 |
Go | Go | avoid ab-ba deadlock | 2ffef1b7eb618162673c6ffabccb9ca57c7dfce3 | <ide><path>runtime/graphdriver/devmapper/deviceset.go
<ide> type DevInfo struct {
<ide> // sometimes release that lock while sleeping. In that case
<ide> // this per-device lock is still held, protecting against
<ide> // other accesses to the device that we're doing the wait on.
<add> //
<add> // WARNING: In order to avoid AB-BA deadlocks when releasing
<add> // the global lock while holding the per-device locks all
<add> // device locks must be aquired *before* the device lock, and
<add> // multiple device locks should be aquired parent before child.
<ide> lock sync.Mutex `json:"-"`
<ide> }
<ide>
<ide> func (devices *DeviceSet) initDevmapper(doInit bool) error {
<ide> }
<ide>
<ide> func (devices *DeviceSet) AddDevice(hash, baseHash string) error {
<del> devices.Lock()
<del> defer devices.Unlock()
<del>
<del> if info, _ := devices.lookupDevice(hash); info != nil {
<del> return fmt.Errorf("device %s already exists", hash)
<del> }
<del>
<ide> baseInfo, err := devices.lookupDevice(baseHash)
<ide> if err != nil {
<ide> return err
<ide> func (devices *DeviceSet) AddDevice(hash, baseHash string) error {
<ide> baseInfo.lock.Lock()
<ide> defer baseInfo.lock.Unlock()
<ide>
<add> devices.Lock()
<add> defer devices.Unlock()
<add>
<add> if info, _ := devices.lookupDevice(hash); info != nil {
<add> return fmt.Errorf("device %s already exists", hash)
<add> }
<add>
<ide> deviceId := devices.allocateDeviceId()
<ide>
<ide> if err := devices.createSnapDevice(devices.getPoolDevName(), deviceId, baseInfo.Name(), baseInfo.DeviceId); err != nil {
<ide> func (devices *DeviceSet) deleteDevice(info *DevInfo) error {
<ide> }
<ide>
<ide> func (devices *DeviceSet) DeleteDevice(hash string) error {
<del> devices.Lock()
<del> defer devices.Unlock()
<del>
<ide> info, err := devices.lookupDevice(hash)
<ide> if err != nil {
<ide> return err
<ide> func (devices *DeviceSet) DeleteDevice(hash string) error {
<ide> info.lock.Lock()
<ide> defer info.lock.Unlock()
<ide>
<add> devices.Lock()
<add> defer devices.Unlock()
<add>
<ide> return devices.deleteDevice(info)
<ide> }
<ide>
<ide> func (devices *DeviceSet) waitClose(info *DevInfo) error {
<ide> }
<ide>
<ide> func (devices *DeviceSet) Shutdown() error {
<del> devices.Lock()
<del> defer devices.Unlock()
<ide>
<ide> utils.Debugf("[deviceset %s] shutdown()", devices.devicePrefix)
<ide> utils.Debugf("[devmapper] Shutting down DeviceSet: %s", devices.root)
<ide> func (devices *DeviceSet) Shutdown() error {
<ide> utils.Debugf("Shutdown unmounting %s, error: %s\n", info.mountPath, err)
<ide> }
<ide>
<add> devices.Lock()
<ide> if err := devices.deactivateDevice(info); err != nil {
<ide> utils.Debugf("Shutdown deactivate %s , error: %s\n", info.Hash, err)
<ide> }
<add> devices.Unlock()
<ide> }
<ide> info.lock.Unlock()
<ide> }
<ide>
<ide> info, _ := devices.lookupDevice("")
<ide> if info != nil {
<add> info.lock.Lock()
<add> devices.Lock()
<ide> if err := devices.deactivateDevice(info); err != nil {
<ide> utils.Debugf("Shutdown deactivate base , error: %s\n", err)
<ide> }
<add> devices.Unlock()
<add> info.lock.Unlock()
<ide> }
<ide>
<add> devices.Lock()
<ide> if err := devices.deactivatePool(); err != nil {
<ide> utils.Debugf("Shutdown deactivate pool , error: %s\n", err)
<ide> }
<add> devices.Unlock()
<ide>
<ide> return nil
<ide> }
<ide>
<ide> func (devices *DeviceSet) MountDevice(hash, path string, mountLabel string) error {
<del> devices.Lock()
<del> defer devices.Unlock()
<del>
<ide> info, err := devices.lookupDevice(hash)
<ide> if err != nil {
<ide> return err
<ide> func (devices *DeviceSet) MountDevice(hash, path string, mountLabel string) erro
<ide> info.lock.Lock()
<ide> defer info.lock.Unlock()
<ide>
<add> devices.Lock()
<add> defer devices.Unlock()
<add>
<ide> if info.mountCount > 0 {
<ide> if path != info.mountPath {
<ide> return fmt.Errorf("Trying to mount devmapper device in multple places (%s, %s)", info.mountPath, path)
<ide> func (devices *DeviceSet) MountDevice(hash, path string, mountLabel string) erro
<ide> func (devices *DeviceSet) UnmountDevice(hash string, mode UnmountMode) error {
<ide> utils.Debugf("[devmapper] UnmountDevice(hash=%s, mode=%d)", hash, mode)
<ide> defer utils.Debugf("[devmapper] UnmountDevice END")
<del> devices.Lock()
<del> defer devices.Unlock()
<ide>
<ide> info, err := devices.lookupDevice(hash)
<ide> if err != nil {
<ide> func (devices *DeviceSet) UnmountDevice(hash string, mode UnmountMode) error {
<ide> info.lock.Lock()
<ide> defer info.lock.Unlock()
<ide>
<add> devices.Lock()
<add> defer devices.Unlock()
<add>
<ide> if mode == UnmountFloat {
<ide> if info.floating {
<ide> return fmt.Errorf("UnmountDevice: can't float floating reference %s\n", hash)
<ide> func (devices *DeviceSet) HasInitializedDevice(hash string) bool {
<ide> }
<ide>
<ide> func (devices *DeviceSet) HasActivatedDevice(hash string) bool {
<del> devices.Lock()
<del> defer devices.Unlock()
<del>
<ide> info, _ := devices.lookupDevice(hash)
<ide> if info == nil {
<ide> return false
<ide> func (devices *DeviceSet) HasActivatedDevice(hash string) bool {
<ide> info.lock.Lock()
<ide> defer info.lock.Unlock()
<ide>
<add> devices.Lock()
<add> defer devices.Unlock()
<add>
<ide> devinfo, _ := getInfo(info.Name())
<ide> return devinfo != nil && devinfo.Exists != 0
<ide> }
<ide> func (devices *DeviceSet) deviceStatus(devName string) (sizeInSectors, mappedSec
<ide> }
<ide>
<ide> func (devices *DeviceSet) GetDeviceStatus(hash string) (*DevStatus, error) {
<del> devices.Lock()
<del> defer devices.Unlock()
<del>
<ide> info, err := devices.lookupDevice(hash)
<ide> if err != nil {
<ide> return nil, err
<ide> func (devices *DeviceSet) GetDeviceStatus(hash string) (*DevStatus, error) {
<ide> info.lock.Lock()
<ide> defer info.lock.Unlock()
<ide>
<add> devices.Lock()
<add> defer devices.Unlock()
<add>
<ide> status := &DevStatus{
<ide> DeviceId: info.DeviceId,
<ide> Size: info.Size, | 1 |
Python | Python | improve datasource __del__ | 470d53fc6bc8267fec7d7cf5c7116d5e7437d789 | <ide><path>numpy/lib/_datasource.py
<ide> def __init__(self, destpath=os.curdir):
<ide>
<ide> def __del__(self):
<ide> # Remove temp directories
<del> if self._istmpdest:
<add> if hasattr(self, '_istmpdest') and self._istmpdest:
<ide> shutil.rmtree(self._destpath)
<ide>
<ide> def _iszip(self, filename):
<ide><path>numpy/lib/tests/test__datasource.py
<ide> def test_DataSourceOpen(self):
<ide> fp = datasource.open(local_file)
<ide> assert_(fp)
<ide> fp.close()
<add>
<add>def test_del_attr_handling():
<add> # DataSource __del__ can be called
<add> # even if __init__ fails when the
<add> # Exception object is caught by the
<add> # caller as happens in refguide_check
<add> # is_deprecated() function
<add>
<add> ds = datasource.DataSource()
<add> # simulate failed __init__ by removing key attribute
<add> # produced within __init__ and expected by __del__
<add> del ds._istmpdest
<add> # should not raise an AttributeError if __del__
<add> # gracefully handles failed __init__:
<add> ds.__del__() | 2 |
Java | Java | apply consistent copyright header | e9d1b39aff5fd912ec692ca594d7e02e42318789 | <ide><path>spring-aop/src/main/java/org/springframework/aop/TargetSource.java
<del>/*<
<del> * Copyright 2002-2017 the original author or authors.
<add>/*
<add> * Copyright 2002-2018 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><path>spring-core/src/main/java/org/springframework/core/ParameterizedTypeReference.java
<ide> * you may not use this file except in compliance with the License.
<ide> * You may obtain a copy of the License at
<ide> *
<del> * http://www.apache.org/licenses/LICENSE-2.0
<add> * http://www.apache.org/licenses/LICENSE-2.0
<ide> *
<ide> * Unless required by applicable law or agreed to in writing, software
<ide> * distributed under the License is distributed on an "AS IS" BASIS,
<ide> * limitations under the License.
<ide> */
<ide>
<add>
<ide> package org.springframework.core;
<ide>
<ide> import java.lang.reflect.ParameterizedType;
<ide><path>spring-core/src/main/java/org/springframework/core/env/PropertySourcesPropertyResolver.java
<ide> /*
<del> * Copyright 2002-2017 the original author or authors.
<add> * Copyright 2002-2018 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> * You may obtain a copy of the License at
<ide> *
<del> * http://www.apache.org/licenses/LICENSE-2.0
<add> * http://www.apache.org/licenses/LICENSE-2.0
<ide> *
<ide> * Unless required by applicable law or agreed to in writing, software
<ide> * distributed under the License is distributed on an "AS IS" BASIS,
<ide><path>spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/MessageExceptionHandler.java
<ide> /*
<del> * Copyright 2002-2014 the original author or authors.
<add> * Copyright 2002-2018 the original author or authors.
<ide> *
<del>
<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> * You may obtain a copy of the License at
<ide><path>spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/HandlerMethodReturnValueHandlerComposite.java
<del>/*
<ide> /*
<ide> * Copyright 2002-2018 the original author or authors.
<ide> *
<ide><path>spring-messaging/src/main/java/org/springframework/messaging/simp/config/ChannelRegistration.java
<ide> /*
<del> * Copyright 2002-2017 the original author or authors.7
<add> * Copyright 2002-2018 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><path>spring-test/src/main/java/org/springframework/test/web/servlet/MvcResult.java
<ide> /*
<ide> * Copyright 2002-2018 the original author or authors.
<ide> *
<del> * Licensed under the Apache License; Version 2.0 (the "License");
<add> * Licensed under the Apache License, Version 2.0 (the "License");
<ide> * you may not use this file except in compliance with the License.
<ide> * You may obtain a copy of the License at
<ide> *
<ide> * http://www.apache.org/licenses/LICENSE-2.0
<ide> *
<del> * Unless required by applicable law or agreed to in writing; software
<del> * distributed under the License is distributed on an "AS IS" BASIS;
<del> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND; either express or implied.
<add> * Unless required by applicable law or agreed to in writing, software
<add> * distributed under the License is distributed on an "AS IS" BASIS,
<add> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<ide> * See the License for the specific language governing permissions and
<ide> * limitations under the License.
<ide> */
<ide><path>spring-web/src/main/java/org/springframework/http/codec/xml/Jaxb2XmlEncoder.java
<ide> /*
<del> * Copyright 2002-2017 the original author or authors.
<add> * Copyright 2002-2018 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> * distributed under the License is distributed on an "AS IS" BASIS,
<ide> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<ide> * See the License for the specific language governing permissions and
<del> * limitations under the License.H
<add> * limitations under the License.
<ide> */
<ide>
<ide> package org.springframework.http.codec.xml;
<ide><path>spring-web/src/main/java/org/springframework/http/converter/GenericHttpMessageConverter.java
<ide> * you may not use this file except in compliance with the License.
<ide> * You may obtain a copy of the License at
<ide> *
<del> * http://www.apache.org/licenses/LICENSE-2.0
<add> * http://www.apache.org/licenses/LICENSE-2.0
<ide> *
<ide> * Unless required by applicable law or agreed to in writing, software
<ide> * distributed under the License is distributed on an "AS IS" BASIS,
<ide><path>spring-web/src/main/java/org/springframework/http/converter/protobuf/ExtensionRegistryInitializer.java
<ide> * you may not use this file except in compliance with the License.
<ide> * You may obtain a copy of the License at
<ide> *
<del> * http://www.apache.org/licenses/LICENSE-2.0
<add> * http://www.apache.org/licenses/LICENSE-2.0
<ide> *
<ide> * Unless required by applicable law or agreed to in writing, software
<ide> * distributed under the License is distributed on an "AS IS" BASIS,
<ide><path>spring-web/src/main/java/org/springframework/http/converter/xml/Jaxb2CollectionHttpMessageConverter.java
<ide> * you may not use this file except in compliance with the License.
<ide> * You may obtain a copy of the License at
<ide> *
<del> * http://www.apache.org/licenses/LICENSE-2.0
<add> * http://www.apache.org/licenses/LICENSE-2.0
<ide> *
<ide> * Unless required by applicable law or agreed to in writing, software
<ide> * distributed under the License is distributed on an "AS IS" BASIS,
<ide><path>spring-web/src/main/java/org/springframework/http/server/reactive/ContextPathCompositeHandler.java
<add>/*
<add> * Copyright 2002-2018 the original author or authors.
<add> *
<add> * Licensed under the Apache License, Version 2.0 (the "License");
<add> * you may not use this file except in compliance with the License.
<add> * You may obtain a copy of the License at
<add> *
<add> * http://www.apache.org/licenses/LICENSE-2.0
<add> *
<add> * Unless required by applicable law or agreed to in writing, software
<add> * distributed under the License is distributed on an "AS IS" BASIS,
<add> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<add> * See the License for the specific language governing permissions and
<add> * limitations under the License.
<add> */
<ide>
<ide> package org.springframework.http.server.reactive;
<ide>
<ide><path>spring-web/src/main/java/org/springframework/web/accept/ParameterContentNegotiationStrategy.java
<ide> /*
<del> * Copyright 2002-201 the original author or authors.
<add> * Copyright 2002-2018 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><path>spring-web/src/main/java/org/springframework/web/context/AbstractContextLoaderInitializer.java
<ide> * you may not use this file except in compliance with the License.
<ide> * You may obtain a copy of the License at
<ide> *
<del> * http://www.apache.org/licenses/LICENSE-2.0
<add> * http://www.apache.org/licenses/LICENSE-2.0
<ide> *
<ide> * Unless required by applicable law or agreed to in writing, software
<ide> * distributed under the License is distributed on an "AS IS" BASIS,
<ide><path>spring-web/src/main/java/org/springframework/web/context/request/ServletWebRequest.java
<ide> * you may not use this file except in compliance with the License.
<ide> * You may obtain a copy of the License at
<ide> *
<del> * http://www.apache.org/licenses/LICENSE-2.0
<add> * http://www.apache.org/licenses/LICENSE-2.0
<ide> *
<ide> * Unless required by applicable law or agreed to in writing, software
<ide> * distributed under the License is distributed on an "AS IS" BASIS,
<ide><path>spring-web/src/main/java/org/springframework/web/cors/reactive/CorsWebFilter.java
<add>/*
<add> * Copyright 2002-2018 the original author or authors.
<add> *
<add> * Licensed under the Apache License, Version 2.0 (the "License");
<add> * you may not use this file except in compliance with the License.
<add> * You may obtain a copy of the License at
<add> *
<add> * http://www.apache.org/licenses/LICENSE-2.0
<add> *
<add> * Unless required by applicable law or agreed to in writing, software
<add> * distributed under the License is distributed on an "AS IS" BASIS,
<add> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<add> * See the License for the specific language governing permissions and
<add> * limitations under the License.
<add> */
<add>
<ide> package org.springframework.web.cors.reactive;
<ide>
<ide> import reactor.core.publisher.Mono;
<ide><path>spring-web/src/main/java/org/springframework/web/util/UriBuilder.java
<ide> /*
<del> * Copyright 2002-2017 the original author or authors.
<add> * Copyright 2002-2018 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> *
<ide> * Unless required by applicable law or agreed to in writing, software
<ide> * distributed under the License is distributed on an "AS IS" BASIS,
<del> * WITHOUUriBuilder WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<add> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<ide> * See the License for the specific language governing permissions and
<ide> * limitations under the License.
<ide> */
<add>
<ide> package org.springframework.web.util;
<ide>
<ide> import java.net.URI;
<ide><path>spring-webflux/src/main/java/org/springframework/web/reactive/function/client/support/package-info.java
<del>/*
<del> * Copyright 2002-2018 the original author or authors.
<del> *
<del> * Licensed under the Apache License, Version 2.0 (the "License");
<del> * you may not use this file except in compliance with the License.
<del> * You may obtain a copy of the License at
<del> *
<del> * http://www.apache.org/licenses/LICENSE-2.0
<del> *
<del> * Unless required by applicable law or agreed to in writing, software
<del> * distributed under the License is distributed on an "AS IS" BASIS,
<del> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<del> * See the License for the specific language governing permissions and
<del> * limitations under the License.
<del> */
<del>
<ide> /**
<ide> * Classes supporting the {@code org.springframework.web.reactive.function.client} package.
<ide> * Contains a {@code ClientResponse} wrapper to adapt a request.
<ide><path>spring-webflux/src/main/java/org/springframework/web/reactive/resource/FixedVersionStrategy.java
<ide> /*
<del> * Copyright 2002-2016 the original author or authors.
<add> * Copyright 2002-2018 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> * You may obtain a copy of the License at
<ide> *
<del> * http://www.apache.org/licenses/LICENSE-2.0
<add> * http://www.apache.org/licenses/LICENSE-2.0
<ide> *
<ide> * Unless required by applicable law or agreed to in writing, software
<ide> * distributed under the License is distributed on an "AS IS" BASIS,
<ide><path>spring-webflux/src/main/java/org/springframework/web/reactive/resource/HttpResource.java
<add>/*
<add> * Copyright 2002-2018 the original author or authors.
<add> *
<add> * Licensed under the Apache License, Version 2.0 (the "License");
<add> * you may not use this file except in compliance with the License.
<add> * You may obtain a copy of the License at
<add> *
<add> * http://www.apache.org/licenses/LICENSE-2.0
<add> *
<add> * Unless required by applicable law or agreed to in writing, software
<add> * distributed under the License is distributed on an "AS IS" BASIS,
<add> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<add> * See the License for the specific language governing permissions and
<add> * limitations under the License.
<add> */
<add>
<ide> package org.springframework.web.reactive.resource;
<ide>
<ide> import org.springframework.core.io.Resource;
<ide><path>spring-webflux/src/main/java/org/springframework/web/reactive/result/view/ViewResolver.java
<add>/*
<add> * Copyright 2002-2018 the original author or authors.
<add> *
<add> * Licensed under the Apache License, Version 2.0 (the "License");
<add> * you may not use this file except in compliance with the License.
<add> * You may obtain a copy of the License at
<add> *
<add> * http://www.apache.org/licenses/LICENSE-2.0
<add> *
<add> * Unless required by applicable law or agreed to in writing, software
<add> * distributed under the License is distributed on an "AS IS" BASIS,
<add> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<add> * See the License for the specific language governing permissions and
<add> * limitations under the License.
<add> */
<add>
<ide> package org.springframework.web.reactive.result.view;
<ide>
<ide> import java.util.Locale;
<ide><path>spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ContentVersionStrategy.java
<ide> /*
<del> * Copyright 2002-2015 the original author or authors.
<add> * Copyright 2002-2018 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> * You may obtain a copy of the License at
<ide> *
<del> * http://www.apache.org/licenses/LICENSE-2.0
<add> * http://www.apache.org/licenses/LICENSE-2.0
<ide> *
<ide> * Unless required by applicable law or agreed to in writing, software
<ide> * distributed under the License is distributed on an "AS IS" BASIS,
<ide><path>spring-webmvc/src/main/java/org/springframework/web/servlet/resource/FixedVersionStrategy.java
<ide> /*
<del> * Copyright 2002-2015 the original author or authors.
<add> * Copyright 2002-2018 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> * You may obtain a copy of the License at
<ide> *
<del> * http://www.apache.org/licenses/LICENSE-2.0
<add> * http://www.apache.org/licenses/LICENSE-2.0
<ide> *
<ide> * Unless required by applicable law or agreed to in writing, software
<ide> * distributed under the License is distributed on an "AS IS" BASIS,
<ide><path>spring-webmvc/src/main/java/org/springframework/web/servlet/support/AbstractAnnotationConfigDispatcherServletInitializer.java
<ide> /*
<del> * Copyright 2002-2017 the original author or authors.
<add> * Copyright 2002-2018 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> * You may obtain a copy of the License at
<ide> *
<del> * http://www.apache.org/licenses/LICENSE-2.0
<add> * http://www.apache.org/licenses/LICENSE-2.0
<ide> *
<ide> * Unless required by applicable law or agreed to in writing, software
<ide> * distributed under the License is distributed on an "AS IS" BASIS, | 24 |
Text | Text | remove reference to the obsolete chrome extension | cbcfaa2c8db02f7b529e6de0a6f8957ad03efdb5 | <ide><path>CONTRIBUTING.md
<ide> from the main (upstream) repository:
<ide> git pull --ff upstream master
<ide> ```
<ide>
<del>### GitHub Pull Request Helper
<del>
<del>We track Pull Requests by attaching labels and assigning to milestones. For some reason GitHub
<del>does not provide a good UI for managing labels on Pull Requests (unlike Issues). We have developed
<del>a simple Chrome Extension that enables you to view (and manage if you have permission) the labels
<del>on Pull Requests. You can get the extension from the Chrome WebStore -
<del>[GitHub PR Helper][github-pr-helper]
<del>
<ide> ## Coding Rules
<ide> To ensure consistency throughout the source code, keep these rules in mind as you are working:
<ide> | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.