2e9e2fa7a3
Reviewed-on: https://codeberg.org/mvdkleijn/forgejo-sdk/pulls/1 Co-authored-by: Martijn van der Kleijn <martijn.niji@gmail.com> Co-committed-by: Martijn van der Kleijn <martijn.niji@gmail.com> Signed-off-by: Martijn van der Kleijn <martijn.niji@gmail.com>
32 lines
725 B
Go
32 lines
725 B
Go
// Copyright 2024 The Forgejo Authors. All rights reserved.
|
|
// Use of this source code is governed by a MIT-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
// Copyright 2022 The Gitea Authors. All rights reserved.
|
|
// Use of this source code is governed by a MIT-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
//go:build windows
|
|
|
|
package forgejo
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/davidmz/go-pageant"
|
|
"golang.org/x/crypto/ssh/agent"
|
|
)
|
|
|
|
// hasAgent returns true if pageant is available
|
|
func hasAgent() bool {
|
|
return pageant.Available()
|
|
}
|
|
|
|
// GetAgent returns a ssh agent
|
|
func GetAgent() (agent.Agent, error) {
|
|
if !hasAgent() {
|
|
return nil, fmt.Errorf("no pageant available")
|
|
}
|
|
|
|
return pageant.New(), nil
|
|
}
|