Skip to content

Allow to set custom push options #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ To use this plugin you need to include the following block in your
| auth_username | git | The name of the user to use for authentication. |
| auth_password | | The password to use for basic auth or the SSH key. |
| auth_private_key | | The path to an SSH private key file. |
| git_path | . | The path to the Git repository |
| git_path | . | The path to the Git repository. |
| push_options | | The push options for the git tag push. |

### Authentication

Expand Down
13 changes: 12 additions & 1 deletion pkg/provider/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type Repository struct {
remoteName string
auth transport.AuthMethod
repo *git.Repository
pushOptions map[string]string
}

func (repo *Repository) Init(config map[string]string) error {
Expand Down Expand Up @@ -68,6 +69,15 @@ func (repo *Repository) Init(config map[string]string) error {
repo.auth = nil
}

if config["push_options"] != "" {
options := strings.Split(config["push_options"], ",")
repo.pushOptions = make(map[string]string, len(options))
for _, o := range options {
key, value, _ := strings.Cut(o, "=")
repo.pushOptions[key] = value
}
}

gitPath := config["git_path"]
if gitPath == "" {
gitPath = "."
Expand Down Expand Up @@ -201,7 +211,8 @@ func (repo *Repository) CreateRelease(release *provider.CreateReleaseConfig) err
RefSpecs: []config.RefSpec{
config.RefSpec(fmt.Sprintf("refs/tags/%s:refs/tags/%s", tag, tag)),
},
Auth: repo.auth,
Auth: repo.auth,
Options: repo.pushOptions,
})
return err
}
Expand Down