Skip to content

Commit

Permalink
Merge pull request #18 from bbkane/git-xargs/update-goreleaser
Browse files Browse the repository at this point in the history
Update goreleasor YAML keys
  • Loading branch information
bbkane authored Mar 3, 2024
2 parents 0e27502 + bddde1c commit 9ccbee9
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 12 deletions.
19 changes: 9 additions & 10 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ brews:
description: GNU Stow alternative for dotfiles
folder: Formula
homepage: https://github.com/bbkane/fling
tap:
repository:
name: homebrew-tap
owner: bbkane
# Optionally a token can be provided, if it differs from the token provided to GoReleaser
Expand All @@ -43,12 +43,11 @@ changelog:
sort: asc
checksum:
name_template: checksums.txt
# https://goreleaser.com/customization/scoop/
scoop:
bucket:
name: scoop-bucket
owner: bbkane
token: '{{ .Env.KEY_GITHUB_GORELEASER_TO_HOMEBREW_TAP }}'
description: fling computes and creates/removes the minimal amount of symlinks needed in a directory to refer to files and directories in another directory, similar to GNU Stow. I use fling to manage my dotfiles
homepage: https://github.com/bbkane/fling
license: MIT
scoops:
- description: fling computes and creates/removes the minimal amount of symlinks needed in a directory to refer to files and directories in another directory, similar to GNU Stow. I use fling to manage my dotfiles
homepage: https://github.com/bbkane/fling
license: MIT
repository:
name: scoop-bucket
owner: bbkane
token: '{{ .Env.KEY_GITHUB_GORELEASER_TO_HOMEBREW_TAP }}'
38 changes: 36 additions & 2 deletions link_unlink.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ package main

import (
"bufio"
"cmp"
"errors"
"fmt"
"io/fs"
"os"
"path/filepath"
"regexp"
"slices"
"strings"

"github.com/karrick/godirwalk"
Expand Down Expand Up @@ -120,12 +122,12 @@ func (t ignoredPath) ColorString(color *gocolor.Color) string {

type fileInfo struct {
dirLinksToCreate []dirLinkToCreate
fileLinksToCreate []fileLinkToCreate
existingDirLinks []existingDirLink
existingFileLinks []existingFileLink
fileLinksToCreate []fileLinkToCreate
ignoredPaths []ignoredPath
pathErrs []pathErr
pathsErrs []pathsErr
ignoredPaths []ignoredPath
}

func fPrintHeader(f *bufio.Writer, color *gocolor.Color, header string) {
Expand Down Expand Up @@ -373,6 +375,38 @@ func buildFileInfo(srcDir string, linkDir string, ignorePatterns []string, isDot
return nil, fmt.Errorf("walking error: %w", err)
}

// sort all fields so all traversals of the same directory
// produce the same struct - needed for tests

// https://pkg.go.dev/slices#example-SortFunc-MultiField
compareLinks := func(a, b linkT) int {
if n := cmp.Compare(a.link, b.link); n != 0 {
return n
}
return cmp.Compare(a.src, b.src)
}

slices.SortFunc(fi.dirLinksToCreate, compareLinks)
slices.SortFunc(fi.existingDirLinks, compareLinks)
slices.SortFunc(fi.existingFileLinks, compareLinks)
slices.SortFunc(fi.fileLinksToCreate, compareLinks)
slices.Sort(fi.ignoredPaths)
slices.SortFunc(fi.pathErrs, func(a, b pathErr) int {
if n := cmp.Compare(a.path, b.path); n != 0 {
return n
}
return cmp.Compare(a.err.Error(), b.err.Error())
})
slices.SortFunc(fi.pathsErrs, func(a pathsErr, b pathsErr) int {
if n := cmp.Compare(a.link, b.link); n != 0 {
return n
}
if n := cmp.Compare(a.src, b.src); n != 0 {
return n
}
return cmp.Compare(a.err.Error(), b.err.Error())
})

return &fi, nil

}
Expand Down

0 comments on commit 9ccbee9

Please sign in to comment.