Skip to content

Commit

Permalink
all: gofmt -w -s .
Browse files Browse the repository at this point in the history
  • Loading branch information
keegancsmith committed Sep 13, 2022
1 parent c70c729 commit bf39095
Show file tree
Hide file tree
Showing 19 changed files with 120 additions and 100 deletions.
2 changes: 2 additions & 0 deletions build/builder_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//go:build !windows
// +build !windows

package build
Expand Down
4 changes: 2 additions & 2 deletions cmd/zoekt-archive-index/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
//
// Example via github.com:
//
// zoekt-archive-index -incremental -commit b57cb1605fd11ba2ecfa7f68992b4b9cc791934d -name github.com/gorilla/mux -strip_components 1 https://codeload.github.com/gorilla/mux/legacy.tar.gz/b57cb1605fd11ba2ecfa7f68992b4b9cc791934d
// zoekt-archive-index -incremental -commit b57cb1605fd11ba2ecfa7f68992b4b9cc791934d -name github.com/gorilla/mux -strip_components 1 https://codeload.github.com/gorilla/mux/legacy.tar.gz/b57cb1605fd11ba2ecfa7f68992b4b9cc791934d
//
// zoekt-archive-index -branch master https://github.com/gorilla/mux/commit/b57cb1605fd11ba2ecfa7f68992b4b9cc791934d
// zoekt-archive-index -branch master https://github.com/gorilla/mux/commit/b57cb1605fd11ba2ecfa7f68992b4b9cc791934d
package main

