nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: StackExchange/dnscontrol
Pull request #1085 (2021-03-07 20:14:39)

Make GCLOUD and GANDI_V5 modules consistent
Fixes https://github.com/StackExchange/dnscontrol/issues/1060
Fixes https://github.com/StackExchange/dnscontrol/issues/1059


Patch:
diff --git a/providers/gandi_v5/auditrecords.go b/providers/gandi_v5/auditrecords.go
index 50f2676e..0cd78230 100644
--- a/providers/gandi_v5/auditrecords.go
+++ b/providers/gandi_v5/auditrecords.go
@@ -1,4 +1,4 @@
-package gandi5
+package gandi_v5
 
 import (
 	"github.com/StackExchange/dnscontrol/v3/models"
diff --git a/providers/gandi_v5/convert.go b/providers/gandi_v5/convert.go
index 2d31305a..4e37559e 100644
--- a/providers/gandi_v5/convert.go
+++ b/providers/gandi_v5/convert.go
@@ -1,4 +1,4 @@
-package gandi5
+package gandi_v5
 
 // Convert the provider's native record description to models.RecordConfig.
 
diff --git a/providers/gandi_v5/gandi_v5Provider.go b/providers/gandi_v5/gandi_v5Provider.go
index a5819997..aaa12d63 100644
--- a/providers/gandi_v5/gandi_v5Provider.go
+++ b/providers/gandi_v5/gandi_v5Provider.go
@@ -1,4 +1,4 @@
-package gandi5
+package gandi_v5
 
 /*
 
diff --git a/providers/gcloud/auditrecords.go b/providers/gcloud/auditrecords.go
index 62e9ff2d..891b914f 100644
--- a/providers/gcloud/auditrecords.go
+++ b/providers/gcloud/auditrecords.go
@@ -1,4 +1,4 @@
-package google
+package gcloud
 
 import (
 	"github.com/StackExchange/dnscontrol/v3/models"
diff --git a/providers/gcloud/gcloudProvider.go b/providers/gcloud/gcloudProvider.go
index 0be486f6..deb579c6 100644
--- a/providers/gcloud/gcloudProvider.go
+++ b/providers/gcloud/gcloudProvider.go
@@ -1,4 +1,4 @@
-package google
+package gcloud
 
 import (
 	"context"


Test patch:
diff --git a/providers/gandi_v5/convert_test.go b/providers/gandi_v5/convert_test.go
index 8ada0fab..47239844 100644
--- a/providers/gandi_v5/convert_test.go
+++ b/providers/gandi_v5/convert_test.go
@@ -1,4 +1,4 @@
-package gandi5
+package gandi_v5
 
 import (
 	"testing"
Repository: StackExchange/dnscontrol
Pull request #1822 (2022-11-26 00:02:29)

VULTR: Fix setting RecordConfig Original
RecordConfig.Original was set with a pointer that was being reused.
This caused the wrong record to be modified/removed in some cases.

tlimoncelli: Thanks for finding and fixing this!  

Patch:
diff --git a/providers/vultr/vultrProvider.go b/providers/vultr/vultrProvider.go
index c0980bb6..a72e4c7f 100644
--- a/providers/vultr/vultrProvider.go
+++ b/providers/vultr/vultrProvider.go
@@ -85,7 +85,7 @@ func (api *vultrProvider) GetZoneRecords(domain string) (models.Records, error)
 		}
 		currentI := 0
 		for i, record := range records {
-			r, err := toRecordConfig(domain, &record)
+			r, err := toRecordConfig(domain, record)
 			if err != nil {
 				return nil, err
 			}
@@ -126,7 +126,7 @@ func (api *vultrProvider) GetDomainCorrections(dc *models.DomainConfig) ([]*mode
 	var corrections []*models.Correction
 
 	for _, mod := range delete {
-		id := mod.Existing.Original.(*govultr.DomainRecord).ID
+		id := mod.Existing.Original.(govultr.DomainRecord).ID
 		corrections = append(corrections, &models.Correction{
 			Msg: fmt.Sprintf("%s; Vultr RecordID: %v", mod.String(), id),
 			F: func() error {
@@ -147,7 +147,7 @@ func (api *vultrProvider) GetDomainCorrections(dc *models.DomainConfig) ([]*mode
 	}
 
 	for _, mod := range modify {
-		r := toVultrRecord(dc, mod.Desired, mod.Existing.Original.(*govultr.DomainRecord).ID)
+		r := toVultrRecord(dc, mod.Desired, mod.Existing.Original.(govultr.DomainRecord).ID)
 		corrections = append(corrections, &models.Correction{
 			Msg: fmt.Sprintf("%s; Vultr RecordID: %v", mod.String(), r.ID),
 			F: func() error {
@@ -204,8 +204,9 @@ func (api *vultrProvider) isDomainInAccount(domain string) (bool, error) {
 }
 
 // toRecordConfig converts a Vultr DomainRecord to a RecordConfig. #rtype_variations
-func toRecordConfig(domain string, r *govultr.DomainRecord) (*models.RecordConfig, error) {
+func toRecordConfig(domain string, r govultr.DomainRecord) (*models.RecordConfig, error) {
 	origin, data := domain, r.Data
+
 	rc := &models.RecordConfig{
 		TTL:      uint32(r.TTL),
 		Original: r,


Test patch:
diff --git a/providers/vultr/convert_test.go b/providers/vultr/convert_test.go
index e995e369..06fbae89 100644
--- a/providers/vultr/convert_test.go
+++ b/providers/vultr/convert_test.go
@@ -12,7 +12,7 @@ func TestConversion(t *testing.T) {
 		Name: "example.com",
 	}
 
-	records := []*govultr.DomainRecord{
+	records := []govultr.DomainRecord{
 		{
 			Type: "A",
 			Name: "",
Repository: StackExchange/dnscontrol
Pull request #2249 (2023-03-29 17:59:31)

diff2: Add a "hints" when change is TTL-only
<!--
Before you submit a pull request, please make sure you've run the following commands from the root directory.

go vet ./...
go fmt ./...
go generate ./...
go mod tidy
!-->




Patch:
diff --git a/pkg/diff2/analyze.go b/pkg/diff2/analyze.go
index 678a2e28..93453821 100644
--- a/pkg/diff2/analyze.go
+++ b/pkg/diff2/analyze.go
@@ -170,10 +170,12 @@ func findTTLChanges(existing, desired []targetConfig) ([]targetConfig, []targetC
 
 		if ecomp == dcomp && er.TTL != dr.TTL {
 			m := color.YellowString("± MODIFY-TTL %s %s %s", dr.NameFQDN, dr.Type, humanDiff(existing[ei], desired[di]))
-			instructions = append(instructions, mkChange(dr.NameFQDN, dr.Type, []string{m},
+			v := mkChange(dr.NameFQDN, dr.Type, []string{m},
 				models.Records{er},
 				models.Records{dr},
-			))
+			)
+			v.HintOnlyTTL = true
+			instructions = append(instructions, v)
 			ei++
 			di++
 		} else if ecomp < dcomp {
diff --git a/pkg/diff2/diff2.go b/pkg/diff2/diff2.go
index ada61fea..e117dae2 100644
--- a/pkg/diff2/diff2.go
+++ b/pkg/diff2/diff2.go
@@ -39,6 +39,10 @@ type Change struct {
 	Msgs       []string                      // Human-friendly explanation of what changed
 	MsgsJoined string                        // strings.Join(Msgs, "\n")
 	MsgsByKey  map[models.RecordKey][]string // Messages for a given key
+
+	// HintOnlyTTL is true only if (.Type == diff2.CHANGE) && (there is
+	// exactly 1 record being updated) && (the only change is the TTL)
+	HintOnlyTTL bool
 }
 
 /*
@@ -223,6 +227,9 @@ func (c Change) String() string {
 
 	fmt.Fprintf(b, "Change: verb=%v\n", c.Type)
 	fmt.Fprintf(b, "    key=%v\n", c.Key)
+	if c.HintOnlyTTL {
+		fmt.Fprint(b, "    Hints=OnlyTTL\n", c.Key)
+	}
 	if len(c.Old) != 0 {
 		fmt.Fprintf(b, "    old=%v\n", c.Old)
 	}


Test patch:
diff --git a/pkg/diff2/analyze_test.go b/pkg/diff2/analyze_test.go
index b4f1537f..452ef4df 100644
--- a/pkg/diff2/analyze_test.go
+++ b/pkg/diff2/analyze_test.go
@@ -670,7 +670,7 @@ func Test_splitTTLOnly(t *testing.T) {
 			},
 			wantExistDiff:  nil,
 			wantDesireDiff: nil,
-			wantChanges:    "ChangeList: len=1\n00: Change: verb=CHANGE\n    key={laba.f.com A}\n    old=[1.2.3.4]\n    new=[1.2.3.4]\n    msg=[\"± MODIFY-TTL laba.f.com A 1.2.3.4 ttl=(300->700)\"]\n",
+			wantChanges:    "ChangeList: len=1\n00: Change: verb=CHANGE\n    key={laba.f.com A}\n    Hints=OnlyTTL\n{laba.f.com A}    old=[1.2.3.4]\n    new=[1.2.3.4]\n    msg=[\"± MODIFY-TTL laba.f.com A 1.2.3.4 ttl=(300->700)\"]\n",
 		},
 
 		{
Repository: StackExchange/dnscontrol
Pull request #2320 (2023-05-04 23:32:24)

NS1 Fix URLFWD implementation by being more consistent
URLFWD isn't a real record type. There's no need to maintain both a "virtual" type and an alias type when there's a single implementation.

Discussed in #2319. 

tlimoncelli: Thank you!  Yes, that's much better!

Patch:
diff --git a/pkg/normalize/validate.go b/pkg/normalize/validate.go
index 86baa1da..0aa8fb1f 100644
--- a/pkg/normalize/validate.go
+++ b/pkg/normalize/validate.go
@@ -206,7 +206,7 @@ func checkTargets(rec *models.RecordConfig, domain string) (errs []error) {
 		if label == "@" {
 			check(fmt.Errorf("cannot create NS record for bare domain. Use NAMESERVER instead"))
 		}
-	case "URLFWD":
+	case "NS1_URLFWD":
 		if len(strings.Fields(target)) != 5 {
 			check(fmt.Errorf("record should follow format: \"from to redirectType pathForwardingMode queryForwarding\""))
 		}


Test patch:
diff --git a/integrationTest/integration_test.go b/integrationTest/integration_test.go
index 20397aab..8aa69543 100644
--- a/integrationTest/integration_test.go
+++ b/integrationTest/integration_test.go
@@ -645,8 +645,8 @@ func tlsa(name string, usage, selector, matchingtype uint8, target string) *mode
 	return r
 }
 
-func urlfwd(name, target string) *models.RecordConfig {
-	return makeRec(name, target, "URLFWD")
+func ns1_urlfwd(name, target string) *models.RecordConfig {
+	return makeRec(name, target, "NS1_URLFWD")
 }
 
 func clear(items ...interface{}) *TestCase {
@@ -1678,8 +1678,8 @@ func makeTests(t *testing.T) []*TestGroup {
 
 		testgroup("NS1_URLFWD tests",
 			only("NS1"),
-			tc("Add a urlfwd", urlfwd("urlfwd1", "/ http://example.com 302 2 0")),
-			tc("Update a urlfwd", urlfwd("urlfwd1", "/ http://example.org 301 2 0")),
+			tc("Add a urlfwd", ns1_urlfwd("urlfwd1", "/ http://example.com 302 2 0")),
+			tc("Update a urlfwd", ns1_urlfwd("urlfwd1", "/ http://example.org 301 2 0")),
 		),
 
 		//// IGNORE* features
diff --git a/pkg/normalize/validate_test.go b/pkg/normalize/validate_test.go
index 24d51d63..b0f16aba 100644
--- a/pkg/normalize/validate_test.go
+++ b/pkg/normalize/validate_test.go
@@ -198,25 +198,25 @@ func TestNSAtRoot(t *testing.T) {
 	}
 }
 
-func TestURLFWDValid(t *testing.T) {
-	rec := &models.RecordConfig{Type: "URLFWD"}
+func TestNS1URLFWDValid(t *testing.T) {
+	rec := &models.RecordConfig{Type: "NS1_URLFWD"}
 	rec.SetLabel("test1", "foo.com")
 	rec.SetTarget("/ http://example.com 302 2 0")
 
 	errs := checkTargets(rec, "foo.com")
 	if len(errs) > 0 {
-		t.Error("Expect no error with valid URLFWD target")
+		t.Error("Expect no error with valid NS1_URLFWD target")
 	}
 }
 
-func TestURLFWDInvalid(t *testing.T) {
-	rec := &models.RecordConfig{Type: "URLFWD"}
+func TestNS1URLFWDInvalid(t *testing.T) {
+	rec := &models.RecordConfig{Type: "NS1_URLFWD"}
 	rec.SetLabel("test2", "foo.com")
 	rec.SetTarget("/ http://example.com 302 2")
 
 	errs := checkTargets(rec, "foo.com")
 	if len(errs) == 0 {
-		t.Error("Expect error with invalid URLFWD target")
+		t.Error("Expect error with invalid NS1_URLFWD target")
 	}
 }
Repository: StackExchange/dnscontrol
Pull request #2405 (2023-05-30 19:29:26)

CHORE: Rename js.Javascript to js.JavaScript
<!--
Before you submit a pull request, please make sure you've run the following commands from the root directory.

go vet ./...
go fmt ./...
go generate ./...
go mod tidy
!-->




Patch:
diff --git a/commands/printIR.go b/commands/printIR.go
index 1241c031..82dc48ef 100644
--- a/commands/printIR.go
+++ b/commands/printIR.go
@@ -122,7 +122,7 @@ func ExecuteDSL(args ExecuteDSLArgs) (*models.DNSConfig, error) {
 		return nil, fmt.Errorf("no config specified")
 	}
 
-	dnsConfig, err := js.ExecuteJavascript(args.JSFile, args.DevMode, stringSliceToMap(args.Variable))
+	dnsConfig, err := js.ExecuteJavaScript(args.JSFile, args.DevMode, stringSliceToMap(args.Variable))
 	if err != nil {
 		return nil, fmt.Errorf("executing %s: %w", args.JSFile, err)
 	}
diff --git a/pkg/js/js.go b/pkg/js/js.go
index 8a45dace..c2e5f49a 100644
--- a/pkg/js/js.go
+++ b/pkg/js/js.go
@@ -35,8 +35,8 @@ var currentDirectory string
 // EnableFetch sets whether to enable fetch() in JS execution environment
 var EnableFetch bool = false
 
-// ExecuteJavascript accepts a javascript file and runs it, returning the resulting dnsConfig.
-func ExecuteJavascript(file string, devMode bool, variables map[string]string) (*models.DNSConfig, error) {
+// ExecuteJavaScript accepts a javascript file and runs it, returning the resulting dnsConfig.
+func ExecuteJavaScript(file string, devMode bool, variables map[string]string) (*models.DNSConfig, error) {
 	script, err := os.ReadFile(file)
 	if err != nil {
 		return nil, err


Test patch:
diff --git a/pkg/js/js_test.go b/pkg/js/js_test.go
index b4526847..9b1ef438 100644
--- a/pkg/js/js_test.go
+++ b/pkg/js/js_test.go
@@ -41,7 +41,7 @@ func TestParsedFiles(t *testing.T) {
 			var err error
 
 			// Compile the .js file:
-			conf, err := ExecuteJavascript(string(filepath.Join(testDir, name)), true, nil)
+			conf, err := ExecuteJavaScript(string(filepath.Join(testDir, name)), true, nil)
 			if err != nil {
 				t.Fatal(err)
 			}
@@ -144,7 +144,7 @@ func TestErrors(t *testing.T) {
 	}
 	for _, tst := range tests {
 		t.Run(tst.desc, func(t *testing.T) {
-			if _, err := ExecuteJavascript(tst.text, true, nil); err == nil {
+			if _, err := ExecuteJavaScript(tst.text, true, nil); err == nil {
 				t.Fatal("Expected error but found none")
 			}
 		})