From adfae2b03939be2d7e23ea22bfa3b7be3de6bc86 Mon Sep 17 00:00:00 2001 From: "jesus m. rodriguez" Date: Fri, 30 Sep 2022 11:53:18 -0400 Subject: [PATCH] Remove unused code Signed-off-by: jesus m. rodriguez --- internal/jira/mock/endpointpattern.go | 14 +++++ internal/jira/mock/server.go | 73 +++++---------------------- internal/jira/mock/server_options.go | 56 +++++--------------- internal/jira/mock/utils.go | 14 +++++ main.go | 30 ----------- 5 files changed, 56 insertions(+), 131 deletions(-) diff --git a/internal/jira/mock/endpointpattern.go b/internal/jira/mock/endpointpattern.go index aff066a..c9d103c 100644 --- a/internal/jira/mock/endpointpattern.go +++ b/internal/jira/mock/endpointpattern.go @@ -1,3 +1,17 @@ +// Copyright © 2022 jesus m. rodriguez jmrodri@gmail.com +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package mock var PostIssue EndpointPattern = EndpointPattern{ diff --git a/internal/jira/mock/server.go b/internal/jira/mock/server.go index 6d5cb97..236992c 100644 --- a/internal/jira/mock/server.go +++ b/internal/jira/mock/server.go @@ -1,3 +1,17 @@ +// Copyright © 2022 jesus m. rodriguez jmrodri@gmail.com +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package mock import ( @@ -49,65 +63,6 @@ func (srh *FIFOReponseHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) w.Write(srh.Responses[srh.CurrentIndex]) } -// PaginatedReponseHandler handler implementation that -// responds to the HTTP requests and honors the pagination headers -// -// Header e.g: `Link: ; rel="next", -// ; rel="last", -// ; rel="first", -// ; rel="prev"` -// -// See: https://docs.github.com/en/rest/guides/traversing-with-pagination -// type PaginatedReponseHandler struct { -// ResponsePages [][]byte -// } - -// func (prh *PaginatedReponseHandler) getCurrentPage(r *http.Request) int { -// strPage := r.URL.Query().Get("page") -// -// if strPage == "" { -// return 1 -// } -// -// page, err := strconv.Atoi(r.URL.Query().Get("page")) -// -// if err == nil { -// return page -// } -// -// // this should never happen as the request is being made by the SDK -// panic(fmt.Sprintf("invalid page: %s", strPage)) -// } - -// func (prh *PaginatedReponseHandler) generateLinkHeader( -// w http.ResponseWriter, -// r *http.Request, -// ) { -// currentPage := prh.getCurrentPage(r) -// lastPage := len(prh.ResponsePages) -// -// buf := bytes.NewBufferString(`; rel="first",`) -// buf.WriteString(fmt.Sprintf(`; rel="last",`, lastPage)) -// -// if currentPage < lastPage { -// // when resp.NextPage == 0, it means no more pages -// // which is basically as not setting it in the response -// buf.WriteString(fmt.Sprintf(`; rel="next",`, currentPage+1)) -// } -// -// if currentPage > 1 { -// buf.WriteString(fmt.Sprintf(`; rel="prev",`, currentPage-1)) -// } -// -// w.Header().Add("Link", buf.String()) -// } - -// ServeHTTP implementation of `http.Handler` -// func (prh *PaginatedReponseHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { -// prh.generateLinkHeader(w, r) -// w.Write(prh.ResponsePages[prh.getCurrentPage(r)-1]) -// } - // EnforceHostRoundTripper rewrites all requests with the given `Host`. type EnforceHostRoundTripper struct { Host string diff --git a/internal/jira/mock/server_options.go b/internal/jira/mock/server_options.go index fde0653..176451b 100644 --- a/internal/jira/mock/server_options.go +++ b/internal/jira/mock/server_options.go @@ -1,3 +1,17 @@ +// Copyright © 2022 jesus m. rodriguez jmrodri@gmail.com +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package mock import ( @@ -62,45 +76,3 @@ func WithRequestMatch( Responses: responses, }) } - -// WithRequestMatchPages honors pagination directives. -// -// Pages can be requested in any order and each page can be called multiple times. -// -// E.g. -// -// mockedHTTPClient := NewMockedHTTPClient( -// WithRequestMatchPages( -// GetOrgsReposByOrg, -// []github.Repository{ -// { -// Name: github.String("repo-A-on-first-page"), -// }, -// { -// Name: github.String("repo-B-on-first-page"), -// }, -// }, -// []github.Repository{ -// { -// Name: github.String("repo-C-on-second-page"), -// }, -// { -// Name: github.String("repo-D-on-second-page"), -// }, -// }, -// ), -// ) -// func WithRequestMatchPages( -// ep EndpointPattern, -// pages ...interface{}, -// ) MockBackendOption { -// p := [][]byte{} -// -// for _, r := range pages { -// p = append(p, MustMarshal(r)) -// } -// -// return WithRequestMatchHandler(ep, &PaginatedReponseHandler{ -// ResponsePages: p, -// }) -// } diff --git a/internal/jira/mock/utils.go b/internal/jira/mock/utils.go index 1441def..fd97dcb 100644 --- a/internal/jira/mock/utils.go +++ b/internal/jira/mock/utils.go @@ -1,3 +1,17 @@ +// Copyright © 2022 jesus m. rodriguez jmrodri@gmail.com +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package mock import ( diff --git a/main.go b/main.go index bac5061..5157415 100644 --- a/main.go +++ b/main.go @@ -17,8 +17,6 @@ package main import ( "os" - // "github.com/jmrodri/gh2jira/internal/gh" - // "github.com/jmrodri/gh2jira/internal/jira" "github.com/jmrodri/gh2jira/cmd/root" ) @@ -42,32 +40,4 @@ func main() { if err := cmd.Execute(); err != nil { os.Exit(1) } - // if len(os.Args) < 2 { - // fmt.Println("Usage: list or clone") - // os.Exit(1) - // } - // - // command := os.Args[1] - // - // switch command { - // case "list": - // // Pass in options to the List command - // gh.ListIssues() - // case "clone": - // // Need github issue number - // if len(os.Args) < 3 { - // fmt.Println("Usage: clone ISSUE_TO_CLONE") - // os.Exit(1) - // } - // issueNum, _ := strconv.Atoi(os.Args[2]) - // issue := gh.GetIssue(issueNum) - // - // var dryRun bool - // if len(os.Args) > 3 { - // dryRun = os.Args[3] == "--dryrun" - // } - // jira.CloneIssueToJira(issue, dryRun) - // default: - // fmt.Printf("Unsupported command: %s\n", command) - // } }