As we reevaluate how to best support and maintain Staging Ref in the future, we encourage development teams using this environment to highlight their use cases in the following issue: https://gitlab.com/gitlab-com/gl-infra/software-delivery/framework/software-delivery-framework-issue-tracker/-/issues/36.

Skip to content
Snippets Groups Projects
Unverified Commit f3f0958b authored by Ash McKenzie's avatar Ash McKenzie Committed by GitLab
Browse files

Merge branch '792-gitlabnet-git-lint' into 'main'

Lint fixes in gitlabnet git package

Closes #792

See merge request https://gitlab.com/gitlab-org/gitlab-shell/-/merge_requests/1149



Merged-by: default avatarAsh McKenzie <amckenzie@gitlab.com>
Approved-by: default avatarAsh McKenzie <amckenzie@gitlab.com>
Co-authored-by: default avatarArchish <archishthakkar@gmail.com>
parents e480a63d f10dffc7
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -34,7 +34,7 @@ func buildTestHandlers(code int, rsp *healthcheck.Response) []testserver.TestReq
return []testserver.TestRequestHandler{
{
Path: "/api/v4/internal/check",
Handler: func(w http.ResponseWriter, r *http.Request) {
Handler: func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(code)
if rsp != nil {
json.NewEncoder(w).Encode(rsp)
Loading
Loading
Loading
Loading
@@ -7,6 +7,7 @@ import (
"net/http"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
httpclient "gitlab.com/gitlab-org/gitlab-shell/v14/client"
"gitlab.com/gitlab-org/gitlab-shell/v14/client/testserver"
Loading
Loading
@@ -16,6 +17,7 @@ var customHeaders = map[string]string{
"Authorization": "Bearer: token",
"Header-One": "Value-Two",
}
var refsBody = "0032want 0a53e9ddeaddad63ad106860237bbf53411d11a7\n"
func TestInfoRefs(t *testing.T) {
client := setup(t)
Loading
Loading
@@ -53,7 +55,6 @@ func TestReceivePack(t *testing.T) {
func TestUploadPack(t *testing.T) {
client := setup(t)
refsBody := "0032want 0a53e9ddeaddad63ad106860237bbf53411d11a7\n"
response, err := client.UploadPack(context.Background(), bytes.NewReader([]byte(refsBody)))
require.NoError(t, err)
defer response.Body.Close()
Loading
Loading
@@ -67,7 +68,6 @@ func TestUploadPack(t *testing.T) {
func TestSSHUploadPack(t *testing.T) {
client := setup(t)
refsBody := "0032want 0a53e9ddeaddad63ad106860237bbf53411d11a7\n"
response, err := client.SSHUploadPack(context.Background(), bytes.NewReader([]byte(refsBody)))
require.NoError(t, err)
defer response.Body.Close()
Loading
Loading
@@ -81,7 +81,6 @@ func TestSSHUploadPack(t *testing.T) {
func TestSSHReceivePack(t *testing.T) {
client := setup(t)
refsBody := "0032want 0a53e9ddeaddad63ad106860237bbf53411d11a7\n"
response, err := client.SSHReceivePack(context.Background(), bytes.NewReader([]byte(refsBody)))
require.NoError(t, err)
defer response.Body.Close()
Loading
Loading
@@ -157,8 +156,8 @@ func setup(t *testing.T) *Client {
{
Path: "/info/refs",
Handler: func(w http.ResponseWriter, r *http.Request) {
require.Equal(t, customHeaders["Authorization"], r.Header.Get("Authorization"))
require.Equal(t, customHeaders["Header-One"], r.Header.Get("Header-One"))
assert.Equal(t, customHeaders["Authorization"], r.Header.Get("Authorization"))
assert.Equal(t, customHeaders["Header-One"], r.Header.Get("Header-One"))
w.Write([]byte(r.URL.Query().Get("service")))
},
Loading
Loading
@@ -166,13 +165,13 @@ func setup(t *testing.T) *Client {
{
Path: "/git-receive-pack",
Handler: func(w http.ResponseWriter, r *http.Request) {
require.Equal(t, customHeaders["Authorization"], r.Header.Get("Authorization"))
require.Equal(t, customHeaders["Header-One"], r.Header.Get("Header-One"))
require.Equal(t, "application/x-git-receive-pack-request", r.Header.Get("Content-Type"))
require.Equal(t, "application/x-git-receive-pack-result", r.Header.Get("Accept"))
assert.Equal(t, customHeaders["Authorization"], r.Header.Get("Authorization"))
assert.Equal(t, customHeaders["Header-One"], r.Header.Get("Header-One"))
assert.Equal(t, "application/x-git-receive-pack-request", r.Header.Get("Content-Type"))
assert.Equal(t, "application/x-git-receive-pack-result", r.Header.Get("Accept"))
body, err := io.ReadAll(r.Body)
require.NoError(t, err)
assert.NoError(t, err)
defer r.Body.Close()
w.Write([]byte("git-receive-pack: "))
Loading
Loading
@@ -182,13 +181,13 @@ func setup(t *testing.T) *Client {
{
Path: "/git-upload-pack",
Handler: func(w http.ResponseWriter, r *http.Request) {
require.Equal(t, customHeaders["Authorization"], r.Header.Get("Authorization"))
require.Equal(t, customHeaders["Header-One"], r.Header.Get("Header-One"))
require.Equal(t, "application/x-git-upload-pack-request", r.Header.Get("Content-Type"))
require.Equal(t, "application/x-git-upload-pack-result", r.Header.Get("Accept"))
assert.Equal(t, customHeaders["Authorization"], r.Header.Get("Authorization"))
assert.Equal(t, customHeaders["Header-One"], r.Header.Get("Header-One"))
assert.Equal(t, "application/x-git-upload-pack-request", r.Header.Get("Content-Type"))
assert.Equal(t, "application/x-git-upload-pack-result", r.Header.Get("Accept"))
_, err := io.ReadAll(r.Body)
require.NoError(t, err)
assert.NoError(t, err)
defer r.Body.Close()
w.Write([]byte("git-upload-pack: content"))
Loading
Loading
@@ -197,11 +196,11 @@ func setup(t *testing.T) *Client {
{
Path: sshUploadPackPath,
Handler: func(w http.ResponseWriter, r *http.Request) {
require.Equal(t, customHeaders["Authorization"], r.Header.Get("Authorization"))
require.Equal(t, customHeaders["Header-One"], r.Header.Get("Header-One"))
assert.Equal(t, customHeaders["Authorization"], r.Header.Get("Authorization"))
assert.Equal(t, customHeaders["Header-One"], r.Header.Get("Header-One"))
_, err := io.ReadAll(r.Body)
require.NoError(t, err)
assert.NoError(t, err)
defer r.Body.Close()
w.Write([]byte("ssh-upload-pack: content"))
Loading
Loading
@@ -210,11 +209,11 @@ func setup(t *testing.T) *Client {
{
Path: sshReceivePackPath,
Handler: func(w http.ResponseWriter, r *http.Request) {
require.Equal(t, customHeaders["Authorization"], r.Header.Get("Authorization"))
require.Equal(t, customHeaders["Header-One"], r.Header.Get("Header-One"))
assert.Equal(t, customHeaders["Authorization"], r.Header.Get("Authorization"))
assert.Equal(t, customHeaders["Header-One"], r.Header.Get("Header-One"))
_, err := io.ReadAll(r.Body)
require.NoError(t, err)
assert.NoError(t, err)
defer r.Body.Close()
w.Write([]byte("ssh-receive-pack: content"))
Loading
Loading
Loading
Loading
@@ -127,7 +127,6 @@ internal/command/healthcheck/healthcheck.go:17:6: exported: exported type Comman
internal/command/healthcheck/healthcheck.go:22:1: exported: exported method Command.Execute should have comment or be unexported (revive)
internal/command/healthcheck/healthcheck.go:28:13: Error return value of `fmt.Fprintf` is not checked (errcheck)
internal/command/healthcheck/healthcheck.go:34:13: Error return value of `fmt.Fprintf` is not checked (errcheck)
internal/command/healthcheck/healthcheck_test.go:37:41: unused-parameter: parameter 'r' seems to be unused, consider removing or renaming it as _ (revive)
internal/command/lfsauthenticate/lfsauthenticate.go:87:13: Error return value of `fmt.Fprintf` is not checked (errcheck)
internal/command/lfsauthenticate/lfsauthenticate_test.go:76:5: go-require: do not use require in http handlers (testifylint)
internal/command/lfsauthenticate/lfsauthenticate_test.go:79:5: go-require: do not use require in http handlers (testifylint)
Loading
Loading
@@ -279,26 +278,6 @@ internal/gitlabnet/client.go:14:1: exported: exported function GetClient should
internal/gitlabnet/client.go:21:15: ST1005: error strings should not be capitalized (stylecheck)
internal/gitlabnet/client.go:27:1: exported: exported function ParseJSON should have comment or be unexported (revive)
internal/gitlabnet/client.go:35:1: exported: exported function ParseIP should have comment or be unexported (revive)
internal/gitlabnet/git/client_test.go:56:14: string `0032want 0a53e9ddeaddad63ad106860237bbf53411d11a7
` has 3 occurrences, make it a constant (goconst)
internal/gitlabnet/git/client_test.go:160:5: go-require: do not use require in http handlers (testifylint)
internal/gitlabnet/git/client_test.go:161:5: go-require: do not use require in http handlers (testifylint)
internal/gitlabnet/git/client_test.go:169:5: go-require: do not use require in http handlers (testifylint)
internal/gitlabnet/git/client_test.go:170:5: go-require: do not use require in http handlers (testifylint)
internal/gitlabnet/git/client_test.go:171:5: go-require: do not use require in http handlers (testifylint)
internal/gitlabnet/git/client_test.go:172:5: go-require: do not use require in http handlers (testifylint)
internal/gitlabnet/git/client_test.go:175:5: go-require: do not use require in http handlers (testifylint)
internal/gitlabnet/git/client_test.go:185:5: go-require: do not use require in http handlers (testifylint)
internal/gitlabnet/git/client_test.go:186:5: go-require: do not use require in http handlers (testifylint)
internal/gitlabnet/git/client_test.go:187:5: go-require: do not use require in http handlers (testifylint)
internal/gitlabnet/git/client_test.go:188:5: go-require: do not use require in http handlers (testifylint)
internal/gitlabnet/git/client_test.go:191:5: go-require: do not use require in http handlers (testifylint)
internal/gitlabnet/git/client_test.go:200:5: go-require: do not use require in http handlers (testifylint)
internal/gitlabnet/git/client_test.go:201:5: go-require: do not use require in http handlers (testifylint)
internal/gitlabnet/git/client_test.go:204:5: go-require: do not use require in http handlers (testifylint)
internal/gitlabnet/git/client_test.go:213:5: go-require: do not use require in http handlers (testifylint)
internal/gitlabnet/git/client_test.go:214:5: go-require: do not use require in http handlers (testifylint)
internal/gitlabnet/git/client_test.go:217:5: go-require: do not use require in http handlers (testifylint)
internal/gitlabnet/healthcheck/client_test.go:19:41: unused-parameter: parameter 'r' seems to be unused, consider removing or renaming it as _ (revive)
internal/gitlabnet/lfsauthenticate/client_test.go:29:5: go-require: do not use require in http handlers (testifylint)
internal/gitlabnet/lfsauthenticate/client_test.go:32:5: go-require: do not use require in http handlers (testifylint)
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment