use git committer info from flags

This commit is contained in:
Mustafa Gezen 2020-12-17 12:12:10 +01:00
parent 1f0742889d
commit e55e442aea
2 changed files with 24 additions and 18 deletions

View File

@ -17,7 +17,8 @@ var (
upstreamPrefix string
branch string
gcsBucket string
debrandedTarballs []string
gitCommitterName string
gitCommitterEmail string
)
var root = &cobra.Command{
@ -40,12 +41,14 @@ func mn(_ *cobra.Command, _ []string) {
}
internal.ProcessRPM(&internal.ProcessData{
RpmLocation: sourceRpmLocation,
UpstreamPrefix: upstreamPrefix,
SshKeyLocation: sshKeyLocation,
SshUser: sshUser,
Branch: branch,
Bucket: client.Bucket(gcsBucket),
RpmLocation: sourceRpmLocation,
UpstreamPrefix: upstreamPrefix,
SshKeyLocation: sshKeyLocation,
SshUser: sshUser,
Branch: branch,
Bucket: client.Bucket(gcsBucket),
GitCommitterName: gitCommitterName,
GitCommitterEmail: gitCommitterEmail,
})
}
@ -58,10 +61,11 @@ func main() {
_ = root.MarkFlagRequired("branch")
root.Flags().StringVar(&gcsBucket, "gcs-bucket", "", "Bucket to use as blob storage")
_ = root.MarkFlagRequired("gcs-bucket")
root.Flags().StringVar(&gitCommitterName, "git-committer-name", "distrobuild-bot", "Name of committer")
root.Flags().StringVar(&gitCommitterEmail, "git-committer-email", "mustafa+distrobuild@bycrates.com", "Email of committer")
root.Flags().StringVar(&sshKeyLocation, "ssh-key-location", "", "Location of the SSH key to use to authenticate against upstream (Optional)")
root.Flags().StringVar(&sshUser, "ssh-user", "git", "SSH User (Optional, default git)")
root.Flags().StringArrayVar(&debrandedTarballs, "debranded-tarball", []string{}, "GCS urls to debranded tarballs (stage 2) (Optional)")
root.Flags().StringVar(&sshKeyLocation, "ssh-key-location", "", "Location of the SSH key to use to authenticate against upstream")
root.Flags().StringVar(&sshUser, "ssh-user", "git", "SSH User")
if err := root.Execute(); err != nil {
log.Fatal(err)

View File

@ -29,12 +29,14 @@ import (
)
type ProcessData struct {
RpmLocation string
UpstreamPrefix string
SshKeyLocation string
SshUser string
Branch string
Bucket *storage.BucketHandle
RpmLocation string
UpstreamPrefix string
SshKeyLocation string
SshUser string
Branch string
Bucket *storage.BucketHandle
GitCommitterName string
GitCommitterEmail string
}
func strContains(a []string, b string) bool {
@ -401,8 +403,8 @@ func ProcessRPM(pd *ProcessData) {
// create import commit
commit, err := w.Commit("import "+filepath.Base(pd.RpmLocation), &git.CommitOptions{
Author: &object.Signature{
Name: "Mustafa Gezen",
Email: "mustafa@bycrates.com",
Name: pd.GitCommitterName,
Email: pd.GitCommitterEmail,
When: time.Now(),
},
Parents: hashes,