PrimeIntellect/SWE-rebench-V2 huggingface dataset:
Repository: bpicode/fritzctl (go)

Issue:
fritzctl temperature on/off
Is there a way to turn on/off the thermostats like direct in the Fritz!Box or at the device? In the help it says only: fritzctl temperature [value in °C] [device names] [flags]

Pull request:
Issue #58: add support for temperature on/off
Closes #58 

Patch:
diff --git a/cmd/temperature.go b/cmd/temperature.go
index 3bdaf08..d984c6b 100644
--- a/cmd/temperature.go
+++ b/cmd/temperature.go
@@ -2,16 +2,21 @@ package cmd
 
 import (
 	"strconv"
+	"strings"
 
 	"github.com/spf13/cobra"
 )
 
 var temperatureCmd = &cobra.Command{
-	Use:     "temperature [value in °C] [device names]",
-	Short:   "Set the temperature of HKR devices",
-	Long:    "Change the temperature of one or more HKR devices.",
-	Example: "fritzctl temperature 21.0 HKR_1 HKR_2",
-	RunE:    changeTemperature,
+	Use:   "temperature [value in °C, on, off] [device names]",
+	Short: "Set the temperature of HKR devices or turn them on/off",
+	Long: "Change the temperature of one or more HKR devices by supplying the desired value in °C. " +
+		"When turning HKR devices on/off, replace the value by 'on'/'off' respectively.",
+	Example: `fritzctl temperature 21.0 HKR_1 HKR_2
+fritzctl temperature off HKR_1
+fritzctl temperature on HKR_2
+`,
+	RunE: changeTemperature,
 }
 
 func init() {
@@ -19,11 +24,22 @@ func init() {
 }
 
 func changeTemperature(cmd *cobra.Command, args []string) error {
-	assertStringSliceHasAtLeast(args, 2, "insufficient input: at least two parameters expected.")
-	temp, errorParse := strconv.ParseFloat(args[0], 64)
+	assertStringSliceHasAtLeast(args, 2, "insufficient input: at least two parameters expected.\n\n", cmd.UsageString())
+	temp, errorParse := parseTemperature(args[0])
 	assertNoError(errorParse, "cannot parse temperature value:", errorParse)
 	c := homeAutoClient()
 	err := c.Temp(temp, args[1:]...)
 	assertNoError(err, "error setting temperature:", err)
 	return nil
 }
+
+func parseTemperature(s string) (float64, error) {
+	if strings.EqualFold(s, "off") {
+		return 126.5, nil
+	}
+	if strings.EqualFold(s, "on") {
+		return 127.0, nil
+	}
+	temp, errorParse := strconv.ParseFloat(s, 64)
+	return temp, errorParse
+}


Test patch:
diff --git a/cmd/temperature_test.go b/cmd/temperature_test.go
new file mode 100644
index 0000000..a042747
--- /dev/null
+++ b/cmd/temperature_test.go
@@ -0,0 +1,24 @@
+package cmd
+
+import (
+	"testing"
+
+	"github.com/stretchr/testify/assert"
+)
+
+// TestParseTemperature tests the user-supplied temperature interpretation.
+func TestParseTemperature(t *testing.T) {
+	assertions := assert.New(t)
+
+	twelve, err := parseTemperature("12")
+	assertions.NoError(err)
+	assertions.Equal(float64(12), twelve)
+
+	on, err := parseTemperature("on")
+	assertions.NoError(err)
+	assertions.Equal(float64(127), on)
+
+	off, err := parseTemperature("off")
+	assertions.NoError(err)
+	assertions.Equal(float64(126.5), off)
+}
Repository: phoenixframework/phoenix (elixir)

Issue:
Confusing error message when resources singleton: true and only: [:index]
<!--
### Precheck

* For help and support, use Stack Overflow or the Phoenix Talk mailing list
* For proposing a new feature, start a discussion on the Phoenix Core mailing list
* For bugs, do a quick search and make sure the bug has not yet been reported
* Ensure that this issue is related to the Phoenix library and not one of the dependencies listed in mix.exs (Ecto, Plug, etc.)
* All checked? Be nice and have fun!
-->

### Environment

* Elixir version (elixir -v): 1.4.5
* Phoenix version (mix deps): 1.2.3
* NodeJS version (node -v): v6.9.4
* NPM version (npm -v): 3.10.10
* Operating system: MacOS 10.12.6

### Expected behavior

I came across a confusing error message, when I try to do:
```elixir
resources "/settings", SettingsController, singleton: true, only: [:index, :update]
```

the error message: 
```elixir
== Compilation error on file web/router.ex ==
** (FunctionClauseError) no function clause matching in anonymous fn/1 in :elixir_compiler_36.__MODULE__/1
    web/router.ex:2: anonymous fn(:index) in :elixir_compiler_36.__MODULE__/1
    (elixir) lib/enum.ex:645: Enum."-each/2-lists^foreach/1-0-"/2
    (elixir) lib/enum.ex:645: Enum.each/2
    web/router.ex:83: (module)
    (stdlib) erl_eval.erl:670: :erl_eval.do_apply/6
```

Scratched my head for a while, after reading through the doc I realized when `singleton: true` there is no `:index` actions.

### Actual behavior

I feel maybe the error message could be a little bit better? I would like to help :)


