Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add version marker #1720

Merged
merged 4 commits into from
Mar 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions .github/workflows/tag.yml

This file was deleted.

7 changes: 2 additions & 5 deletions .github/workflows/testing-git.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
name: Test against pacman-git
# This workflow is triggered on pushes to the repository.
on:
push:
pull_request:
paths-ignore:
- "doc/**"
- "**/*.po"
- "README.md"
- ".gitignore"
branches-ignore:
- "master"
pull_request:

jobs:
build:
Expand Down
7 changes: 2 additions & 5 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
name: Test against pacman
# This workflow is triggered on pushes to the repository.
on:
push:
pull_request:
paths-ignore:
- "doc/**"
- "**/*.po"
- "README.md"
- ".gitignore"
branches-ignore:
- "master"
pull_request:

jobs:
build:
Expand Down
2 changes: 1 addition & 1 deletion cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ func handleVersion() {
func handlePrint(ctx context.Context, cmdArgs *parser.Arguments, dbExecutor db.Executor) error {
switch {
case cmdArgs.ExistsArg("d", "defaultconfig"):
tmpConfig := settings.DefaultConfig()
tmpConfig := settings.DefaultConfig(yayVersion)
fmt.Printf("%v", tmpConfig)

return nil
Expand Down
9 changes: 7 additions & 2 deletions pkg/settings/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,13 @@ type Configuration struct {
BatchInstall bool `json:"batchinstall"`
SingleLineResults bool `json:"singlelineresults"`
Runtime *Runtime `json:"-"`
Version string `json:"version"`
}

// SaveConfig writes yay config to file.
func (c *Configuration) Save(configPath string) error {
c.Version = c.Runtime.Version

marshalledinfo, err := json.MarshalIndent(c, "", "\t")
if err != nil {
return err
Expand Down Expand Up @@ -171,7 +174,7 @@ func (c *Configuration) setPrivilegeElevator() error {
return &ErrPrivilegeElevatorNotFound{confValue: c.SudoBin}
}

func DefaultConfig() *Configuration {
func DefaultConfig(version string) *Configuration {
return &Configuration{
AURURL: "https://aur.archlinux.org",
BuildDir: os.ExpandEnv("$HOME/.cache/yay"),
Expand Down Expand Up @@ -213,11 +216,12 @@ func DefaultConfig() *Configuration {
EditMenu: false,
UseAsk: false,
CombinedUpgrade: false,
Version: version,
}
}

func NewConfig(version string) (*Configuration, error) {
newConfig := DefaultConfig()
newConfig := DefaultConfig(version)

cacheHome, errCache := getCacheHome()
if errCache != nil {
Expand Down Expand Up @@ -248,6 +252,7 @@ func NewConfig(version string) (*Configuration, error) {

newConfig.Runtime = &Runtime{
ConfigPath: configPath,
Version: version,
Mode: parser.ModeAny,
SaveConfig: false,
CompletionPath: filepath.Join(cacheHome, completionFileName),
Expand Down
14 changes: 7 additions & 7 deletions pkg/settings/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func TestConfiguration_setPrivilegeElevator(t *testing.T) {
os.Chmod(doas, 0o755)
assert.NoError(t, err)

config := DefaultConfig()
config := DefaultConfig("test")
config.SudoLoop = true
config.SudoFlags = "-v"

Expand Down Expand Up @@ -116,7 +116,7 @@ func TestConfiguration_setPrivilegeElevator_su(t *testing.T) {
os.Chmod(doas, 0o755)
assert.NoError(t, err)

config := DefaultConfig()
config := DefaultConfig("test")
config.SudoLoop = true
config.SudoFlags = "-v"

Expand All @@ -138,7 +138,7 @@ func TestConfiguration_setPrivilegeElevator_no_path(t *testing.T) {
oldPath := os.Getenv("PATH")

os.Setenv("PATH", "")
config := DefaultConfig()
config := DefaultConfig("test")
config.SudoLoop = true
config.SudoFlags = "-v"

Expand All @@ -165,7 +165,7 @@ func TestConfiguration_setPrivilegeElevator_doas(t *testing.T) {
os.Chmod(doas, 0o755)
assert.NoError(t, err)

config := DefaultConfig()
config := DefaultConfig("test")
config.SudoLoop = true
config.SudoFlags = "-v"

Expand All @@ -192,7 +192,7 @@ func TestConfiguration_setPrivilegeElevator_custom_script(t *testing.T) {
os.Chmod(wrapper, 0o755)
assert.NoError(t, err)

config := DefaultConfig()
config := DefaultConfig("test")
config.SudoLoop = true
config.SudoBin = wrapper
config.SudoFlags = "-v"
Expand Down Expand Up @@ -226,7 +226,7 @@ func TestConfiguration_setPrivilegeElevator_pacman_auth_doas(t *testing.T) {
os.Chmod(sudo, 0o755)
require.NoError(t, err)

config := DefaultConfig()
config := DefaultConfig("test")
config.SudoBin = "sudo"
config.SudoLoop = true
config.SudoFlags = "-v"
Expand Down Expand Up @@ -260,7 +260,7 @@ func TestConfiguration_setPrivilegeElevator_pacman_auth_sudo(t *testing.T) {
os.Chmod(sudo, 0o755)
require.NoError(t, err)

config := DefaultConfig()
config := DefaultConfig("test")
config.SudoBin = "doas"
config.SudoLoop = true
config.SudoFlags = "-v"
Expand Down
1 change: 1 addition & 0 deletions pkg/settings/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (

type Runtime struct {
Mode parser.TargetMode
Version string // current version of yay
SaveConfig bool
CompletionPath string
ConfigPath string
Expand Down