nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: abahmed/kwatch
Pull request #308 (2024-05-31 17:39:12)

🐛 handle empty events
Changes proposed in this pull request:
- 🐛 handle empty events



Patch:
diff --git a/handler/executeContainersFilters.go b/handler/executeContainersFilters.go
index dbafd43..7bb4c52 100644
--- a/handler/executeContainersFilters.go
+++ b/handler/executeContainersFilters.go
@@ -45,6 +45,11 @@ func (h *handler) executeContainersFilters(ctx *filter.Context) {
 				ownerName = ctx.Owner.Name
 			}
 
+			if ctx.Events == nil {
+				events, _ := util.GetPodEvents(ctx.Client, ctx.Pod.Name, ctx.Pod.Namespace)
+				ctx.Events = &events.Items
+			}
+
 			logrus.Printf(
 				"container only issue %s %s %s %s %s %d",
 				ctx.Container.Container.Name,
diff --git a/util/util.go b/util/util.go
index 1b276dd..cf68db4 100644
--- a/util/util.go
+++ b/util/util.go
@@ -18,6 +18,10 @@ import (
 
 // GetPodEventsStr returns formatted events as a string for specified pod
 func GetPodEventsStr(events *[]v1.Event) string {
+	if events == nil {
+		return ""
+	}
+
 	eventsString := ""
 
 	for _, ev := range *events {


Test patch:
diff --git a/util/util_test.go b/util/util_test.go
index 2ba4841..0a5474d 100644
--- a/util/util_test.go
+++ b/util/util_test.go
@@ -76,6 +76,14 @@ func TestGetPodEventsStr(t *testing.T) {
 	assert.Equal(result, expectedOutput)
 }
 
+func TestGetPodEventsStrNil(t *testing.T) {
+	assert := assert.New(t)
+
+	result := GetPodEventsStr(nil)
+	expectedOutput := ""
+	assert.Equal(result, expectedOutput)
+}
+
 func TestContainsKillingStoppingContainerEvents(t *testing.T) {
 	assert := assert.New(t)
Repository: abice/go-enum
Pull request #111 (2022-06-15 10:09:29)

Fix ignoring text after closing ) also for single line ENUM
When trying out 0.4.2 locally, I noticed that while multi-line comments worked fine with trailing text, singleline ENUM specifications failed.

The altered test case fails without the addition in `trimAllTheThings`, possibly some of the previous fixes in https://github.com/abice/go-enum/commit/fa188db43bd040a7fe6c2bcedd699b757ae6cb0b are now redundant.

abice: Hey, thanks for catching that.

One of the reasons I chose not to modify that method is because it has implications for people who write comments in the multi line version of the enum definition.

Would you mind adding a test for a multi line comment that says something like ` x (a.k.a. y+z) is something special` and make sure that the comment is still in tact? The parsing allows for people to use parens within their comments and keeps track when they close. 

If that doesn't work, then we would need to modify the same location I did before, but make sure that it takes the single line version into account. 
dsonck92: Sure, I'll look at it tonight, or otherwise somewhere in the weekend.
abice: You know what, there already is a test that has that.  Turns out the comment parsing takes place first, and strips off the comment from the `trimAllTheThings` method, so we shouldn't have to worry about it... that's why your tests passed without modifying the snapshots.  👍 

I think I'd still like to see changes elsewhere to ensure we're ending on the last `)`, but your PR is perfectly fine for now.  I'll go ahead and merge... 

Thanks for the contribution!

Patch:
diff --git a/generator/generator.go b/generator/generator.go
index 7a2af17..c54dd64 100644
--- a/generator/generator.go
+++ b/generator/generator.go
@@ -572,7 +572,14 @@ func breakCommentIntoLines(comment *ast.Comment) []string {
 
 // trimAllTheThings takes off all the cruft of a line that we don't need.
 func trimAllTheThings(thing string) string {
-	return strings.TrimSpace(strings.TrimSuffix(strings.TrimSuffix(strings.TrimSpace(thing), `,`), `)`))
+	preTrimmed := strings.TrimSuffix(strings.TrimSpace(thing), `,`)
+	end := strings.Index(preTrimmed, `)`)
+
+	if end < 0 {
+		end = len(preTrimmed)
+	}
+
+	return strings.TrimSpace(preTrimmed[:end])
 }
 
 // inspect will walk the ast and fill a map of names and their struct information


Test patch:
diff --git a/generator/example_test.go b/generator/example_test.go
index a6d4d33..4f09473 100644
--- a/generator/example_test.go
+++ b/generator/example_test.go
@@ -21,7 +21,7 @@ type Color int
 // ) Some other line of info
 type Animal int32
 
-// Model x ENUM(Toyota,_,Chevy,_,Ford)
+// Model x ENUM(Toyota,_,Chevy,_,Ford).
 type Model int32
 
 /* ENUM(
Repository: pion/rtp
Pull request #216 (2023-02-13 19:57:17)

Fix errShortPacket with H264 EOS NALUs
#### Description

Porting of #213 



Patch:
diff --git a/codecs/h264_packet.go b/codecs/h264_packet.go
index 11a82fe..3eda4de 100644
--- a/codecs/h264_packet.go
+++ b/codecs/h264_packet.go
@@ -211,10 +211,8 @@ func (p *H264Packet) IsDetectedFinalPacketInSequence(rtpPacketMarketBit bool) bo
 
 // Unmarshal parses the passed byte slice and stores the result in the H264Packet this method is called upon
 func (p *H264Packet) Unmarshal(payload []byte) ([]byte, error) {
-	if payload == nil {
-		return nil, errNilPacket
-	} else if len(payload) <= 2 {
-		return nil, fmt.Errorf("%w: %d <= 2", errShortPacket, len(payload))
+	if len(payload) == 0 {
+		return nil, fmt.Errorf("%w: %d <=0", errShortPacket, len(payload))
 	}
 
 	// NALU Types


Test patch:
diff --git a/codecs/h264_packet_test.go b/codecs/h264_packet_test.go
index 47826d7..fd77a3e 100644
--- a/codecs/h264_packet_test.go
+++ b/codecs/h264_packet_test.go
@@ -115,8 +115,16 @@ func TestH264Packet_Unmarshal(t *testing.T) {
 		t.Fatal("Unmarshal did not fail on nil payload")
 	}
 
-	if _, err := pkt.Unmarshal([]byte{0x00, 0x00}); err == nil {
-		t.Fatal("Unmarshal accepted a packet that is too small for a payload and header")
+	if _, err := pkt.Unmarshal([]byte{}); err == nil {
+		t.Fatal("Unmarshal did not fail on []byte{}")
+	}
+
+	if _, err := pkt.Unmarshal([]byte{0xFC}); err == nil {
+		t.Fatal("Unmarshal accepted a FU-A packet that is too small for a payload and header")
+	}
+
+	if _, err := pkt.Unmarshal([]byte{0x0A}); err != nil {
+		t.Fatal("Unmarshaling end of sequence(NALU Type : 10) should succeed")
 	}
 
 	if _, err := pkt.Unmarshal([]byte{0xFF, 0x00, 0x00}); err == nil {