GetFile: Use "ref" in-query if posible #491

Merged
6543 merged 9 commits from 6543/go-sdk:GetFile_use-ref_in-query_if-posible into master 2021-02-16 20:07:45 +00:00
Owner
based on https://github.com/go-gitea/gitea/pull/14563
6543 added this to the v0.14.0 milestone 2021-02-16 11:33:00 +00:00
6543 added the
kind/enhancement
label 2021-02-16 11:33:00 +00:00
6543 added 1 commit 2021-02-16 11:33:01 +00:00
GetFile: use ref in-query if posible
All checks were successful
continuous-integration/drone/pr Build is passing
0b46b13343
6543 added 1 commit 2021-02-16 14:36:34 +00:00
GetFile: test with ref="" and ref not default branch
All checks were successful
continuous-integration/drone/pr Build is passing
42dfc52e3d
6543 added 1 commit 2021-02-16 14:47:44 +00:00
bytes.Equal
All checks were successful
continuous-integration/drone/pr Build is passing
58f3add627
zeripath reviewed 2021-02-16 15:45:52 +00:00
Dismissed
@ -122,0 +121,4 @@
if c.checkServerVersionGreaterThanOrEqual(version1_14_0) != nil {
return c.getResponse("GET", fmt.Sprintf("/repos/%s/%s/raw/%s/%s", owner, repo, ref, tree), nil, nil)
}
return c.getResponse("GET", fmt.Sprintf("/repos/%s/%s/raw/%s?ref=%s", owner, repo, tree, ref), nil, nil)
Owner

tree and ref should both be escaped properly.

ref is simple as it's url.QueryEscape but tree needs escaping using the partial pathescape.

tree and ref should both be escaped properly. ref is simple as it's url.QueryEscape but tree needs escaping using the partial pathescape.
6543 marked this conversation as resolved
6543 added 1 commit 2021-02-16 16:51:49 +00:00
QueryEscape
All checks were successful
continuous-integration/drone/pr Build is passing
c60731a1f2
techknowlogick approved these changes 2021-02-16 17:02:15 +00:00
Dismissed
6543 added 1 commit 2021-02-16 17:49:05 +00:00
extreme test branch naming
All checks were successful
continuous-integration/drone/pr Build is passing
e1bfd1ce6f
6543 added 1 commit 2021-02-16 18:00:42 +00:00
test content itselve too
All checks were successful
continuous-integration/drone/pr Build is passing
c2b7a504b9
zeripath reviewed 2021-02-16 18:13:22 +00:00
Dismissed
@ -122,0 +122,4 @@
if c.checkServerVersionGreaterThanOrEqual(version1_14_0) != nil {
return c.getResponse("GET", fmt.Sprintf("/repos/%s/%s/raw/%s/%s", owner, repo, ref, tree), nil, nil)
}
return c.getResponse("GET", fmt.Sprintf("/repos/%s/%s/raw/%s?ref=%s", owner, repo, tree, url.QueryEscape(ref)), nil, nil)
Owner

tree needs to be util.PathEscapeSegments or something like it.

e.g. from Gitea modules/util

// PathEscapeSegments escapes segments of a path while not escaping forward slash
func PathEscapeSegments(path string) string {
	slice := strings.Split(path, "/")
	for index := range slice {
		slice[index] = url.PathEscape(slice[index])
	}
	escapedPath := strings.Join(slice, "/")
	return escapedPath
}

as does ref and tree on line 123

tree needs to be `util.PathEscapeSegments` or something like it. e.g. from Gitea modules/util ``` // PathEscapeSegments escapes segments of a path while not escaping forward slash func PathEscapeSegments(path string) string { slice := strings.Split(path, "/") for index := range slice { slice[index] = url.PathEscape(slice[index]) } escapedPath := strings.Join(slice, "/") return escapedPath } ``` as does ref and tree on line 123
Author
Owner

this is a more genneral issue witch I like to catch with #273 since we need this not only for this function...

this is a more genneral issue witch I like to catch with #273 since we need this not only for this function...
6543 marked this conversation as resolved
6543 added 1 commit 2021-02-16 19:22:41 +00:00
pathEscapeSegments
All checks were successful
continuous-integration/drone/pr Build is passing
12c4dc167b
6543 added 2 commits 2021-02-16 19:39:43 +00:00
Test: use strange file name
All checks were successful
continuous-integration/drone/pr Build is passing
c19c73c06b
zeripath approved these changes 2021-02-16 19:51:46 +00:00
Dismissed
6543 merged commit 32b0722f98 into master 2021-02-16 20:07:45 +00:00
6543 deleted branch GetFile_use-ref_in-query_if-posible 2021-02-16 20:07:52 +00:00
Sign in to join this conversation.
No description provided.