fork of https://github.com/sourcegraph/zoekt
0

Configure Feed

Select the types of activity you want to include in your feed.

sourcegraph: fix wrong git config (#841)

Turns out git config doesn't support "_" in the keys.

https://git-scm.com/docs/git-config/2.22.0#_configuration_file

"The variable names are case-insensitive, allow only alphanumeric
characters and -, and must start with an alphabetic character."

Test plan:
New unit test

+36 -8
+2 -2
api.go
··· 638 638 // Sourcegraph indexserver doesn't set repo.Rank, so we set it here. Setting it 639 639 // on read instead of during indexing allows us to avoid a complete reindex. 640 640 // 641 - // Prefer "latest_commit_date" over "priority" for ranking. We keep priority for 641 + // Prefer "latestCommitDate" over "priority" for ranking. We keep priority for 642 642 // backwards compatibility. 643 - if _, ok := repo.RawConfig["latest_commit_date"]; ok { 643 + if _, ok := repo.RawConfig["latestCommitDate"]; ok { 644 644 // We use the number of months since 1970 as a simple measure of repo freshness. 645 645 // It is monotonically increasing and stable across re-indexes and restarts. 646 646 r.Rank = monthsSince1970(repo.LatestCommitDate)
+1 -1
cmd/zoekt-sourcegraph-indexserver/index.go
··· 122 122 "fork": marshalBool(o.Fork), 123 123 "archived": marshalBool(o.Archived), 124 124 // Calculate repo rank based on the latest commit date. 125 - "latest_commit_date": "1", 125 + "latestCommitDate": "1", 126 126 }, 127 127 }, 128 128 IndexDir: o.IndexDir,
+32 -4
cmd/zoekt-sourcegraph-indexserver/index_test.go
··· 14 14 "time" 15 15 16 16 "github.com/sourcegraph/log/logtest" 17 + "github.com/stretchr/testify/require" 17 18 "google.golang.org/grpc" 18 19 "google.golang.org/protobuf/testing/protocmp" 19 20 "google.golang.org/protobuf/types/known/timestamppb" ··· 494 495 "git -C $TMPDIR/test%2Frepo.git update-ref HEAD deadbeef", 495 496 "git -C $TMPDIR/test%2Frepo.git config zoekt.archived 0", 496 497 "git -C $TMPDIR/test%2Frepo.git config zoekt.fork 0", 497 - "git -C $TMPDIR/test%2Frepo.git config zoekt.latest_commit_date 1", 498 + "git -C $TMPDIR/test%2Frepo.git config zoekt.latestCommitDate 1", 498 499 "git -C $TMPDIR/test%2Frepo.git config zoekt.name test/repo", 499 500 "git -C $TMPDIR/test%2Frepo.git config zoekt.priority 0", 500 501 "git -C $TMPDIR/test%2Frepo.git config zoekt.public 0", ··· 517 518 "git -C $TMPDIR/test%2Frepo.git update-ref HEAD deadbeef", 518 519 "git -C $TMPDIR/test%2Frepo.git config zoekt.archived 0", 519 520 "git -C $TMPDIR/test%2Frepo.git config zoekt.fork 0", 520 - "git -C $TMPDIR/test%2Frepo.git config zoekt.latest_commit_date 1", 521 + "git -C $TMPDIR/test%2Frepo.git config zoekt.latestCommitDate 1", 521 522 "git -C $TMPDIR/test%2Frepo.git config zoekt.name test/repo", 522 523 "git -C $TMPDIR/test%2Frepo.git config zoekt.priority 0", 523 524 "git -C $TMPDIR/test%2Frepo.git config zoekt.public 0", ··· 549 550 "git -C $TMPDIR/test%2Frepo.git update-ref refs/heads/dev feebdaed", 550 551 "git -C $TMPDIR/test%2Frepo.git config zoekt.archived 0", 551 552 "git -C $TMPDIR/test%2Frepo.git config zoekt.fork 0", 552 - "git -C $TMPDIR/test%2Frepo.git config zoekt.latest_commit_date 1", 553 + "git -C $TMPDIR/test%2Frepo.git config zoekt.latestCommitDate 1", 553 554 "git -C $TMPDIR/test%2Frepo.git config zoekt.name test/repo", 554 555 "git -C $TMPDIR/test%2Frepo.git config zoekt.priority 0", 555 556 "git -C $TMPDIR/test%2Frepo.git config zoekt.public 0", ··· 597 598 "git -C $TMPDIR/test%2Frepo.git update-ref refs/heads/release 12345678", 598 599 "git -C $TMPDIR/test%2Frepo.git config zoekt.archived 0", 599 600 "git -C $TMPDIR/test%2Frepo.git config zoekt.fork 0", 600 - "git -C $TMPDIR/test%2Frepo.git config zoekt.latest_commit_date 1", 601 + "git -C $TMPDIR/test%2Frepo.git config zoekt.latestCommitDate 1", 601 602 "git -C $TMPDIR/test%2Frepo.git config zoekt.name test/repo", 602 603 "git -C $TMPDIR/test%2Frepo.git config zoekt.priority 0", 603 604 "git -C $TMPDIR/test%2Frepo.git config zoekt.public 0", ··· 685 686 } 686 687 687 688 var _ proto.ZoektConfigurationServiceClient = &mockGRPCClient{} 689 + 690 + // Tests whether we can set git config values without error. 691 + func TestSetZoektConfig(t *testing.T) { 692 + dir := t.TempDir() 693 + 694 + // init git dir 695 + script := `mkdir repo 696 + cd repo 697 + git init -b main 698 + ` 699 + cmd := exec.Command("/bin/sh", "-euxc", script) 700 + cmd.Dir = dir 701 + _, err := cmd.CombinedOutput() 702 + require.NoError(t, err) 703 + 704 + var out []byte 705 + c := gitIndexConfig{ 706 + runCmd: func(cmd *exec.Cmd) error { 707 + var err error 708 + out, err = cmd.CombinedOutput() 709 + return err 710 + }, 711 + } 712 + 713 + err = setZoektConfig(context.Background(), filepath.Join(dir, "repo"), &indexArgs{}, c) 714 + require.NoError(t, err, string(out)) 715 + }
+1 -1
internal/e2e/e2e_rank_test.go
··· 254 254 RepositoryDescription: zoekt.Repository{ 255 255 // Use the latest commit date to calculate the repo rank when loading the shard. 256 256 // This is the same setting we use in production. 257 - RawConfig: map[string]string{"latest_commit_date": "1"}, 257 + RawConfig: map[string]string{"latestCommitDate": "1"}, 258 258 }, 259 259 }) 260 260 if err != nil {