Setup husky hooks for api
This commit is contained in:
parent
0a5e6bf350
commit
95c174d3a5
|
@ -0,0 +1,8 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
gofiles=$(git diff --cached --name-only --diff-filter=ACM | grep '.go$')
|
||||||
|
[ -z "$gofiles" ] && exit 0
|
||||||
|
|
||||||
|
# Automatically format go code, exit on error
|
||||||
|
echo "Formatting staged go files"
|
||||||
|
gofmt -w $gofiles
|
|
@ -0,0 +1,4 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
cd ui
|
||||||
|
npx lint-staged
|
|
@ -1,4 +1,8 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
. "$(dirname "$0")/_/husky.sh"
|
. "$(dirname "$0")/_/husky.sh"
|
||||||
|
|
||||||
cd ui && npx lint-staged
|
## Lint UI
|
||||||
|
sh "$(dirname "$0")/lint-ui.sh"
|
||||||
|
|
||||||
|
## Lint API
|
||||||
|
sh "$(dirname "$0")/lint-api.sh"
|
||||||
|
|
|
@ -87,7 +87,7 @@ func (c *AlbumScannerCache) GetMediaType(path string) (*MediaType, error) {
|
||||||
return mediaType, nil
|
return mediaType, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *AlbumScannerCache) GetAlbumIgnore(path string) (*[]string) {
|
func (c *AlbumScannerCache) GetAlbumIgnore(path string) *[]string {
|
||||||
c.mutex.Lock()
|
c.mutex.Lock()
|
||||||
defer c.mutex.Unlock()
|
defer c.mutex.Unlock()
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,6 @@ func SaveEXIF(tx *gorm.DB, media *models.Media) (*models.MediaEXIF, error) {
|
||||||
parser = &externalExifParser{}
|
parser = &externalExifParser{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
exif, err := parser.ParseExif(media)
|
exif, err := parser.ParseExif(media)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "failed to parse exif data")
|
return nil, errors.Wrap(err, "failed to parse exif data")
|
||||||
|
|
|
@ -17,7 +17,7 @@ import (
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
func getPhotoviewIgnore(ignorePath string) ([]string , error){
|
func getPhotoviewIgnore(ignorePath string) ([]string, error) {
|
||||||
var photoviewIgnore []string
|
var photoviewIgnore []string
|
||||||
|
|
||||||
// Open .photoviewignore file, if exists
|
// Open .photoviewignore file, if exists
|
||||||
|
@ -30,13 +30,13 @@ func getPhotoviewIgnore(ignorePath string) ([]string , error){
|
||||||
defer photoviewIgnoreFile.Close()
|
defer photoviewIgnoreFile.Close()
|
||||||
|
|
||||||
// Read and save .photoviewignore data
|
// Read and save .photoviewignore data
|
||||||
scanner := bufio.NewScanner(photoviewIgnoreFile)
|
scanner := bufio.NewScanner(photoviewIgnoreFile)
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
photoviewIgnore = append(photoviewIgnore, scanner.Text())
|
photoviewIgnore = append(photoviewIgnore, scanner.Text())
|
||||||
log.Printf("Ignore found: %s", scanner.Text())
|
log.Printf("Ignore found: %s", scanner.Text())
|
||||||
}
|
}
|
||||||
|
|
||||||
return photoviewIgnore, scanner.Err()
|
return photoviewIgnore, scanner.Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
func findAlbumsForUser(db *gorm.DB, user *models.User, album_cache *AlbumScannerCache) ([]*models.Album, []error) {
|
func findAlbumsForUser(db *gorm.DB, user *models.User, album_cache *AlbumScannerCache) ([]*models.Album, []error) {
|
||||||
|
@ -101,7 +101,7 @@ func findAlbumsForUser(db *gorm.DB, user *models.User, album_cache *AlbumScanner
|
||||||
|
|
||||||
// Skip this dir if in ignore list
|
// Skip this dir if in ignore list
|
||||||
ignorePaths := ignore.CompileIgnoreLines(albumIgnore...)
|
ignorePaths := ignore.CompileIgnoreLines(albumIgnore...)
|
||||||
if (ignorePaths.MatchesPath(albumPath + "/")) {
|
if ignorePaths.MatchesPath(albumPath + "/") {
|
||||||
log.Printf("Skip, directroy %s is in ignore file", albumPath)
|
log.Printf("Skip, directroy %s is in ignore file", albumPath)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue