Add Filtering, HealthCheck, Better Tests (#350)
feat: add filtering when choosing merge requests (#346) feat: Add healthcheck (#345) refactor: Move to gomock (#349) feat: Makes the remote of the plugin configurable (#348) This is a #MINOR release.
This commit is contained in:
committed by
GitHub
parent
aa5d3c1f52
commit
4ae623cd65
18
cmd/git.go
18
cmd/git.go
@@ -12,7 +12,7 @@ type GitProjectInfo struct {
|
||||
Namespace string
|
||||
ProjectName string
|
||||
BranchName string
|
||||
GetLatestCommitOnRemote func(a *api) (string, error)
|
||||
GetLatestCommitOnRemote func(a *Api) (string, error)
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -90,10 +90,10 @@ func GetCurrentBranchNameFromNativeGitCmd() (res string, e error) {
|
||||
|
||||
/* Gets the project SSH or HTTPS url */
|
||||
func GetProjectUrlFromNativeGitCmd() (string, error) {
|
||||
cmd := exec.Command("git", "remote", "get-url", "origin")
|
||||
cmd := exec.Command("git", "remote", "get-url", pluginOptions.ConnectionSettings.Remote)
|
||||
url, err := cmd.Output()
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("Could not get origin remote")
|
||||
return "", fmt.Errorf("Could not get remote")
|
||||
}
|
||||
|
||||
return strings.TrimSpace(string(url)), nil
|
||||
@@ -101,24 +101,24 @@ func GetProjectUrlFromNativeGitCmd() (string, error) {
|
||||
|
||||
/* Pulls down latest commit information from Gitlab */
|
||||
func RefreshProjectInfo() error {
|
||||
cmd := exec.Command("git", "fetch", "origin")
|
||||
cmd := exec.Command("git", "fetch", pluginOptions.ConnectionSettings.Remote)
|
||||
_, err := cmd.Output()
|
||||
if err != nil {
|
||||
return fmt.Errorf("Failed to run `git fetch origin`: %v", err)
|
||||
return fmt.Errorf("Failed to run `git fetch %s`: %v", pluginOptions.ConnectionSettings.Remote, err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
/*
|
||||
The GetLatestCommitOnRemote function is attached during the createRouterAndApi call, since it needs to be called every time to get the latest commit.
|
||||
The GetLatestCommitOnRemote function is attached during the CreateRouterAndApi call, since it needs to be called every time to get the latest commit.
|
||||
*/
|
||||
func GetLatestCommitOnRemote(a *api) (string, error) {
|
||||
cmd := exec.Command("git", "log", "-1", "--format=%H", fmt.Sprintf("origin/%s", a.gitInfo.BranchName))
|
||||
func GetLatestCommitOnRemote(a *Api) (string, error) {
|
||||
cmd := exec.Command("git", "log", "-1", "--format=%H", fmt.Sprintf("%s/%s", pluginOptions.ConnectionSettings.Remote, a.gitInfo.BranchName))
|
||||
|
||||
out, err := cmd.Output()
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("Failed to run `git log -1 --format=%%H " + fmt.Sprintf("origin/%s", a.gitInfo.BranchName))
|
||||
return "", fmt.Errorf("Failed to run `git log -1 --format=%%H " + fmt.Sprintf("%s/%s", pluginOptions.ConnectionSettings.Remote, a.gitInfo.BranchName))
|
||||
}
|
||||
|
||||
commit := strings.TrimSpace(string(out))
|
||||
|
||||
Reference in New Issue
Block a user