Skip to content
This repository has been archived by the owner on Mar 24, 2024. It is now read-only.

Commit

Permalink
feat: fleek-provided aliases for updating and version checks (#297)
Browse files Browse the repository at this point in the history
* feat: fleek-provided aliases for updating and version checks

* fix: git status parsing buffer error
  • Loading branch information
bketelsen authored Sep 24, 2023
1 parent c01686d commit 79ba0cf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
8 changes: 4 additions & 4 deletions internal/flake/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ func (f *Flake) add() error {
func (f *Flake) commit(message string) error {
status, err := f.gitStatus()
if err != nil {
return err
return errors.New("error parsing git status")
}
if status.Empty() {
fin.Debug.Println("git status is empty, skipping commit")
Expand Down Expand Up @@ -221,14 +221,14 @@ func (f *Flake) push() error {

func (f *Flake) gitStatus() (*fgit.Status, error) {
// git status --ignored --porcelain=v2
cmd := cmdutil.CommandTTY(gitbin, "status", "--ignored", "--porcelain=v2")
cmd, buff := cmdutil.CommandTTYWithBuffer(gitbin, "status", "--ignored", "--porcelain=v2")
cmd.Dir = f.Config.UserFlakeDir()
cmd.Env = os.Environ()
out, err := cmd.Output()
err := cmd.Run()
if err != nil {
return nil, err
}
return fgit.ParseStatusPorcelainV2(out)
return fgit.ParseStatusPorcelainV2(buff.Bytes())

}

Expand Down
17 changes: 14 additions & 3 deletions internal/fleek/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ var (
HighPrograms = []string{"eza", "bat", "atuin", "zoxide"}
)

var systemAliases = map[string]string{
"update-fleek": "nix run \"https://getfleek.dev/latest.tar.gz\" -- update",
"latest-fleek-version": "nix run \"https://getfleek.dev/latest.tar.gz\" -- version",
}

// Config holds the options that will be
// merged into the home-manager flake.
type Config struct {
Expand Down Expand Up @@ -356,6 +361,13 @@ func (c *Config) UserForSystem(system string) *User {
return nil
}

func (c *Config) AllAliases() map[string]string {
for k, v := range systemAliases {
c.Aliases[k] = v
}
return c.Aliases
}

func (c *Config) AddPackage(pack string) error {
var found bool
for _, p := range c.Packages {
Expand Down Expand Up @@ -487,8 +499,7 @@ func ReadConfig(loc string) (*Config, error) {
}

func (c *Config) WriteInitialConfig(force bool, symlink bool) error {
aliases := make(map[string]string)
aliases["fleeks"] = "cd ~/" + c.FlakeDir
systemAliases["fleeks"] = "cd ~/" + c.FlakeDir
sys, err := NewSystem()
if err != nil {
fin.Debug.Printfln("new system err: %s ", err)
Expand All @@ -509,7 +520,7 @@ func (c *Config) WriteInitialConfig(force bool, symlink bool) error {
c.Programs = []string{
"dircolors",
}
c.Aliases = aliases
c.Aliases = systemAliases
c.Paths = []string{
"$HOME/bin",
"$HOME/.local/bin",
Expand Down

0 comments on commit 79ba0cf

Please sign in to comment.