mirror of
https://github.com/Jguer/yay
synced 2024-07-08 20:36:24 +00:00
feat(config): Add version marker (#1720)
* only run on PRs * prefer manual tags * add defaults for tests * cuddle assignment
This commit is contained in:
parent
dc9bef0115
commit
ae01f8e4a0
21
.github/workflows/tag.yml
vendored
21
.github/workflows/tag.yml
vendored
|
@ -1,21 +0,0 @@
|
|||
name: Tag
|
||||
on:
|
||||
push:
|
||||
paths-ignore:
|
||||
- ".github/**"
|
||||
- "README.md"
|
||||
- ".gitignore"
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
tag:
|
||||
name: Tag release
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: mathieudutour/github-tag-action@v4.5
|
||||
id: tag_version
|
||||
with:
|
||||
github_token: ${{ secrets.PAT }}
|
||||
tag_prefix: "v"
|
7
.github/workflows/testing-git.yml
vendored
7
.github/workflows/testing-git.yml
vendored
|
@ -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:
|
||||
|
|
7
.github/workflows/testing.yml
vendored
7
.github/workflows/testing.yml
vendored
|
@ -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:
|
||||
|
|
2
cmd.go
2
cmd.go
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
@ -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"),
|
||||
|
@ -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 {
|
||||
|
@ -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),
|
||||
|
|
|
@ -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"
|
||||
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
|
|
@ -14,6 +14,7 @@ import (
|
|||
|
||||
type Runtime struct {
|
||||
Mode parser.TargetMode
|
||||
Version string // current version of yay
|
||||
SaveConfig bool
|
||||
CompletionPath string
|
||||
ConfigPath string
|
||||
|
|
Loading…
Reference in New Issue
Block a user