mirror of
https://github.com/Threnklyn/jira.git
synced 2026-05-18 20:23:28 +02:00
[#163] fix url path join logic
This commit is contained in:
@@ -3,6 +3,7 @@ config:
|
|||||||
password-source: pass
|
password-source: pass
|
||||||
endpoint: https://go-jira.atlassian.net
|
endpoint: https://go-jira.atlassian.net
|
||||||
user: admin
|
user: admin
|
||||||
|
login: atlassian@corybennett.org
|
||||||
|
|
||||||
queries:
|
queries:
|
||||||
todo: |
|
todo: |
|
||||||
|
|||||||
+2
-4
@@ -1,8 +1,6 @@
|
|||||||
package jira
|
package jira
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiradata"
|
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiradata"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -12,7 +10,7 @@ func (j *Jira) GetAttachment(id string) (*jiradata.Attachment, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func GetAttachment(ua HttpClient, endpoint string, id string) (*jiradata.Attachment, error) {
|
func GetAttachment(ua HttpClient, endpoint string, id string) (*jiradata.Attachment, error) {
|
||||||
uri := fmt.Sprintf("%s/rest/api/2/attachment/%s", endpoint, id)
|
uri := URLJoin(endpoint, "rest/api/2/attachment", id)
|
||||||
resp, err := ua.GetJSON(uri)
|
resp, err := ua.GetJSON(uri)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -32,7 +30,7 @@ func (j *Jira) RemoveAttachment(id string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func RemoveAttachment(ua HttpClient, endpoint string, id string) error {
|
func RemoveAttachment(ua HttpClient, endpoint string, id string) error {
|
||||||
uri := fmt.Sprintf("%s/rest/api/2/attachment/%s", endpoint, id)
|
uri := URLJoin(endpoint, "rest/api/2/attachment", id)
|
||||||
resp, err := ua.Delete(uri)
|
resp, err := ua.Delete(uri)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
+1
-2
@@ -3,7 +3,6 @@ package jira
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiradata"
|
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiradata"
|
||||||
)
|
)
|
||||||
@@ -23,7 +22,7 @@ func CreateComponent(ua HttpClient, endpoint string, cp ComponentProvider) (*jir
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
uri := fmt.Sprintf("%s/rest/api/2/component", endpoint)
|
uri := URLJoin(endpoint, "rest/api/2/component")
|
||||||
resp, err := ua.Post(uri, "application/json", bytes.NewBuffer(encoded))
|
resp, err := ua.Post(uri, "application/json", bytes.NewBuffer(encoded))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ func EpicSearch(ua HttpClient, endpoint string, epic string, sp SearchProvider)
|
|||||||
// if err != nil {
|
// if err != nil {
|
||||||
// return nil, err
|
// return nil, err
|
||||||
// }
|
// }
|
||||||
uri, err := url.Parse(fmt.Sprintf("%s/rest/agile/1.0/epic/%s/issue", endpoint, epic))
|
uri, err := url.Parse(URLJoin(endpoint, "rest/agile/1.0/epic", epic, "issue"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -74,7 +74,7 @@ func EpicAddIssues(ua HttpClient, endpoint string, epic string, eip EpicIssuesPr
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
uri := fmt.Sprintf("%s/rest/agile/1.0/epic/%s/issue", endpoint, epic)
|
uri := URLJoin(endpoint, "rest/agile/1.0/epic", epic, "issue")
|
||||||
resp, err := ua.Post(uri, "application/json", bytes.NewBuffer(encoded))
|
resp, err := ua.Post(uri, "application/json", bytes.NewBuffer(encoded))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -99,7 +99,7 @@ func EpicRemoveIssues(ua HttpClient, endpoint string, eip EpicIssuesProvider) er
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
uri := fmt.Sprintf("%s/rest/agile/1.0/epic/none/issue", endpoint)
|
uri := URLJoin(endpoint, "rest/agile/1.0/epic/none/issue")
|
||||||
resp, err := ua.Post(uri, "application/json", bytes.NewBuffer(encoded))
|
resp, err := ua.Post(uri, "application/json", bytes.NewBuffer(encoded))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
package jira
|
package jira
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiradata"
|
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiradata"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -12,7 +10,7 @@ func (j *Jira) GetFields() ([]jiradata.Field, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func GetFields(ua HttpClient, endpoint string) ([]jiradata.Field, error) {
|
func GetFields(ua HttpClient, endpoint string) ([]jiradata.Field, error) {
|
||||||
uri := fmt.Sprintf("%s/rest/api/2/field", endpoint)
|
uri := URLJoin(endpoint, "rest/api/2/field")
|
||||||
resp, err := ua.GetJSON(uri)
|
resp, err := ua.GetJSON(uri)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
@@ -59,7 +59,8 @@ func GetIssue(ua HttpClient, endpoint string, issue string, iqg IssueQueryProvid
|
|||||||
if iqg != nil {
|
if iqg != nil {
|
||||||
query = iqg.ProvideIssueQueryString()
|
query = iqg.ProvideIssueQueryString()
|
||||||
}
|
}
|
||||||
uri := fmt.Sprintf("%s/rest/api/2/issue/%s%s", endpoint, issue, query)
|
uri := URLJoin(endpoint, "rest/api/2/issue", issue)
|
||||||
|
uri += query
|
||||||
resp, err := ua.GetJSON(uri)
|
resp, err := ua.GetJSON(uri)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -84,7 +85,8 @@ func GetIssueWorklog(ua HttpClient, endpoint string, issue string) (*jiradata.Wo
|
|||||||
maxResults := 100
|
maxResults := 100
|
||||||
worklogs := jiradata.Worklogs{}
|
worklogs := jiradata.Worklogs{}
|
||||||
for startAt < total {
|
for startAt < total {
|
||||||
uri := fmt.Sprintf("%s/rest/api/2/issue/%s/worklog?startAt=%d&maxResults=%d", endpoint, issue, startAt, maxResults)
|
uri := URLJoin(endpoint, "rest/api/2/issue", issue, "worklog")
|
||||||
|
uri += fmt.Sprintf("?startAt=%d&maxResults=%d", startAt, maxResults)
|
||||||
resp, err := ua.GetJSON(uri)
|
resp, err := ua.GetJSON(uri)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -124,7 +126,7 @@ func AddIssueWorklog(ua HttpClient, endpoint string, issue string, wp WorklogPro
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
uri := fmt.Sprintf("%s/rest/api/2/issue/%s/worklog", endpoint, issue)
|
uri := URLJoin(endpoint, "rest/api/2/issue", issue, "worklog")
|
||||||
resp, err := ua.Post(uri, "application/json", bytes.NewBuffer(encoded))
|
resp, err := ua.Post(uri, "application/json", bytes.NewBuffer(encoded))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -144,7 +146,7 @@ func (j *Jira) GetIssueEditMeta(issue string) (*jiradata.EditMeta, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func GetIssueEditMeta(ua HttpClient, endpoint string, issue string) (*jiradata.EditMeta, error) {
|
func GetIssueEditMeta(ua HttpClient, endpoint string, issue string) (*jiradata.EditMeta, error) {
|
||||||
uri := fmt.Sprintf("%s/rest/api/2/issue/%s/editmeta", endpoint, issue)
|
uri := URLJoin(endpoint, "rest/api/2/issue", issue, "editmeta")
|
||||||
resp, err := ua.GetJSON(uri)
|
resp, err := ua.GetJSON(uri)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -173,7 +175,7 @@ func EditIssue(ua HttpClient, endpoint string, issue string, iup IssueUpdateProv
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
uri := fmt.Sprintf("%s/rest/api/2/issue/%s", endpoint, issue)
|
uri := URLJoin(endpoint, "rest/api/2/issue", issue)
|
||||||
resp, err := ua.Put(uri, "application/json", bytes.NewBuffer(encoded))
|
resp, err := ua.Put(uri, "application/json", bytes.NewBuffer(encoded))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -197,7 +199,7 @@ func CreateIssue(ua HttpClient, endpoint string, iup IssueUpdateProvider) (*jira
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
uri := fmt.Sprintf("%s/rest/api/2/issue", endpoint)
|
uri := URLJoin(endpoint, "rest/api/2/issue")
|
||||||
resp, err := ua.Post(uri, "application/json", bytes.NewBuffer(encoded))
|
resp, err := ua.Post(uri, "application/json", bytes.NewBuffer(encoded))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -217,7 +219,8 @@ func (j *Jira) GetIssueCreateMetaProject(projectKey string) (*jiradata.CreateMet
|
|||||||
}
|
}
|
||||||
|
|
||||||
func GetIssueCreateMetaProject(ua HttpClient, endpoint string, projectKey string) (*jiradata.CreateMetaProject, error) {
|
func GetIssueCreateMetaProject(ua HttpClient, endpoint string, projectKey string) (*jiradata.CreateMetaProject, error) {
|
||||||
uri := fmt.Sprintf("%s/rest/api/2/issue/createmeta?projectKeys=%s&expand=projects.issuetypes.fields", endpoint, projectKey)
|
uri := URLJoin(endpoint, "rest/api/2/issue/createmeta")
|
||||||
|
uri += fmt.Sprintf("?projectKeys=%s&expand=projects.issuetypes.fields", projectKey)
|
||||||
resp, err := ua.GetJSON(uri)
|
resp, err := ua.GetJSON(uri)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -246,7 +249,8 @@ func (j *Jira) GetIssueCreateMetaIssueType(projectKey, issueTypeName string) (*j
|
|||||||
}
|
}
|
||||||
|
|
||||||
func GetIssueCreateMetaIssueType(ua HttpClient, endpoint string, projectKey, issueTypeName string) (*jiradata.IssueType, error) {
|
func GetIssueCreateMetaIssueType(ua HttpClient, endpoint string, projectKey, issueTypeName string) (*jiradata.IssueType, error) {
|
||||||
uri := fmt.Sprintf("%s/rest/api/2/issue/createmeta?projectKeys=%s&issuetypeNames=%s&expand=projects.issuetypes.fields", endpoint, projectKey, url.QueryEscape(issueTypeName))
|
uri := URLJoin(endpoint, "rest/api/2/issue/createmeta")
|
||||||
|
uri += fmt.Sprintf("?projectKeys=%s&issuetypeNames=%s&expand=projects.issuetypes.fields", projectKey, url.QueryEscape(issueTypeName))
|
||||||
resp, err := ua.GetJSON(uri)
|
resp, err := ua.GetJSON(uri)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -288,7 +292,7 @@ func LinkIssues(ua HttpClient, endpoint string, lip LinkIssueProvider) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
uri := fmt.Sprintf("%s/rest/api/2/issueLink", endpoint)
|
uri := URLJoin(endpoint, "rest/api/2/issueLink")
|
||||||
resp, err := ua.Post(uri, "application/json", bytes.NewBuffer(encoded))
|
resp, err := ua.Post(uri, "application/json", bytes.NewBuffer(encoded))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -307,7 +311,8 @@ func (j *Jira) GetIssueTransitions(issue string) (*jiradata.TransitionsMeta, err
|
|||||||
}
|
}
|
||||||
|
|
||||||
func GetIssueTransitions(ua HttpClient, endpoint string, issue string) (*jiradata.TransitionsMeta, error) {
|
func GetIssueTransitions(ua HttpClient, endpoint string, issue string) (*jiradata.TransitionsMeta, error) {
|
||||||
uri := fmt.Sprintf("%s/rest/api/2/issue/%s/transitions?expand=transitions.fields", endpoint, issue)
|
uri := URLJoin(endpoint, "rest/api/2/issue", issue, "transitions")
|
||||||
|
uri += "?expand=transitions.fields"
|
||||||
resp, err := ua.GetJSON(uri)
|
resp, err := ua.GetJSON(uri)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -332,7 +337,7 @@ func TransitionIssue(ua HttpClient, endpoint string, issue string, iup IssueUpda
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
uri := fmt.Sprintf("%s/rest/api/2/issue/%s/transitions", endpoint, issue)
|
uri := URLJoin(endpoint, "rest/api/2/issue", issue, "transitions")
|
||||||
resp, err := ua.Post(uri, "application/json", bytes.NewBuffer(encoded))
|
resp, err := ua.Post(uri, "application/json", bytes.NewBuffer(encoded))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -351,7 +356,7 @@ func (j *Jira) GetIssueLinkTypes() (*jiradata.IssueLinkTypes, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func GetIssueLinkTypes(ua HttpClient, endpoint string) (*jiradata.IssueLinkTypes, error) {
|
func GetIssueLinkTypes(ua HttpClient, endpoint string) (*jiradata.IssueLinkTypes, error) {
|
||||||
uri := fmt.Sprintf("%s/rest/api/2/issueLinkType", endpoint)
|
uri := URLJoin(endpoint, "rest/api/2/issueLinkType")
|
||||||
resp, err := ua.GetJSON(uri)
|
resp, err := ua.GetJSON(uri)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -375,7 +380,7 @@ func (j *Jira) IssueAddVote(issue string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func IssueAddVote(ua HttpClient, endpoint string, issue string) error {
|
func IssueAddVote(ua HttpClient, endpoint string, issue string) error {
|
||||||
uri := fmt.Sprintf("%s/rest/api/2/issue/%s/votes", endpoint, issue)
|
uri := URLJoin(endpoint, "rest/api/2/issue", issue, "votes")
|
||||||
resp, err := ua.Post(uri, "application/json", strings.NewReader("{}"))
|
resp, err := ua.Post(uri, "application/json", strings.NewReader("{}"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -394,7 +399,7 @@ func (j *Jira) IssueRemoveVote(issue string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func IssueRemoveVote(ua HttpClient, endpoint string, issue string) error {
|
func IssueRemoveVote(ua HttpClient, endpoint string, issue string) error {
|
||||||
uri := fmt.Sprintf("%s/rest/api/2/issue/%s/votes", endpoint, issue)
|
uri := URLJoin(endpoint, "rest/api/2/issue", issue, "votes")
|
||||||
resp, err := ua.Delete(uri)
|
resp, err := ua.Delete(uri)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -422,7 +427,7 @@ func RankIssues(ua HttpClient, endpoint string, rrp RankRequestProvider) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
uri := fmt.Sprintf("%s/rest/agile/1.0/issue/rank", endpoint)
|
uri := URLJoin(endpoint, "rest/agile/1.0/issue/rank")
|
||||||
resp, err := ua.Put(uri, "application/json", bytes.NewBuffer(encoded))
|
resp, err := ua.Put(uri, "application/json", bytes.NewBuffer(encoded))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -441,7 +446,7 @@ func (j *Jira) IssueAddWatcher(issue, user string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func IssueAddWatcher(ua HttpClient, endpoint string, issue, user string) error {
|
func IssueAddWatcher(ua HttpClient, endpoint string, issue, user string) error {
|
||||||
uri := fmt.Sprintf("%s/rest/api/2/issue/%s/watchers", endpoint, issue)
|
uri := URLJoin(endpoint, "rest/api/2/issue", issue, "watchers")
|
||||||
resp, err := ua.Post(uri, "application/json", strings.NewReader(fmt.Sprintf("%q", user)))
|
resp, err := ua.Post(uri, "application/json", strings.NewReader(fmt.Sprintf("%q", user)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -460,7 +465,8 @@ func (j *Jira) IssueRemoveWatcher(issue, user string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func IssueRemoveWatcher(ua HttpClient, endpoint string, issue, user string) error {
|
func IssueRemoveWatcher(ua HttpClient, endpoint string, issue, user string) error {
|
||||||
uri := fmt.Sprintf("%s/rest/api/2/issue/%s/watchers?username=%s", endpoint, issue, user)
|
uri := URLJoin(endpoint, "rest/api/2/issue", issue, "watchers")
|
||||||
|
uri += fmt.Sprintf("?username=%s", user)
|
||||||
resp, err := ua.Delete(uri)
|
resp, err := ua.Delete(uri)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -488,7 +494,7 @@ func IssueAddComment(ua HttpClient, endpoint string, issue string, cp CommentPro
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
uri := fmt.Sprintf("%s/rest/api/2/issue/%s/comment", endpoint, issue)
|
uri := URLJoin(endpoint, "rest/api/2/issue", issue, "comment")
|
||||||
resp, err := ua.Post(uri, "application/json", bytes.NewBuffer(encoded))
|
resp, err := ua.Post(uri, "application/json", bytes.NewBuffer(encoded))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -526,7 +532,7 @@ func IssueAssign(ua HttpClient, endpoint string, issue, name string) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
uri := fmt.Sprintf("%s/rest/api/2/issue/%s/assignee", endpoint, issue)
|
uri := URLJoin(endpoint, "rest/api/2/issue", issue, "assignee")
|
||||||
resp, err := ua.Put(uri, "application/json", bytes.NewBuffer(encoded))
|
resp, err := ua.Put(uri, "application/json", bytes.NewBuffer(encoded))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -556,7 +562,7 @@ func IssueAttachFile(ua HttpClient, endpoint string, issue, filename string, con
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
uri, err := url.Parse(fmt.Sprintf("%s/rest/api/2/issue/%s/attachments", endpoint, issue))
|
uri, err := url.Parse(URLJoin(endpoint, "rest/api/2/issue", issue, "attachments"))
|
||||||
req := oreo.RequestBuilder(uri).WithMethod("POST").WithHeader(
|
req := oreo.RequestBuilder(uri).WithMethod("POST").WithHeader(
|
||||||
"X-Atlassian-Token", "no-check",
|
"X-Atlassian-Token", "no-check",
|
||||||
).WithHeader(
|
).WithHeader(
|
||||||
|
|||||||
+1
-1
@@ -52,7 +52,7 @@ func CmdAssign(o *oreo.Client, globals *jiracli.GlobalOptions, opts *AssignOptio
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !globals.Quiet.Value {
|
if !globals.Quiet.Value {
|
||||||
fmt.Printf("OK %s %s/browse/%s\n", opts.Issue, globals.Endpoint.Value, opts.Issue)
|
fmt.Printf("OK %s %s\n", opts.Issue, jira.URLJoin(globals.Endpoint.Value, "browse", opts.Issue))
|
||||||
}
|
}
|
||||||
|
|
||||||
if opts.Browse.Value {
|
if opts.Browse.Value {
|
||||||
|
|||||||
+2
-2
@@ -66,8 +66,8 @@ func CmdBlock(o *oreo.Client, globals *jiracli.GlobalOptions, opts *BlockOptions
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !globals.Quiet.Value {
|
if !globals.Quiet.Value {
|
||||||
fmt.Printf("OK %s %s/browse/%s\n", opts.InwardIssue.Key, globals.Endpoint.Value, opts.InwardIssue.Key)
|
fmt.Printf("OK %s %s\n", opts.InwardIssue.Key, jira.URLJoin(globals.Endpoint.Value, "browse", opts.InwardIssue.Key))
|
||||||
fmt.Printf("OK %s %s/browse/%s\n", opts.OutwardIssue.Key, globals.Endpoint.Value, opts.OutwardIssue.Key)
|
fmt.Printf("OK %s %s\n", opts.OutwardIssue.Key, jira.URLJoin(globals.Endpoint.Value, "browse", opts.OutwardIssue.Key))
|
||||||
}
|
}
|
||||||
|
|
||||||
if opts.Browse.Value {
|
if opts.Browse.Value {
|
||||||
|
|||||||
+2
-3
@@ -1,11 +1,10 @@
|
|||||||
package jiracmd
|
package jiracmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"github.com/coryb/figtree"
|
"github.com/coryb/figtree"
|
||||||
"github.com/coryb/oreo"
|
"github.com/coryb/oreo"
|
||||||
"github.com/pkg/browser"
|
"github.com/pkg/browser"
|
||||||
|
jira "gopkg.in/Netflix-Skunkworks/go-jira.v1"
|
||||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiracli"
|
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiracli"
|
||||||
kingpin "gopkg.in/alecthomas/kingpin.v2"
|
kingpin "gopkg.in/alecthomas/kingpin.v2"
|
||||||
)
|
)
|
||||||
@@ -27,5 +26,5 @@ func CmdBrowseRegistry() *jiracli.CommandRegistryEntry {
|
|||||||
|
|
||||||
// CmdBrowse open the default system browser to the provided issue
|
// CmdBrowse open the default system browser to the provided issue
|
||||||
func CmdBrowse(globals *jiracli.GlobalOptions, issue string) error {
|
func CmdBrowse(globals *jiracli.GlobalOptions, issue string) error {
|
||||||
return browser.OpenURL(fmt.Sprintf("%s/browse/%s", globals.Endpoint.Value, issue))
|
return browser.OpenURL(jira.URLJoin(globals.Endpoint.Value, "browse", issue))
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -68,7 +68,7 @@ func CmdComment(o *oreo.Client, globals *jiracli.GlobalOptions, opts *CommentOpt
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !globals.Quiet.Value {
|
if !globals.Quiet.Value {
|
||||||
fmt.Printf("OK %s %s/browse/%s\n", opts.Issue, globals.Endpoint.Value, opts.Issue)
|
fmt.Printf("OK %s %s\n", opts.Issue, jira.URLJoin(globals.Endpoint.Value, "browse", opts.Issue))
|
||||||
}
|
}
|
||||||
|
|
||||||
if opts.Browse.Value {
|
if opts.Browse.Value {
|
||||||
|
|||||||
+3
-2
@@ -93,8 +93,9 @@ func CmdCreate(o *oreo.Client, globals *jiracli.GlobalOptions, opts *CreateOptio
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
browseLink := jira.URLJoin(globals.Endpoint.Value, "browse", issueResp.Key)
|
||||||
if !globals.Quiet.Value {
|
if !globals.Quiet.Value {
|
||||||
fmt.Printf("OK %s %s/browse/%s\n", issueResp.Key, globals.Endpoint.Value, issueResp.Key)
|
fmt.Printf("OK %s %s\n", issueResp.Key, browseLink)
|
||||||
}
|
}
|
||||||
|
|
||||||
if opts.SaveFile != "" {
|
if opts.SaveFile != "" {
|
||||||
@@ -105,7 +106,7 @@ func CmdCreate(o *oreo.Client, globals *jiracli.GlobalOptions, opts *CreateOptio
|
|||||||
defer fh.Close()
|
defer fh.Close()
|
||||||
out, err := yaml.Marshal(map[string]string{
|
out, err := yaml.Marshal(map[string]string{
|
||||||
"issue": issueResp.Key,
|
"issue": issueResp.Key,
|
||||||
"link": fmt.Sprintf("%s/browse/%s", globals.Endpoint.Value, issueResp.Key),
|
"link": browseLink,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
+2
-2
@@ -67,7 +67,7 @@ func CmdDup(o *oreo.Client, globals *jiracli.GlobalOptions, opts *DupOptions) er
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if !globals.Quiet.Value {
|
if !globals.Quiet.Value {
|
||||||
fmt.Printf("OK %s %s/browse/%s\n", opts.OutwardIssue.Key, globals.Endpoint.Value, opts.OutwardIssue.Key)
|
fmt.Printf("OK %s %s\n", opts.OutwardIssue.Key, jira.URLJoin(globals.Endpoint.Value, "browse", opts.OutwardIssue.Key))
|
||||||
}
|
}
|
||||||
|
|
||||||
meta, err := jira.GetIssueTransitions(o, globals.Endpoint.Value, opts.InwardIssue.Key)
|
meta, err := jira.GetIssueTransitions(o, globals.Endpoint.Value, opts.InwardIssue.Key)
|
||||||
@@ -103,7 +103,7 @@ func CmdDup(o *oreo.Client, globals *jiracli.GlobalOptions, opts *DupOptions) er
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !globals.Quiet.Value {
|
if !globals.Quiet.Value {
|
||||||
fmt.Printf("OK %s %s/browse/%s\n", opts.InwardIssue.Key, globals.Endpoint.Value, opts.InwardIssue.Key)
|
fmt.Printf("OK %s %s\n", opts.InwardIssue.Key, jira.URLJoin(globals.Endpoint.Value, "browse", opts.InwardIssue.Key))
|
||||||
}
|
}
|
||||||
|
|
||||||
if opts.Browse.Value {
|
if opts.Browse.Value {
|
||||||
|
|||||||
+2
-2
@@ -98,7 +98,7 @@ func CmdEdit(o *oreo.Client, globals *jiracli.GlobalOptions, opts *EditOptions)
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if !globals.Quiet.Value {
|
if !globals.Quiet.Value {
|
||||||
fmt.Printf("OK %s %s/browse/%s\n", opts.Issue, globals.Endpoint.Value, opts.Issue)
|
fmt.Printf("OK %s %s\n", opts.Issue, jira.URLJoin(globals.Endpoint.Value, "browse", opts.Issue))
|
||||||
}
|
}
|
||||||
if opts.Browse.Value {
|
if opts.Browse.Value {
|
||||||
return CmdBrowse(globals, opts.Issue)
|
return CmdBrowse(globals, opts.Issue)
|
||||||
@@ -145,7 +145,7 @@ func CmdEdit(o *oreo.Client, globals *jiracli.GlobalOptions, opts *EditOptions)
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if !globals.Quiet.Value {
|
if !globals.Quiet.Value {
|
||||||
fmt.Printf("OK %s %s/browse/%s\n", issueData.Key, globals.Endpoint.Value, issueData.Key)
|
fmt.Printf("OK %s %s\n", issueData.Key, jira.URLJoin(globals.Endpoint.Value, "browse", issueData.Key))
|
||||||
}
|
}
|
||||||
if opts.Browse.Value {
|
if opts.Browse.Value {
|
||||||
return CmdBrowse(globals, issueData.Key)
|
return CmdBrowse(globals, issueData.Key)
|
||||||
|
|||||||
+2
-2
@@ -44,9 +44,9 @@ func CmdEpicAdd(o *oreo.Client, globals *jiracli.GlobalOptions, opts *EpicAddOpt
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !globals.Quiet.Value {
|
if !globals.Quiet.Value {
|
||||||
fmt.Printf("OK %s %s/browse/%s\n", opts.Epic, globals.Endpoint.Value, opts.Epic)
|
fmt.Printf("OK %s %s\n", opts.Epic, jira.URLJoin(globals.Endpoint.Value, "browse", opts.Epic))
|
||||||
for _, issue := range opts.Issues {
|
for _, issue := range opts.Issues {
|
||||||
fmt.Printf("OK %s %s/browse/%s\n", issue, globals.Endpoint.Value, issue)
|
fmt.Printf("OK %s %s\n", issue, jira.URLJoin(globals.Endpoint.Value, "browse", issue))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ func CmdEpicRemove(o *oreo.Client, globals *jiracli.GlobalOptions, opts *EpicRem
|
|||||||
|
|
||||||
if !globals.Quiet.Value {
|
if !globals.Quiet.Value {
|
||||||
for _, issue := range opts.Issues {
|
for _, issue := range opts.Issues {
|
||||||
fmt.Printf("OK %s %s/browse/%s\n", issue, globals.Endpoint.Value, issue)
|
fmt.Printf("OK %s %s\n", issue, jira.URLJoin(globals.Endpoint.Value, "browse", issue))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -62,8 +62,8 @@ func CmdIssueLink(o *oreo.Client, globals *jiracli.GlobalOptions, opts *IssueLin
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !globals.Quiet.Value {
|
if !globals.Quiet.Value {
|
||||||
fmt.Printf("OK %s %s/browse/%s\n", opts.InwardIssue.Key, globals.Endpoint.Value, opts.InwardIssue.Key)
|
fmt.Printf("OK %s %s\n", opts.InwardIssue.Key, jira.URLJoin(globals.Endpoint.Value, "browse", opts.InwardIssue.Key))
|
||||||
fmt.Printf("OK %s %s/browse/%s\n", opts.OutwardIssue.Key, globals.Endpoint.Value, opts.OutwardIssue.Key)
|
fmt.Printf("OK %s %s\n", opts.OutwardIssue.Key, jira.URLJoin(globals.Endpoint.Value, "browse", opts.OutwardIssue.Key))
|
||||||
}
|
}
|
||||||
|
|
||||||
if opts.Browse.Value {
|
if opts.Browse.Value {
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ func CmdLabelsAdd(o *oreo.Client, globals *jiracli.GlobalOptions, opts *LabelsAd
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if !globals.Quiet.Value {
|
if !globals.Quiet.Value {
|
||||||
fmt.Printf("OK %s %s/browse/%s\n", opts.Issue, globals.Endpoint.Value, opts.Issue)
|
fmt.Printf("OK %s %s\n", opts.Issue, jira.URLJoin(globals.Endpoint.Value, "browse", opts.Issue))
|
||||||
}
|
}
|
||||||
if opts.Browse.Value {
|
if opts.Browse.Value {
|
||||||
return CmdBrowse(globals, opts.Issue)
|
return CmdBrowse(globals, opts.Issue)
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ func CmdLabelsRemove(o *oreo.Client, globals *jiracli.GlobalOptions, opts *Label
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if !globals.Quiet.Value {
|
if !globals.Quiet.Value {
|
||||||
fmt.Printf("OK %s %s/browse/%s\n", opts.Issue, globals.Endpoint.Value, opts.Issue)
|
fmt.Printf("OK %s %s\n", opts.Issue, jira.URLJoin(globals.Endpoint.Value, "browse", opts.Issue))
|
||||||
}
|
}
|
||||||
if opts.Browse.Value {
|
if opts.Browse.Value {
|
||||||
return CmdBrowse(globals, opts.Issue)
|
return CmdBrowse(globals, opts.Issue)
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ func CmdLabelsSet(o *oreo.Client, globals *jiracli.GlobalOptions, opts *LabelsSe
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if !globals.Quiet.Value {
|
if !globals.Quiet.Value {
|
||||||
fmt.Printf("OK %s %s/browse/%s\n", opts.Issue, globals.Endpoint.Value, opts.Issue)
|
fmt.Printf("OK %s %s\n", opts.Issue, jira.URLJoin(globals.Endpoint.Value, "browse", opts.Issue))
|
||||||
}
|
}
|
||||||
if opts.Browse.Value {
|
if opts.Browse.Value {
|
||||||
return CmdBrowse(globals, opts.Issue)
|
return CmdBrowse(globals, opts.Issue)
|
||||||
|
|||||||
+2
-2
@@ -59,8 +59,8 @@ func CmdRank(o *oreo.Client, globals *jiracli.GlobalOptions, opts *RankOptions)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !globals.Quiet.Value {
|
if !globals.Quiet.Value {
|
||||||
fmt.Printf("OK %s %s/browse/%s\n", opts.First, globals.Endpoint.Value, opts.First)
|
fmt.Printf("OK %s %s\n", opts.First, jira.URLJoin(globals.Endpoint.Value, "browse", opts.First))
|
||||||
fmt.Printf("OK %s %s/browse/%s\n", opts.Second, globals.Endpoint.Value, opts.Second)
|
fmt.Printf("OK %s %s\n", opts.Second, jira.URLJoin(globals.Endpoint.Value, "browse", opts.Second))
|
||||||
}
|
}
|
||||||
|
|
||||||
if opts.Browse.Value {
|
if opts.Browse.Value {
|
||||||
|
|||||||
+1
-1
@@ -108,7 +108,7 @@ func CmdSubtask(o *oreo.Client, globals *jiracli.GlobalOptions, opts *SubtaskOpt
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !globals.Quiet.Value {
|
if !globals.Quiet.Value {
|
||||||
fmt.Printf("OK %s %s/browse/%s\n", issueResp.Key, globals.Endpoint.Value, issueResp.Key)
|
fmt.Printf("OK %s %s\n", issueResp.Key, jira.URLJoin(globals.Endpoint.Value, "browse", issueResp.Key))
|
||||||
}
|
}
|
||||||
|
|
||||||
if opts.Browse.Value {
|
if opts.Browse.Value {
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ func CmdTransition(o *oreo.Client, globals *jiracli.GlobalOptions, opts *Transit
|
|||||||
return jiracli.CliError(err)
|
return jiracli.CliError(err)
|
||||||
}
|
}
|
||||||
if !globals.Quiet.Value {
|
if !globals.Quiet.Value {
|
||||||
fmt.Printf("OK %s %s/browse/%s\n", issueData.Key, globals.Endpoint.Value, issueData.Key)
|
fmt.Printf("OK %s %s\n", issueData.Key, jira.URLJoin(globals.Endpoint.Value, "browse", issueData.Key))
|
||||||
}
|
}
|
||||||
|
|
||||||
if opts.Browse.Value {
|
if opts.Browse.Value {
|
||||||
|
|||||||
+1
-1
@@ -64,7 +64,7 @@ func CmdVote(o *oreo.Client, globals *jiracli.GlobalOptions, opts *VoteOptions)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !globals.Quiet.Value {
|
if !globals.Quiet.Value {
|
||||||
fmt.Printf("OK %s %s/browse/%s\n", opts.Issue, globals.Endpoint.Value, opts.Issue)
|
fmt.Printf("OK %s %s\n", opts.Issue, jira.URLJoin(globals.Endpoint.Value, "browse", opts.Issue))
|
||||||
}
|
}
|
||||||
if opts.Browse.Value {
|
if opts.Browse.Value {
|
||||||
return CmdBrowse(globals, opts.Issue)
|
return CmdBrowse(globals, opts.Issue)
|
||||||
|
|||||||
+1
-1
@@ -71,7 +71,7 @@ func CmdWatch(o *oreo.Client, globals *jiracli.GlobalOptions, opts *WatchOptions
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !globals.Quiet.Value {
|
if !globals.Quiet.Value {
|
||||||
fmt.Printf("OK %s %s/browse/%s\n", opts.Issue, globals.Endpoint.Value, opts.Issue)
|
fmt.Printf("OK %s %s\n", opts.Issue, jira.URLJoin(globals.Endpoint.Value, "browse", opts.Issue))
|
||||||
}
|
}
|
||||||
|
|
||||||
if opts.Browse.Value {
|
if opts.Browse.Value {
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ func CmdWorklogAdd(o *oreo.Client, globals *jiracli.GlobalOptions, opts *Worklog
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if !globals.Quiet.Value {
|
if !globals.Quiet.Value {
|
||||||
fmt.Printf("OK %s %s/browse/%s\n", opts.Issue, globals.Endpoint.Value, opts.Issue)
|
fmt.Printf("OK %s %s\n", opts.Issue, jira.URLJoin(globals.Endpoint.Value, "browse", opts.Issue))
|
||||||
}
|
}
|
||||||
if opts.Browse.Value {
|
if opts.Browse.Value {
|
||||||
return CmdBrowse(globals, opts.Issue)
|
return CmdBrowse(globals, opts.Issue)
|
||||||
|
|||||||
+1
-3
@@ -1,8 +1,6 @@
|
|||||||
package jira
|
package jira
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiradata"
|
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiradata"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -12,7 +10,7 @@ func (j *Jira) GetProjectComponents(project string) (*jiradata.Components, error
|
|||||||
}
|
}
|
||||||
|
|
||||||
func GetProjectComponents(ua HttpClient, endpoint string, project string) (*jiradata.Components, error) {
|
func GetProjectComponents(ua HttpClient, endpoint string, project string) (*jiradata.Components, error) {
|
||||||
uri := fmt.Sprintf("%s/rest/api/2/project/%s/components", endpoint, project)
|
uri := URLJoin(endpoint, "rest/api/2/project", project, "components")
|
||||||
resp, err := ua.GetJSON(uri)
|
resp, err := ua.GetJSON(uri)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ func Search(ua HttpClient, endpoint string, sp SearchProvider) (*jiradata.Search
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
uri := fmt.Sprintf("%s/rest/api/2/search", endpoint)
|
uri := URLJoin(endpoint, "rest/api/2/search")
|
||||||
resp, err := ua.Post(uri, "application/json", bytes.NewBuffer(encoded))
|
resp, err := ua.Post(uri, "application/json", bytes.NewBuffer(encoded))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
+3
-4
@@ -3,7 +3,6 @@ package jira
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiradata"
|
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiradata"
|
||||||
)
|
)
|
||||||
@@ -35,7 +34,7 @@ func NewSession(ua HttpClient, endpoint string, ap AuthProvider) (*jiradata.Auth
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
uri := fmt.Sprintf("%s/rest/auth/1/session", endpoint)
|
uri := URLJoin(endpoint, "rest/auth/1/session")
|
||||||
resp, err := ua.Post(uri, "application/json", bytes.NewBuffer(encoded))
|
resp, err := ua.Post(uri, "application/json", bytes.NewBuffer(encoded))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -55,7 +54,7 @@ func (j *Jira) GetSession() (*jiradata.CurrentUser, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func GetSession(ua HttpClient, endpoint string) (*jiradata.CurrentUser, error) {
|
func GetSession(ua HttpClient, endpoint string) (*jiradata.CurrentUser, error) {
|
||||||
uri := fmt.Sprintf("%s/rest/auth/1/session", endpoint)
|
uri := URLJoin(endpoint, "rest/auth/1/session")
|
||||||
resp, err := ua.GetJSON(uri)
|
resp, err := ua.GetJSON(uri)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -75,7 +74,7 @@ func (j *Jira) DeleteSession() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func DeleteSession(ua HttpClient, endpoint string) error {
|
func DeleteSession(ua HttpClient, endpoint string) error {
|
||||||
uri := fmt.Sprintf("%s/rest/auth/1/session", endpoint)
|
uri := URLJoin(endpoint, "rest/auth/1/session")
|
||||||
resp, err := ua.Delete(uri)
|
resp, err := ua.Delete(uri)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"net/url"
|
||||||
|
"path"
|
||||||
)
|
)
|
||||||
|
|
||||||
func readJSON(input io.Reader, data interface{}) error {
|
func readJSON(input io.Reader, data interface{}) error {
|
||||||
@@ -21,3 +23,13 @@ func readJSON(input io.Reader, data interface{}) error {
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func URLJoin(endpoint string, paths ...string) string {
|
||||||
|
u, err := url.Parse(endpoint)
|
||||||
|
if err != nil {
|
||||||
|
panic(fmt.Errorf("Unable to parse endpoint: %s", endpoint))
|
||||||
|
}
|
||||||
|
paths = append([]string{u.Path}, paths...)
|
||||||
|
u.Path = path.Join(paths...)
|
||||||
|
return u.String()
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user