Skip to content

Commit

Permalink
feat: PAC - try to read git info from local .git config
Browse files Browse the repository at this point in the history
Signed-off-by: Zbynek Roubalik <zroubalik@gmail.com>
  • Loading branch information
zroubalik committed Mar 20, 2023
1 parent 99de349 commit d15be85
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 208 deletions.
13 changes: 11 additions & 2 deletions cmd/config_git_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"github.com/ory/viper"
"github.com/spf13/cobra"

"github.com/openshift-pipelines/pipelines-as-code/pkg/git"

"knative.dev/func/pkg/config"
fn "knative.dev/func/pkg/functions"
"knative.dev/func/pkg/pipelines"
Expand Down Expand Up @@ -142,10 +144,15 @@ func (c configGitSetConfig) Prompt(f fn.Function) (configGitSetConfig, error) {
return c, err
}

// try to read git url from the local .git settings
gitInfo := git.GetGitInfo(c.Path)

// prompt if git URL hasn't been set previously
if c.GitURL == "" {
// TODO we can try to read git url from the local .git settings
url := f.Build.Git.URL
if gitInfo.URL != "" {
url = gitInfo.URL
}
if err := survey.AskOne(&survey.Input{
Message: "The URL to Git repository with the function source code:",
Default: url,
Expand All @@ -157,8 +164,10 @@ func (c configGitSetConfig) Prompt(f fn.Function) (configGitSetConfig, error) {

// prompt if git revision hasn't been set previously
if c.GitRevision == "" {
// TODO we can try to read git url from the local .git settings
revision := f.Build.Git.Revision
if gitInfo.Branch != "" {
revision = gitInfo.Branch
}
if err := survey.AskOne(&survey.Input{
Message: "The Git branch or tag we are targeting:",
Help: "ie: main, refs/tags/*",
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ require (
github.com/heroku/color v0.0.6
github.com/hinshun/vt10x v0.0.0-20220228203356-1ab2cad5fd82
github.com/opencontainers/image-spec v1.1.0-rc2
github.com/openshift-pipelines/pipelines-as-code v0.17.0
github.com/openshift-pipelines/pipelines-as-code v0.17.1
github.com/openshift/source-to-image v1.3.1
github.com/ory/viper v1.7.5
github.com/pkg/errors v0.9.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1332,8 +1332,8 @@ github.com/opencontainers/selinux v1.8.2/go.mod h1:MUIHuUEvKB1wtJjQdOyYRgOnLD2xA
github.com/opencontainers/selinux v1.10.0/go.mod h1:2i0OySw99QjzBBQByd1Gr9gSjvuho1lHsJxIJ3gGbJI=
github.com/opencontainers/selinux v1.10.2 h1:NFy2xCsjn7+WspbfZkUd5zyVeisV7VFbPSP96+8/ha4=
github.com/opencontainers/selinux v1.10.2/go.mod h1:cARutUbaUrlRClyvxOICCgKixCs6L05aUsohzA3EkHQ=
github.com/openshift-pipelines/pipelines-as-code v0.17.0 h1:RtUZp7sX46lP72UntAoDfhU1iZBiKDueTgLjGzmmUrA=
github.com/openshift-pipelines/pipelines-as-code v0.17.0/go.mod h1:5gCkO4y2PEFZ842tbF8376rD386DkoSyyQI3vjdqwq4=
github.com/openshift-pipelines/pipelines-as-code v0.17.1 h1:9+vnu3FMrfMy6R+jhaV6jvmVhDrXRYuGvgHHrCfTdrU=
github.com/openshift-pipelines/pipelines-as-code v0.17.1/go.mod h1:5gCkO4y2PEFZ842tbF8376rD386DkoSyyQI3vjdqwq4=
github.com/opentracing-contrib/go-stdlib v1.0.0/go.mod h1:qtI1ogk+2JhVPIXVc6q+NHziSmy2W5GbdQZFUHADCBU=
github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc=
Expand Down
202 changes: 0 additions & 202 deletions third_party/VENDOR-LICENSE/github.com/moby/sys/mount/LICENSE

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -880,14 +880,15 @@ github.com/opencontainers/selinux/go-selinux
github.com/opencontainers/selinux/go-selinux/label
github.com/opencontainers/selinux/pkg/pwalk
github.com/opencontainers/selinux/pkg/pwalkdir
# github.com/openshift-pipelines/pipelines-as-code v0.17.0
# github.com/openshift-pipelines/pipelines-as-code v0.17.1
## explicit; go 1.18
github.com/openshift-pipelines/pipelines-as-code/pkg/apis/pipelinesascode
github.com/openshift-pipelines/pipelines-as-code/pkg/apis/pipelinesascode/v1alpha1
github.com/openshift-pipelines/pipelines-as-code/pkg/cli
github.com/openshift-pipelines/pipelines-as-code/pkg/formatting
github.com/openshift-pipelines/pipelines-as-code/pkg/generated/clientset/versioned/scheme
github.com/openshift-pipelines/pipelines-as-code/pkg/generated/clientset/versioned/typed/pipelinesascode/v1alpha1
github.com/openshift-pipelines/pipelines-as-code/pkg/git
# github.com/openshift/source-to-image v1.3.1 => github.com/boson-project/source-to-image v1.3.2
## explicit; go 1.13
github.com/openshift/source-to-image/pkg/api
Expand Down

0 comments on commit d15be85

Please sign in to comment.