2022-07-12 17:45:08 +01:00
|
|
|
// 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.
|
|
|
|
|
2022-08-31 01:41:39 +01:00
|
|
|
//go:build windows
|
|
|
|
|
2022-07-12 17:45:08 +01:00
|
|
|
package gitea
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|