Pull request:
Raise error when declaring singleton with index
Fixes #2575.

Patch:
diff --git a/lib/phoenix/router.ex b/lib/phoenix/router.ex
index 1fac62212..51cf07b82 100644
--- a/lib/phoenix/router.ex
+++ b/lib/phoenix/router.ex
@@ -234,6 +234,7 @@ defmodule Phoenix.Router do
 
         if resource.singleton do
           Enum.each resource.actions, fn
+            :index   -> raise ArgumentError, "singleton resources cannot have an :index route"
             :show    -> get    path,            ctrl, :show, opts
             :new     -> get    path <> "/new",  ctrl, :new, opts
             :edit    -> get    path <> "/edit", ctrl, :edit, opts


Test patch:
diff --git a/test/phoenix/router/resources_test.exs b/test/phoenix/router/resources_test.exs
index 25ac6f489..1bfe3a3fd 100644
--- a/test/phoenix/router/resources_test.exs
+++ b/test/phoenix/router/resources_test.exs
@@ -266,4 +266,13 @@ defmodule Phoenix.Router.ResourcesTest do
     assert conn.resp_body == "show users"
     assert conn.params["id"] == "2"
   end
+
+  test "singleton resources declaring an :index route throws an ArgumentError" do
+    assert_raise ArgumentError, ~r"cannot have an :index route", fn ->
+      defmodule SingletonRouter.Router do
+        use Phoenix.Router
+        resources "/", UserController, singleton: true, only: [:index]
+      end
+    end
+  end
 end
Repository: vigetlabs/microcosm (js)

Issue:
Presenter context between setup() and intercept() mismatch
**What kind of issue is this?** (check at least one)

- [x] Report a bug
- [ ] Feature Request
- [ ] Question
- [ ] Discussion
- [ ] Documentation
- [ ] Other, please describe:

**What version of Microcosm is this for**

12.9.0-beta

**Steps to Reproduce/Example** (if applicable)

Failing spec added [here](https://github.com/vigetlabs/microcosm/commit/604acafa31cedcfb87126753a6f1dbd0cfe0e052)

<!-- What is the expected behaviour? -->

Presenter `this` context should be shared between `setup()` and `intercept()`.

<!-- What is happening instead? -->

It looks like logging `this` in `setup()` returns an instance of the Presenter like I expected, but logging `this` in `intercept()` returns an instance of `PresenterMediator` so any attributes defined on `this` in `setup()` are lost in `intercept()`.


Pull request:
Presenter context bug
Presenter `intercept` hooks were getting invoked in the wrong context.

Fixes #363

Patch:
diff --git a/src/addons/presenter.js b/src/addons/presenter.js
index 89b58e0d..be2d6dde 100644
--- a/src/addons/presenter.js
+++ b/src/addons/presenter.js
@@ -270,7 +270,7 @@ class PresenterMediator extends React.PureComponent {
       let handler = mediator.getHandler(taggedIntent)
 
       if (handler) {
-        return handler.call(mediator, mediator.repo, ...params)
+        return handler.call(this.presenter, mediator.repo, ...params)
       }
 
       mediator = mediator.getParent()


Test patch:
diff --git a/test/addons/presenter.test.js b/test/addons/presenter.test.js
index e60cab13..92cc2fe9 100644
--- a/test/addons/presenter.test.js
+++ b/test/addons/presenter.test.js
@@ -1187,6 +1187,26 @@ describe('intercepting actions', function() {
 
     expect(test).toHaveBeenCalled()
   })
+
+  it('shares context between setup() and intercept()', function() {
+    class Parent extends Presenter {
+      setup() {
+        this.foo = 'bar'
+      }
+
+      intercept() {
+        return {
+          test: this.assertionFunction
+        }
+      }
+
+      assertionFunction() {
+        expect(this.foo).toEqual('bar')
+      }
+    }
+
+    mount(<Parent />).instance().send('test')
+  })
 })
 
 describe('forks', function() {