Skip to content
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unrelease

### Added

* Support custom gitlab username and port for SSH #8

### Changed

* Switched from `and` to `or` for include pattern in clone command.
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/clone.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ var cloneCmd = &cobra.Command{
hoster, err := gitlab.MakeHoster()
handleFatalError(err)

gitclient.PrepareSsh(hoster.Host()) // TODO parse url?
gitclient.PrepareSsh(hoster.Host(), config.Values.Gitlab.SSHUser, config.Values.Gitlab.SSHPort)
repos := hoster.Repositories(h.RequestOptions{
Topics: cloneTopics,
Starred: cloneStarred,
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Mode can be one of:
gitDirs := collectGitDirsHandled(dirReposRoot, hoster)

if mode == "fetch" || mode == "pull" {
gitclient.PrepareSsh(hoster.Host())
gitclient.PrepareSsh(hoster.Host(), config.Values.Gitlab.SSHUser, config.Values.Gitlab.SSHPort)
}

tasks := make(chan *StateContext)
Expand Down
2 changes: 2 additions & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ func initLoadDefaults(k *koanf.Koanf) {
Gitlab: gitlab{
DownloadRetryCount: 6, // lower values didn't solve the issue
Host: "gitlab.com",
SSHUser: "git",
SSHPort: 22,
},
}, "koanf"), nil)
print(k, "loaded defaults")
Expand Down
2 changes: 2 additions & 0 deletions internal/config/struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ type gitlab struct {
ApiToken string `koanf:"apitoken"`
DownloadRetryCount int `koanf:"downloadretrycount"`
SecretToken string `koanf:"secrettoken"`
SSHUser string `koanf:"sshuser"`
SSHPort int `koanf:"sshport"`
}
type slack struct {
Token string `koanf:"token"`
Expand Down
5 changes: 3 additions & 2 deletions internal/gitclient/gitclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package gitclient

import (
"bytes"
"fmt"
"io/ioutil"
"os"
"os/exec"
Expand All @@ -12,10 +13,10 @@ import (
"strings"
)

func PrepareSsh(host string) {
func PrepareSsh(host string, sshUser string, sshPort int) {
// not sure how to improve this.
// maybe load ssh config if available and determine identity for host?
_, e, code := util.RunCommandDir(nil, "ssh", "git@"+host)
_, e, code := util.RunCommandDir(nil, "ssh", "-p", strconv.Itoa(sshPort), fmt.Sprintf("%s@%s", sshUser, host))
if code != 0 {
say.Error("Failed loading ssh key: %s", e)
os.Exit(3)
Expand Down
Loading