소스 검색

Fixed gofmt formating, updated precommit hook

Torkel Ödegaard 10 년 전
부모
커밋
ebad9cb502
3개의 변경된 파일40개의 추가작업 그리고 33개의 파일을 삭제
  1. 7 0
      .hooks/pre-commit
  2. 32 32
      pkg/services/sqlstore/migrations/user_mig.go
  3. 1 1
      pkg/services/sqlstore/stars_test.go

+ 7 - 0
.hooks/pre-commit

@@ -0,0 +1,7 @@
+#!/usr/bin/env bash
+
+test -z "$(gofmt -s -l . | grep -v Godeps/_workspace/src/ | tee /dev/stderr)"
+if [ $? -gt 0 ]; then
+    echo "Some files aren't formatted, please run 'go fmt ./pkg/...' to format your source code before committing"
+    exit 1
+fi

+ 32 - 32
pkg/services/sqlstore/migrations/user_mig.go

@@ -6,23 +6,23 @@ func addUserMigrations(mg *Migrator) {
 	userV1 := Table{
 		Name: "user",
 		Columns: []*Column{
-			&Column{Name: "id", Type: DB_BigInt, IsPrimaryKey: true, IsAutoIncrement: true},
-			&Column{Name: "version", Type: DB_Int, Nullable: false},
-			&Column{Name: "login", Type: DB_NVarchar, Length: 255, Nullable: false},
-			&Column{Name: "email", Type: DB_NVarchar, Length: 255, Nullable: false},
-			&Column{Name: "name", Type: DB_NVarchar, Length: 255, Nullable: true},
-			&Column{Name: "password", Type: DB_NVarchar, Length: 255, Nullable: true},
-			&Column{Name: "salt", Type: DB_NVarchar, Length: 50, Nullable: true},
-			&Column{Name: "rands", Type: DB_NVarchar, Length: 50, Nullable: true},
-			&Column{Name: "company", Type: DB_NVarchar, Length: 255, Nullable: true},
-			&Column{Name: "account_id", Type: DB_BigInt, Nullable: false},
-			&Column{Name: "is_admin", Type: DB_Bool, Nullable: false},
-			&Column{Name: "created", Type: DB_DateTime, Nullable: false},
-			&Column{Name: "updated", Type: DB_DateTime, Nullable: false},
+			{Name: "id", Type: DB_BigInt, IsPrimaryKey: true, IsAutoIncrement: true},
+			{Name: "version", Type: DB_Int, Nullable: false},
+			{Name: "login", Type: DB_NVarchar, Length: 255, Nullable: false},
+			{Name: "email", Type: DB_NVarchar, Length: 255, Nullable: false},
+			{Name: "name", Type: DB_NVarchar, Length: 255, Nullable: true},
+			{Name: "password", Type: DB_NVarchar, Length: 255, Nullable: true},
+			{Name: "salt", Type: DB_NVarchar, Length: 50, Nullable: true},
+			{Name: "rands", Type: DB_NVarchar, Length: 50, Nullable: true},
+			{Name: "company", Type: DB_NVarchar, Length: 255, Nullable: true},
+			{Name: "account_id", Type: DB_BigInt, Nullable: false},
+			{Name: "is_admin", Type: DB_Bool, Nullable: false},
+			{Name: "created", Type: DB_DateTime, Nullable: false},
+			{Name: "updated", Type: DB_DateTime, Nullable: false},
 		},
 		Indices: []*Index{
-			&Index{Cols: []string{"login"}, Type: UniqueIndex},
-			&Index{Cols: []string{"email"}, Type: UniqueIndex},
+			{Cols: []string{"login"}, Type: UniqueIndex},
+			{Cols: []string{"email"}, Type: UniqueIndex},
 		},
 	}
 
@@ -45,25 +45,25 @@ func addUserMigrations(mg *Migrator) {
 	userV2 := Table{
 		Name: "user",
 		Columns: []*Column{
-			&Column{Name: "id", Type: DB_BigInt, IsPrimaryKey: true, IsAutoIncrement: true},
-			&Column{Name: "version", Type: DB_Int, Nullable: false},
-			&Column{Name: "login", Type: DB_NVarchar, Length: 255, Nullable: false},
-			&Column{Name: "email", Type: DB_NVarchar, Length: 255, Nullable: false},
-			&Column{Name: "name", Type: DB_NVarchar, Length: 255, Nullable: true},
-			&Column{Name: "password", Type: DB_NVarchar, Length: 255, Nullable: true},
-			&Column{Name: "salt", Type: DB_NVarchar, Length: 50, Nullable: true},
-			&Column{Name: "rands", Type: DB_NVarchar, Length: 50, Nullable: true},
-			&Column{Name: "company", Type: DB_NVarchar, Length: 255, Nullable: true},
-			&Column{Name: "org_id", Type: DB_BigInt, Nullable: false},
-			&Column{Name: "is_admin", Type: DB_Bool, Nullable: false},
-			&Column{Name: "email_verified", Type: DB_Bool, Nullable: true},
-			&Column{Name: "theme", Type: DB_NVarchar, Length: 255, Nullable: true},
-			&Column{Name: "created", Type: DB_DateTime, Nullable: false},
-			&Column{Name: "updated", Type: DB_DateTime, Nullable: false},
+			{Name: "id", Type: DB_BigInt, IsPrimaryKey: true, IsAutoIncrement: true},
+			{Name: "version", Type: DB_Int, Nullable: false},
+			{Name: "login", Type: DB_NVarchar, Length: 255, Nullable: false},
+			{Name: "email", Type: DB_NVarchar, Length: 255, Nullable: false},
+			{Name: "name", Type: DB_NVarchar, Length: 255, Nullable: true},
+			{Name: "password", Type: DB_NVarchar, Length: 255, Nullable: true},
+			{Name: "salt", Type: DB_NVarchar, Length: 50, Nullable: true},
+			{Name: "rands", Type: DB_NVarchar, Length: 50, Nullable: true},
+			{Name: "company", Type: DB_NVarchar, Length: 255, Nullable: true},
+			{Name: "org_id", Type: DB_BigInt, Nullable: false},
+			{Name: "is_admin", Type: DB_Bool, Nullable: false},
+			{Name: "email_verified", Type: DB_Bool, Nullable: true},
+			{Name: "theme", Type: DB_NVarchar, Length: 255, Nullable: true},
+			{Name: "created", Type: DB_DateTime, Nullable: false},
+			{Name: "updated", Type: DB_DateTime, Nullable: false},
 		},
 		Indices: []*Index{
-			&Index{Cols: []string{"login"}, Type: UniqueIndex},
-			&Index{Cols: []string{"email"}, Type: UniqueIndex},
+			{Cols: []string{"login"}, Type: UniqueIndex},
+			{Cols: []string{"email"}, Type: UniqueIndex},
 		},
 	}
 

+ 1 - 1
pkg/services/sqlstore/stars_test.go

@@ -3,8 +3,8 @@ package sqlstore
 import (
 	"testing"
 
-	. "github.com/smartystreets/goconvey/convey"
 	m "github.com/grafana/grafana/pkg/models"
+	. "github.com/smartystreets/goconvey/convey"
 )
 
 func TestUserStarsDataAccess(t *testing.T) {