diff --git a/.hooks/pre-commit b/.hooks/pre-commit new file mode 100755 index 00000000000..83ec0adba1a --- /dev/null +++ b/.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 diff --git a/pkg/services/sqlstore/migrations/user_mig.go b/pkg/services/sqlstore/migrations/user_mig.go index d2672917e20..51db4d74857 100644 --- a/pkg/services/sqlstore/migrations/user_mig.go +++ b/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}, }, } diff --git a/pkg/services/sqlstore/stars_test.go b/pkg/services/sqlstore/stars_test.go index 4d6597529ca..4e48dfdbcb3 100644 --- a/pkg/services/sqlstore/stars_test.go +++ b/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) {