import (
Expand Down
2 changes: 1 addition & 1 deletion cmd/zoekt-mirror-gerrit/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ func deleteStaleRepos(destDir string, filter *gitindex.Filter, repos map[string]
}

names := map[string]struct{}{}
for name, _ := range repos {
for name := range repos {
u, err := url.Parse(strings.Replace(projectURL, "${project}", name, 1))
if err != nil {
return err
Expand Down
6 changes: 3 additions & 3 deletions cmd/zoekt-mirror-gitlab/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
// In addition, the token should be present in the ~/.netrc of the user running
// the mirror command. For example, the ~/.netrc may look like:
//
// machine gitlab.com
// login oauth
// password <personal access token>
// machine gitlab.com
// login oauth
// password <personal access token>
package main

import (
Expand Down
27 changes: 13 additions & 14 deletions cmd/zoekt-repo-index/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,19 @@
// See the License for the specific language governing permissions and
// limitations under the License.

/* zoekt-repo-index indexes a repo-based repository. The constituent
git repositories should already have been downloaded to the
--repo_cache directory, eg.
go install github.com/sourcegraph/zoekt/cmd/zoekt-repo-index &&
zoekt-repo-index -base_url https://gfiber.googlesource.com/ \
-manifest_repo_url https://gfiber.googlesource.com/manifests \
-manifest_rev_prefix=refs/heads/ \
-rev_prefix="refs/remotes/" \
-repo_cache ~/zoekt-serving/repos/ \
-shard_limit 50000000 \
master:default_unrestricted.xml
*/
// zoekt-repo-index indexes a repo-based repository. The constituent git
// repositories should already have been downloaded to the --repo_cache
// directory, eg.
//
// go install github.com/sourcegraph/zoekt/cmd/zoekt-repo-index &&
//
// zoekt-repo-index -base_url https://gfiber.googlesource.com/ \
// -manifest_repo_url https://gfiber.googlesource.com/manifests \
// -manifest_rev_prefix=refs/heads/ \
// -rev_prefix="refs/remotes/" \
// -repo_cache ~/zoekt-serving/repos/ \
// -shard_limit 50000000 \
// master:default_unrestricted.xml
package main

import (
Expand Down
2 changes: 1 addition & 1 deletion cmd/zoekt-sourcegraph-indexserver/cleanup.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func cleanup(indexDir string, repos []uint32, now time.Time, shardMerging bool)

// tombstones: Remove tombstones that conflict with index or trash. After this,
// tombstones only contain repos that are neither in the trash nor in the index.
for repo, _ := range tombtones {
for repo := range tombtones {
if _, conflicts := index[repo]; conflicts {
delete(tombtones, repo)
}
Expand Down
72 changes: 45 additions & 27 deletions cmd/zoekt-sourcegraph-indexserver/cleanup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,20 +319,29 @@ func TestGetTombstonedRepos(t *testing.T) {
// ----
// index/
// CS 1
// r1, tombstoned, old
// r2, tombstoned, old
// r3, tombstoned, old
//
// r1, tombstoned, old
// r2, tombstoned, old
// r3, tombstoned, old
//
// CS 2
// r1, tombstoned, recent
// r2, tombstoned, recent
// r4, tombstoned, recent
//
// r1, tombstoned, recent
// r2, tombstoned, recent
// r4, tombstoned, recent
//
// SS 1
// r1, now
//
// r1, now
//
// .trash/
// SS 3
// r3, now
//
// r3, now
//
// SS 5
// r5, now
//
// r5, now
//
// TO BE INDEXED
// -------------
Expand All @@ -342,21 +351,30 @@ func TestGetTombstonedRepos(t *testing.T) {
// ----
// index/
// CS 1
// r1, tombstoned, old
// r2, tombstoned, old
// r3, tombstoned, old
//
// r1, tombstoned, old
// r2, tombstoned, old
// r3, tombstoned, old
//
// CS 2
// r1, tombstoned, recent
// r2, recent
// r4, recent
//
// r1, tombstoned, recent
// r2, recent
// r4, recent
//
// SS 1
// r1, now
//
// r1, now
//
// SS 3
// r3, now
//
// r3, now
//
// SS 5
// r5, now
// .trash/ --> empty
//
// r5, now
//
// .trash/ --> empty
func TestCleanupCompoundShards(t *testing.T) {
dir := t.TempDir()

Expand Down Expand Up @@ -402,27 +420,27 @@ func TestCleanupCompoundShards(t *testing.T) {
}

wantIndex := map[uint32][]shard{
1: []shard{{
1: {{
RepoID: 1,
RepoName: "repo1",
Path: filepath.Join(dir, "repo1.zoekt"),
}},
2: []shard{{
2: {{
RepoID: 2,
RepoName: "repo2",
Path: cs2,
}},
3: []shard{{
3: {{
RepoID: 3,
RepoName: "repo3",
Path: filepath.Join(dir, "repo3.zoekt"),
}},
4: []shard{{
4: {{
RepoID: 4,
RepoName: "repo4",
Path: cs2,
}},
5: []shard{{
5: {{
RepoID: 5,
RepoName: "repo5",
Path: filepath.Join(dir, "repo5.zoekt"),
Expand Down Expand Up @@ -484,17 +502,17 @@ func TestTombstoneDuplicateShards(t *testing.T) {
}

wantIndex := map[uint32][]shard{
1: []shard{{
1: {{
RepoID: 1,
RepoName: "repo1",
Path: cs2,
}},
2: []shard{{
2: {{
RepoID: 2,
RepoName: "repo2",
Path: cs2,
}},
3: []shard{{
3: {{
RepoID: 3,
RepoName: "repo3",
Path: cs1,
Expand Down
2 changes: 1 addition & 1 deletion cmd/zoekt-sourcegraph-indexserver/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ type queueItem struct {
// Queue is a priority queue which returns the next repo to index. It is safe
// to use concurrently. It is a min queue on:
//
// (!indexed, time added to the queue)
// (!indexed, time added to the queue)
//
// We use the above since:
//
Expand Down
6 changes: 3 additions & 3 deletions eval_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import (

"github.com/RoaringBitmap/roaring"
"github.com/google/go-cmp/cmp"
"github.com/sourcegraph/zoekt/query"
"github.com/grafana/regexp"
"github.com/sourcegraph/zoekt/query"
)

var opnames = map[syntax.Op]string{
Expand Down Expand Up @@ -179,8 +179,8 @@ func compoundReposShard(t *testing.T, names ...string) *indexData {
for _, name := range names {
repos = append(repos, &Repository{ID: hash(name), Name: name})
ds := []Document{
Document{Name: name + ".txt", Content: []byte(name + " content")},
Document{Name: name + ".2.txt", Content: []byte(name + " content 2")},
{Name: name + ".txt", Content: []byte(name + " content")},
{Name: name + ".2.txt", Content: []byte(name + " content 2")},
}
docs = append(docs, ds)
}
Expand Down
2 changes: 1 addition & 1 deletion gitindex/tree_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ import (
"time"

"github.com/google/go-cmp/cmp"
"github.com/grafana/regexp"
"github.com/sourcegraph/zoekt"
"github.com/sourcegraph/zoekt/build"
"github.com/sourcegraph/zoekt/query"
"github.com/sourcegraph/zoekt/shards"
"github.com/grafana/regexp"
)

func createSubmoduleRepo(dir string) error {
Expand Down
44 changes: 22 additions & 22 deletions index_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ import (

"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/sourcegraph/zoekt/query"
"github.com/grafana/regexp"
"github.com/kylelemons/godebug/pretty"
"github.com/sourcegraph/zoekt/query"
)

func clearScores(r *SearchResult) {
Expand Down Expand Up @@ -2863,13 +2863,13 @@ func TestSymbolRegexpPartial(t *testing.T) {

func TestSymbolRegexpAll(t *testing.T) {
docs := []Document{
Document{
{
Name: "f1",
Content: []byte("Hello Zoekt"),
// --------------01234567890
Symbols: []DocumentSection{{0, 5}, {6, 11}},
},
Document{
{
Name: "f2",
Content: []byte("Second Zoekt Third"),
// --------------012345678901234567
Expand Down Expand Up @@ -3434,7 +3434,7 @@ func TestStats(t *testing.T) {
b := testIndexBuilder(t, nil)
got := repoListEntries(b)
want := []RepoListEntry{
RepoListEntry{
{
Stats: RepoStats{
Repos: 0,
Shards: 1,
Expand All @@ -3461,7 +3461,7 @@ func TestStats(t *testing.T) {
)
got := repoListEntries(b)
want := []RepoListEntry{
RepoListEntry{
{
Stats: RepoStats{
Repos: 0,
Shards: 1,
Expand All @@ -3484,23 +3484,23 @@ func TestStats(t *testing.T) {
t.Run("one compound shard", func(t *testing.T) {
b := testIndexBuilderCompound(t,
[]*Repository{
&Repository{Name: "repo 0"},
&Repository{Name: "repo 1"},
{Name: "repo 0"},
{Name: "repo 1"},
},
[][]Document{
[]Document{
Document{Name: "doc 0", Content: []byte("content 0")},
Document{Name: "doc 1", Content: []byte("content 1")},
{
{Name: "doc 0", Content: []byte("content 0")},
{Name: "doc 1", Content: []byte("content 1")},
},
[]Document{
Document{Name: "doc 2", Content: []byte("content 2")},
Document{Name: "doc 3", Content: []byte("content 3")},
{
{Name: "doc 2", Content: []byte("content 2")},
{Name: "doc 3", Content: []byte("content 3")},
},
},
)
got := repoListEntries(b)
want := []RepoListEntry{
RepoListEntry{
{
Stats: RepoStats{
Repos: 0,
Shards: 1,
Expand All @@ -3512,7 +3512,7 @@ func TestStats(t *testing.T) {
OtherBranchesNewLinesCount: 0,
},
},
RepoListEntry{
{
Stats: RepoStats{
Repos: 0,
Shards: 1,
Expand All @@ -3534,16 +3534,16 @@ func TestStats(t *testing.T) {
t.Run("compound shard with empty repos", func(t *testing.T) {
b := testIndexBuilderCompound(t,
[]*Repository{
&Repository{Name: "repo 0"},
&Repository{Name: "repo 1"},
&Repository{Name: "repo 2"},
&Repository{Name: "repo 3"},
&Repository{Name: "repo 4"},
{Name: "repo 0"},
{Name: "repo 1"},
{Name: "repo 2"},
{Name: "repo 3"},
{Name: "repo 4"},
},
[][]Document{
[]Document{Document{Name: "doc 0", Content: []byte("content 0")}},
{{Name: "doc 0", Content: []byte("content 0")}},
nil,
[]Document{Document{Name: "doc 1", Content: []byte("content 1")}},
{{Name: "doc 1", Content: []byte("content 1")}},
nil,
nil,
},
Expand Down
1 change: 1 addition & 0 deletions indexfile_other.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build !linux && !darwin
// +build !linux,!darwin

package zoekt
Expand Down
Loading

0 comments on commit bf39095

Please sign in to comment.