Skip to content

Commit c29a64b

Browse files
committed
Updating fork with changes from (andygrunwald#630)
- IssueLinks malformed when getting from Jira Server
1 parent 494083c commit c29a64b

File tree

3 files changed

+151
-131
lines changed

3 files changed

+151
-131
lines changed

cloud/issuelinktype.go

+14-5
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ func (s *IssueLinkTypeService) GetList(ctx context.Context) ([]IssueLinkType, *R
2525
return nil, nil, err
2626
}
2727

28-
linkTypeList := []IssueLinkType{}
28+
var linkTypeList map[string]([]IssueLinkType)
2929
resp, err := s.client.Do(req, &linkTypeList)
3030
if err != nil {
3131
return nil, resp, NewJiraError(resp, err)
3232
}
33-
return linkTypeList, resp, nil
33+
return linkTypeList["issueLinkTypes"], resp, nil
3434
}
3535

3636
// Get gets info of a specific issue link type from Jira.
@@ -39,7 +39,10 @@ func (s *IssueLinkTypeService) GetList(ctx context.Context) ([]IssueLinkType, *R
3939
//
4040
// TODO Double check this method if this works as expected, is using the latest API and the response is complete
4141
// This double check effort is done for v2 - Remove this two lines if this is completed.
42-
func (s *IssueLinkTypeService) Get(ctx context.Context, ID string) (*IssueLinkType, *Response, error) {
42+
func (s *IssueLinkTypeService) Get(
43+
ctx context.Context,
44+
ID string,
45+
) (*IssueLinkType, *Response, error) {
4346
apiEndPoint := fmt.Sprintf("rest/api/2/issueLinkType/%s", ID)
4447
req, err := s.client.NewRequest(ctx, http.MethodGet, apiEndPoint, nil)
4548
if err != nil {
@@ -60,7 +63,10 @@ func (s *IssueLinkTypeService) Get(ctx context.Context, ID string) (*IssueLinkTy
6063
//
6164
// TODO Double check this method if this works as expected, is using the latest API and the response is complete
6265
// This double check effort is done for v2 - Remove this two lines if this is completed.
63-
func (s *IssueLinkTypeService) Create(ctx context.Context, linkType *IssueLinkType) (*IssueLinkType, *Response, error) {
66+
func (s *IssueLinkTypeService) Create(
67+
ctx context.Context,
68+
linkType *IssueLinkType,
69+
) (*IssueLinkType, *Response, error) {
6470
apiEndpoint := "/rest/api/2/issueLinkType"
6571
req, err := s.client.NewRequest(ctx, http.MethodPost, apiEndpoint, linkType)
6672
if err != nil {
@@ -89,7 +95,10 @@ func (s *IssueLinkTypeService) Create(ctx context.Context, linkType *IssueLinkTy
8995
//
9096
// TODO Double check this method if this works as expected, is using the latest API and the response is complete
9197
// This double check effort is done for v2 - Remove this two lines if this is completed.
92-
func (s *IssueLinkTypeService) Update(ctx context.Context, linkType *IssueLinkType) (*IssueLinkType, *Response, error) {
98+
func (s *IssueLinkTypeService) Update(
99+
ctx context.Context,
100+
linkType *IssueLinkType,
101+
) (*IssueLinkType, *Response, error) {
93102
apiEndpoint := fmt.Sprintf("rest/api/2/issueLinkType/%s", linkType.ID)
94103
req, err := s.client.NewRequest(ctx, http.MethodPut, apiEndpoint, linkType)
95104
if err != nil {

onpremise/issuelinktype.go

+14-5
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ func (s *IssueLinkTypeService) GetList(ctx context.Context) ([]IssueLinkType, *R
2525
return nil, nil, err
2626
}
2727

28-
linkTypeList := []IssueLinkType{}
28+
var linkTypeList map[string]([]IssueLinkType)
2929
resp, err := s.client.Do(req, &linkTypeList)
3030
if err != nil {
3131
return nil, resp, NewJiraError(resp, err)
3232
}
33-
return linkTypeList, resp, nil
33+
return linkTypeList["issueLinkTypes"], resp, nil
3434
}
3535

3636
// Get gets info of a specific issue link type from Jira.
@@ -39,7 +39,10 @@ func (s *IssueLinkTypeService) GetList(ctx context.Context) ([]IssueLinkType, *R
3939
//
4040
// TODO Double check this method if this works as expected, is using the latest API and the response is complete
4141
// This double check effort is done for v2 - Remove this two lines if this is completed.
42-
func (s *IssueLinkTypeService) Get(ctx context.Context, ID string) (*IssueLinkType, *Response, error) {
42+
func (s *IssueLinkTypeService) Get(
43+
ctx context.Context,
44+
ID string,
45+
) (*IssueLinkType, *Response, error) {
4346
apiEndPoint := fmt.Sprintf("rest/api/2/issueLinkType/%s", ID)
4447
req, err := s.client.NewRequest(ctx, http.MethodGet, apiEndPoint, nil)
4548
if err != nil {
@@ -60,7 +63,10 @@ func (s *IssueLinkTypeService) Get(ctx context.Context, ID string) (*IssueLinkTy
6063
//
6164
// TODO Double check this method if this works as expected, is using the latest API and the response is complete
6265
// This double check effort is done for v2 - Remove this two lines if this is completed.
63-
func (s *IssueLinkTypeService) Create(ctx context.Context, linkType *IssueLinkType) (*IssueLinkType, *Response, error) {
66+
func (s *IssueLinkTypeService) Create(
67+
ctx context.Context,
68+
linkType *IssueLinkType,
69+
) (*IssueLinkType, *Response, error) {
6470
apiEndpoint := "/rest/api/2/issueLinkType"
6571
req, err := s.client.NewRequest(ctx, http.MethodPost, apiEndpoint, linkType)
6672
if err != nil {
@@ -89,7 +95,10 @@ func (s *IssueLinkTypeService) Create(ctx context.Context, linkType *IssueLinkTy
8995
//
9096
// TODO Double check this method if this works as expected, is using the latest API and the response is complete
9197
// This double check effort is done for v2 - Remove this two lines if this is completed.
92-
func (s *IssueLinkTypeService) Update(ctx context.Context, linkType *IssueLinkType) (*IssueLinkType, *Response, error) {
98+
func (s *IssueLinkTypeService) Update(
99+
ctx context.Context,
100+
linkType *IssueLinkType,
101+
) (*IssueLinkType, *Response, error) {
93102
apiEndpoint := fmt.Sprintf("rest/api/2/issueLinkType/%s", linkType.ID)
94103
req, err := s.client.NewRequest(ctx, http.MethodPut, apiEndpoint, linkType)
95104
if err != nil {
+123-121
Original file line numberDiff line numberDiff line change
@@ -1,121 +1,123 @@
1-
[
2-
{
3-
"id": "12310361",
4-
"name": "Blocked",
5-
"inward": "Blocked",
6-
"outward": "Blocked",
7-
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/12310361"
8-
},
9-
{
10-
"id": "10032",
11-
"name": "Blocker",
12-
"inward": "is blocked by",
13-
"outward": "blocks",
14-
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/10032"
15-
},
16-
{
17-
"id": "12310460",
18-
"name": "Child-Issue",
19-
"inward": "is a child of",
20-
"outward": "is a parent of",
21-
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/12310460"
22-
},
23-
{
24-
"id": "10020",
25-
"name": "Cloners",
26-
"inward": "is cloned by",
27-
"outward": "is a clone of",
28-
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/10020"
29-
},
30-
{
31-
"id": "12310060",
32-
"name": "Container",
33-
"inward": "Is contained by",
34-
"outward": "contains",
35-
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/12310060"
36-
},
37-
{
38-
"id": "12310461",
39-
"name": "Dependency",
40-
"inward": "Dependency",
41-
"outward": "Dependency",
42-
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/12310461"
43-
},
44-
{
45-
"id": "12310360",
46-
"name": "Dependent",
47-
"inward": "Dependent",
48-
"outward": "Dependent",
49-
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/12310360"
50-
},
51-
{
52-
"id": "12310000",
53-
"name": "Duplicate",
54-
"inward": "is duplicated by",
55-
"outward": "duplicates",
56-
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/12310000"
57-
},
58-
{
59-
"id": "12310010",
60-
"name": "Incorporates",
61-
"inward": "is part of",
62-
"outward": "incorporates",
63-
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/12310010"
64-
},
65-
{
66-
"id": "12310462",
67-
"name": "Parent Feature",
68-
"inward": "Parent Feature",
69-
"outward": "Parent Feature",
70-
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/12310462"
71-
},
72-
{
73-
"id": "12310560",
74-
"name": "Problem/Incident",
75-
"inward": "is caused by",
76-
"outward": "causes",
77-
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/12310560"
78-
},
79-
{
80-
"id": "10030",
81-
"name": "Reference",
82-
"inward": "is related to",
83-
"outward": "relates to",
84-
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/10030"
85-
},
86-
{
87-
"id": "12310050",
88-
"name": "Regression",
89-
"inward": "is broken by",
90-
"outward": "breaks",
91-
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/12310050"
92-
},
93-
{
94-
"id": "12310260",
95-
"name": "Related",
96-
"inward": "is related to",
97-
"outward": "relates to",
98-
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/12310260"
99-
},
100-
{
101-
"id": "12310040",
102-
"name": "Required",
103-
"inward": "is required by",
104-
"outward": "requires",
105-
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/12310040"
106-
},
107-
{
108-
"id": "12310051",
109-
"name": "Supercedes",
110-
"inward": "is superceded by",
111-
"outward": "supercedes",
112-
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/12310051"
113-
},
114-
{
115-
"id": "10001",
116-
"name": "dependent",
117-
"inward": "is depended upon by",
118-
"outward": "depends upon",
119-
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/10001"
120-
}
121-
]
1+
{
2+
"issueLinkTypes": [
3+
{
4+
"id": "12310361",
5+
"name": "Blocked",
6+
"inward": "Blocked",
7+
"outward": "Blocked",
8+
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/12310361"
9+
},
10+
{
11+
"id": "10032",
12+
"name": "Blocker",
13+
"inward": "is blocked by",
14+
"outward": "blocks",
15+
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/10032"
16+
},
17+
{
18+
"id": "12310460",
19+
"name": "Child-Issue",
20+
"inward": "is a child of",
21+
"outward": "is a parent of",
22+
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/12310460"
23+
},
24+
{
25+
"id": "10020",
26+
"name": "Cloners",
27+
"inward": "is cloned by",
28+
"outward": "is a clone of",
29+
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/10020"
30+
},
31+
{
32+
"id": "12310060",
33+
"name": "Container",
34+
"inward": "Is contained by",
35+
"outward": "contains",
36+
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/12310060"
37+
},
38+
{
39+
"id": "12310461",
40+
"name": "Dependency",
41+
"inward": "Dependency",
42+
"outward": "Dependency",
43+
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/12310461"
44+
},
45+
{
46+
"id": "12310360",
47+
"name": "Dependent",
48+
"inward": "Dependent",
49+
"outward": "Dependent",
50+
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/12310360"
51+
},
52+
{
53+
"id": "12310000",
54+
"name": "Duplicate",
55+
"inward": "is duplicated by",
56+
"outward": "duplicates",
57+
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/12310000"
58+
},
59+
{
60+
"id": "12310010",
61+
"name": "Incorporates",
62+
"inward": "is part of",
63+
"outward": "incorporates",
64+
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/12310010"
65+
},
66+
{
67+
"id": "12310462",
68+
"name": "Parent Feature",
69+
"inward": "Parent Feature",
70+
"outward": "Parent Feature",
71+
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/12310462"
72+
},
73+
{
74+
"id": "12310560",
75+
"name": "Problem/Incident",
76+
"inward": "is caused by",
77+
"outward": "causes",
78+
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/12310560"
79+
},
80+
{
81+
"id": "10030",
82+
"name": "Reference",
83+
"inward": "is related to",
84+
"outward": "relates to",
85+
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/10030"
86+
},
87+
{
88+
"id": "12310050",
89+
"name": "Regression",
90+
"inward": "is broken by",
91+
"outward": "breaks",
92+
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/12310050"
93+
},
94+
{
95+
"id": "12310260",
96+
"name": "Related",
97+
"inward": "is related to",
98+
"outward": "relates to",
99+
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/12310260"
100+
},
101+
{
102+
"id": "12310040",
103+
"name": "Required",
104+
"inward": "is required by",
105+
"outward": "requires",
106+
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/12310040"
107+
},
108+
{
109+
"id": "12310051",
110+
"name": "Supercedes",
111+
"inward": "is superceded by",
112+
"outward": "supercedes",
113+
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/12310051"
114+
},
115+
{
116+
"id": "10001",
117+
"name": "dependent",
118+
"inward": "is depended upon by",
119+
"outward": "depends upon",
120+
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/10001"
121+
}
122+
]
123+
}

0 commit comments

Comments
 (0)