From 98c797d4f587920742aa894a35b1ad578f6abe4b Mon Sep 17 00:00:00 2001 From: Denys Vitali Date: Mon, 18 Jan 2021 19:16:35 +0100 Subject: [PATCH 1/4] feat: add fromFile in create --- go.mod | 2 +- go.sum | 3 +-- jiracmd/create.go | 50 +++++++++++++++++++++++++++++++++++------------ 3 files changed, 40 insertions(+), 15 deletions(-) diff --git a/go.mod b/go.mod index 9cca9267..bf4ef945 100644 --- a/go.mod +++ b/go.mod @@ -23,7 +23,7 @@ require ( github.com/imdario/mergo v0.3.7 // indirect github.com/jinzhu/copier v0.0.0-20180308034124-7e38e58719c3 github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 - github.com/kr/pretty v0.1.0 + github.com/kr/pretty v0.1.0 // indirect github.com/kr/pty v1.1.4 // indirect github.com/mattn/go-colorable v0.0.9 // indirect github.com/mattn/go-isatty v0.0.3 // indirect diff --git a/go.sum b/go.sum index cfa3b479..84efd8b5 100644 --- a/go.sum +++ b/go.sum @@ -12,8 +12,6 @@ github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf h1:qet1QNfXsQxTZq github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/cheekybits/genny v1.0.0 h1:uGGa4nei+j20rOSeDeP5Of12XVm7TGUd4dJA9RDitfE= github.com/cheekybits/genny v1.0.0/go.mod h1:+tQajlRqAUrPI7DOSpB0XAqZYtQakVtB7wXkRAgjxjQ= -github.com/coryb/figtree v0.0.0-20180728224503-071d1ef303df h1:cS4Z9Nlv8J4UqFbLp9ltZypgenm2p3Jeg0yqLfpH2pc= -github.com/coryb/figtree v0.0.0-20180728224503-071d1ef303df/go.mod h1:uAkZUEGm6dROpxfy+8vXLs7JrLCI4O+gQyKAuISxI/g= github.com/coryb/figtree v1.0.1-0.20190907170512-58176d03ef0d h1:99xxg8FYj+5TYg88DxA4xL8ODuI6OvuSu35WQOVPDPg= github.com/coryb/figtree v1.0.1-0.20190907170512-58176d03ef0d/go.mod h1:uAkZUEGm6dROpxfy+8vXLs7JrLCI4O+gQyKAuISxI/g= github.com/coryb/kingpeon v0.0.0-20180107011214-9a669f143f2e h1:tGmk9Tuyz7fKuBq/d3nFJvVWRvc48MEBKQC4uYV3wb0= @@ -81,6 +79,7 @@ golang.org/x/net v0.0.0-20171102191033-01c190206fbd h1:CLQSRrSDQMOMkogMxky7XOkER golang.org/x/net v0.0.0-20171102191033-01c190206fbd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/sys v0.0.0-20180727230415-bd9dbc187b6e h1:3dQ4fR8k5KugjVKO0oqSd1odxuk2yaE2CIfxWP2WarQ= golang.org/x/sys v0.0.0-20180727230415-bd9dbc187b6e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/AlecAivazis/survey.v1 v1.6.1 h1:HyWkjKGBpzhNxrpaKRLDqoa4L1f4cMVBNU4bnVmU8Mw= gopkg.in/AlecAivazis/survey.v1 v1.6.1/go.mod h1:2Ehl7OqkBl3Xb8VmC4oFW2bItAhnUfzIjrOzwRxCrOU= diff --git a/jiracmd/create.go b/jiracmd/create.go index b5edea5c..17a43693 100644 --- a/jiracmd/create.go +++ b/jiracmd/create.go @@ -2,6 +2,7 @@ package jiracmd import ( "fmt" + "io/ioutil" "os" "strings" @@ -11,8 +12,8 @@ import ( "github.com/go-jira/jira" "github.com/go-jira/jira/jiracli" "github.com/go-jira/jira/jiradata" - kingpin "gopkg.in/alecthomas/kingpin.v2" - yaml "gopkg.in/coryb/yaml.v2" + "gopkg.in/alecthomas/kingpin.v2" + "gopkg.in/coryb/yaml.v2" ) type CreateOptions struct { @@ -22,6 +23,7 @@ type CreateOptions struct { IssueType string `yaml:"issuetype,omitempty" json:"issuetype,omitempty"` Overrides map[string]string `yaml:"overrides,omitempty" json:"overrides,omitempty"` SaveFile string `yaml:"savefile,omitempty" json:"savefile,omitempty"` + FromFile string `yaml:"fromfile,omitempty" json:"fromfile,omitempty"` } func CmdCreateRegistry() *jiracli.CommandRegistryEntry { @@ -49,6 +51,7 @@ func CmdCreateUsage(cmd *kingpin.CmdClause, opts *CreateOptions) error { jiracli.EditorUsage(cmd, &opts.CommonOptions) jiracli.TemplateUsage(cmd, &opts.CommonOptions) cmd.Flag("noedit", "Disable opening the editor").SetValue(&opts.SkipEditing) + cmd.Flag("fromFile", "Use a file instead of the editor").StringVar(&opts.FromFile) cmd.Flag("project", "project to create issue in").Short('p').StringVar(&opts.Project) cmd.Flag("issuetype", "issuetype in to create").Short('i').StringVar(&opts.IssueType) cmd.Flag("comment", "Comment message for issue").Short('m').PreAction(func(ctx *kingpin.ParseContext) error { @@ -94,18 +97,41 @@ func CmdCreate(o *oreo.Client, globals *jiracli.GlobalOptions, opts *CreateOptio input.Overrides["login"] = globals.Login.Value var issueResp *jiradata.IssueCreateResponse - err = jiracli.EditLoop(&opts.CommonOptions, &input, &issueUpdate, func() error { - if globals.JiraDeploymentType.Value == jiracli.CloudDeploymentType { - err := fixGDPRUserFields(o, globals.Endpoint.Value, createMeta.Fields, issueUpdate.Fields) - if err != nil { - return err - } + + if opts.FromFile != "" { + // Loading from file + inputFile, err := os.Open(opts.FromFile) + if err != nil { + return err + } + + inputFileBytes, err := ioutil.ReadAll(inputFile) + if err != nil { + return err + } + + err = yaml.Unmarshal(inputFileBytes, &issueUpdate) + if err != nil { + return fmt.Errorf("invalid yaml provided: %v", err) } issueResp, err = jira.CreateIssue(o, globals.Endpoint.Value, &issueUpdate) - return err - }) - if err != nil { - return err + if err != nil { + return err + } + } else { + err = jiracli.EditLoop(&opts.CommonOptions, &input, &issueUpdate, func() error { + if globals.JiraDeploymentType.Value == jiracli.CloudDeploymentType { + err := fixGDPRUserFields(o, globals.Endpoint.Value, createMeta.Fields, issueUpdate.Fields) + if err != nil { + return err + } + } + issueResp, err = jira.CreateIssue(o, globals.Endpoint.Value, &issueUpdate) + return err + }) + if err != nil { + return err + } } browseLink := jira.URLJoin(globals.Endpoint.Value, "browse", issueResp.Key) From 831135fa8117a8d956b98cad8acf332c5ca7cc08 Mon Sep 17 00:00:00 2001 From: Rene Lehmann Date: Mon, 28 Oct 2024 15:46:58 +0100 Subject: [PATCH 2/4] Compliance bulk update. Add CONTRIBUTING.md --- CONTRIBUTING.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..5e6d35d6 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,29 @@ +# Contributing + +We welcome contributions and are really glad about your involvement in the project. + +## Reporting Feedback + +Use GitHub’s issues feature to report problems with and request enhancements to the functionality or documentation. + +## Contributing Code + +Code contributions are highly appreciated. Bug fixes and small enhancements can be handed in as pull-requests. For larger changes and features, please open a GitHub issue with your proposal first so the solution can be discussed. + +### Commit Guidelines + +All your commits must follow the [conventional commit message format](https://www.conventionalcommits.org/en/v1.0.0/#summary). + +Valid scopes for this project are: + +- `editor`: changes to the script editor GUI +- `runner`: changes to the script execution logic +- `meta`: changes to the build process, deployment, packaging or the project setup + +Commits that fall into none of these scopes or change aspects in more than one of them should not specify a scope. + +Ideally, each commit should should represent a working and buildable state but still only contain an atomic change compared to its parent. Please rewrite history accordingly before opening a PR. + +### License + +By contributing code or documentation, you agree to have your contribution licensed under [our license](/LICENSE). From 9fef73ecd5991d04c95a3c0953aaa371e9a93da0 Mon Sep 17 00:00:00 2001 From: Rene Lehmann Date: Mon, 28 Oct 2024 15:46:59 +0100 Subject: [PATCH 3/4] Compliance bulk update. Add CODE_OF_CONDUCT.md --- CODE_OF_CONDUCT.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 CODE_OF_CONDUCT.md diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 00000000..ba1d2183 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1 @@ +For interactions on GitHub, Swisscom’s [Social Media Netiquette](https://www.swisscom.ch/en/residential/legal-information/social-media-netiquette.html) applies. From 29887336f450a1279f146edb690a7c63cfba655c Mon Sep 17 00:00:00 2001 From: Rene Lehmann Date: Mon, 28 Oct 2024 17:28:38 +0100 Subject: [PATCH 4/4] revert adding files needed for FOSS compliance --- CODE_OF_CONDUCT.md | 1 - CONTRIBUTING.md | 29 ----------------------------- 2 files changed, 30 deletions(-) delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md deleted file mode 100644 index ba1d2183..00000000 --- a/CODE_OF_CONDUCT.md +++ /dev/null @@ -1 +0,0 @@ -For interactions on GitHub, Swisscom’s [Social Media Netiquette](https://www.swisscom.ch/en/residential/legal-information/social-media-netiquette.html) applies. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index 5e6d35d6..00000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,29 +0,0 @@ -# Contributing - -We welcome contributions and are really glad about your involvement in the project. - -## Reporting Feedback - -Use GitHub’s issues feature to report problems with and request enhancements to the functionality or documentation. - -## Contributing Code - -Code contributions are highly appreciated. Bug fixes and small enhancements can be handed in as pull-requests. For larger changes and features, please open a GitHub issue with your proposal first so the solution can be discussed. - -### Commit Guidelines - -All your commits must follow the [conventional commit message format](https://www.conventionalcommits.org/en/v1.0.0/#summary). - -Valid scopes for this project are: - -- `editor`: changes to the script editor GUI -- `runner`: changes to the script execution logic -- `meta`: changes to the build process, deployment, packaging or the project setup - -Commits that fall into none of these scopes or change aspects in more than one of them should not specify a scope. - -Ideally, each commit should should represent a working and buildable state but still only contain an atomic change compared to its parent. Please rewrite history accordingly before opening a PR. - -### License - -By contributing code or documentation, you agree to have your contribution licensed under [our license](/LICENSE).