Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions static/js/publisher/pages/Builds/RepoSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { buildRepoConnectedState } from "../../state/buildsState";

import type { GithubData } from "../../types/";

type Repo = { name: string; nameWithOwner: string };
type Repo = { name: string; nameWithOwner: string; owner: string };

type Props = {
githubData: GithubData;
Expand Down Expand Up @@ -172,7 +172,9 @@ function RepoSelector({ githubData, setAutoTriggerBuild }: Props) {
}

const responseData = await response.json();
setRepos(responseData);
setRepos(
responseData.sort((a: Repo, b: Repo) => a.name.localeCompare(b.name)),
);
} catch (_error) {
setRepoFetchError("Failed to fetch repositories. Please try again.");
setRepos([]);
Expand Down Expand Up @@ -332,7 +334,9 @@ function RepoSelector({ githubData, setAutoTriggerBuild }: Props) {
))}
<datalist id="repo-list">
{repos.map((repo: Repo) => (
<option value={repo.name} key={repo.name} />
<option value={repo.name} key={repo.name}>
{repo.owner !== selectedOrg ? `Owned by ${repo.owner}` : ""}
</option>
))}
</datalist>
{repoFetchError && (
Expand Down
296 changes: 147 additions & 149 deletions tests/api/cassettes/GitHubTest.test_get_user_repositories.yaml
Original file line number Diff line number Diff line change
@@ -1,151 +1,149 @@
interactions:
- request:
body: '{"query": "{\n viewer {\n repositories(\n first:
100,\n privacy: PUBLIC,\n ownerAffiliations:
[OWNER],\n \n ) {\n edges {\n node
{\n name\n }\n }\n pageInfo
{\n hasNextPage\n endCursor\n }\n }\n }\n }"}'
headers:
Accept:
- application/json
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
Content-Length:
- '473'
Content-Type:
- application/json
User-Agent:
- storefront (516d523a5dba207e721d0f8e56d031af100ce611;devel)
method: POST
uri: https://api.github.com/graphql
response:
body:
string: !!binary |
H4sIAAAAAAAAA3WPPwvCMBDFv8vNWWx1sNBBdLAIxkko4nCYa41oEpL4J4Z+d5Pd3HLv3g8e7yII
9AhNhJekN9msLBntpNdWkss3iTGLUwSlBWVH4SNt8OT8DKaJ/SVVkdRFMi+SRSJnBgZH6tSgc4sr
uj19/CFZ0Ax4d8SAlFg/rdPpEejrY7hUy8BVH7jZ8s1t131XbZuS0vwAWZ+8kvoAAAA=
headers:
Access-Control-Allow-Origin:
- '*'
Access-Control-Expose-Headers:
- ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining,
X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval,
X-GitHub-Media-Type
Cache-Control:
- no-cache
Content-Encoding:
- gzip
Content-Security-Policy:
- default-src 'none'
Content-Type:
- application/json; charset=utf-8
Date:
- Mon, 17 Feb 2020 13:33:31 GMT
Referrer-Policy:
- origin-when-cross-origin, strict-origin-when-cross-origin
Server:
- GitHub.com
Status:
- 200 OK
Strict-Transport-Security:
- max-age=31536000; includeSubdomains; preload
Transfer-Encoding:
- chunked
Vary:
- Accept-Encoding, Accept, X-Requested-With
X-Accepted-OAuth-Scopes:
- repo
X-Content-Type-Options:
- nosniff
X-Frame-Options:
- deny
X-GitHub-Media-Type:
- github.v4
X-GitHub-Request-Id:
- AA88:D864:762CC31:8C7B0A0:5E4A962A
X-OAuth-Client-Id:
- cdeb3a60fecee4208395
X-OAuth-Scopes:
- read:org, repo
X-RateLimit-Limit:
- '5000'
X-RateLimit-Remaining:
- '4998'
X-RateLimit-Reset:
- '1581950009'
X-XSS-Protection:
- 1; mode=block
status:
code: 200
message: OK
- request:
body: '{"query": "{\n viewer {\n repositories(\n first:
100,\n privacy: PUBLIC,\n ownerAffiliations:
[OWNER],\n \n ) {\n edges {\n node
{\n name\n }\n }\n pageInfo
{\n hasNextPage\n endCursor\n }\n }\n }\n }"}'
headers:
Accept:
- application/json
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
Content-Length:
- '473'
Content-Type:
- application/json
User-Agent:
- storefront (516d523a5dba207e721d0f8e56d031af100ce611;devel)
method: POST
uri: https://api.github.com/graphql
response:
body:
string: '{"message":"Bad credentials","documentation_url":"https://developer.github.com/v4"}'
headers:
Access-Control-Allow-Origin:
- '*'
Access-Control-Expose-Headers:
- ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining,
X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval,
X-GitHub-Media-Type
Content-Length:
- '83'
Content-Security-Policy:
- default-src 'none'
Content-Type:
- application/json; charset=utf-8
Date:
- Mon, 17 Feb 2020 13:33:31 GMT
Referrer-Policy:
- origin-when-cross-origin, strict-origin-when-cross-origin
Server:
- GitHub.com
Status:
- 401 Unauthorized
Strict-Transport-Security:
- max-age=31536000; includeSubdomains; preload
Vary:
- Accept-Encoding, Accept, X-Requested-With
X-Content-Type-Options:
- nosniff
X-Frame-Options:
- deny
X-GitHub-Media-Type:
- github.v4
X-GitHub-Request-Id:
- AA88:D864:762CD9B:8C7B1F5:5E4A962B
X-RateLimit-Limit:
- '0'
X-RateLimit-Remaining:
- '0'
X-RateLimit-Reset:
- '1581950011'
X-XSS-Protection:
- 1; mode=block
status:
code: 401
message: Unauthorized
- request:
body:
'{"query": "{\n viewer {\n repositories(\n first:
100,\n privacy: PUBLIC,\n \n )
{\n edges {\n node {\n name\n nameWithOwner\n }\n }\n pageInfo
{\n hasNextPage\n endCursor\n }\n }\n }\n }"}'
headers:
Accept:
- application/json
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
Content-Length:
- "457"
Content-Type:
- application/json
User-Agent:
- storefront (516d523a5dba207e721d0f8e56d031af100ce611;devel)
method: POST
uri: https://api.github.com/graphql
response:
body:
string: '{"data":{"viewer":{"repositories":{"edges":[{"node":{"name":"test1","nameWithOwner":"testuser/test1"}},{"node":{"name":"test2","nameWithOwner":"testuser/test2"}},{"node":{"name":"test3","nameWithOwner":"testuser/test3"}},{"node":{"name":"test4","nameWithOwner":"testuser/test4"}},{"node":{"name":"test5","nameWithOwner":"testuser/test5"}}],"pageInfo":{"hasNextPage":false,"endCursor":"Y3Vyc29yOnYyOpHODjKIzA=="}}}}}'
headers:
Access-Control-Allow-Origin:
- "*"
Access-Control-Expose-Headers:
- ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining,
X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval,
X-GitHub-Media-Type
Cache-Control:
- no-cache
Content-Security-Policy:
- default-src 'none'
Content-Type:
- application/json; charset=utf-8
Date:
- Mon, 17 Feb 2020 13:33:31 GMT
Referrer-Policy:
- origin-when-cross-origin, strict-origin-when-cross-origin
Server:
- GitHub.com
Status:
- 200 OK
Strict-Transport-Security:
- max-age=31536000; includeSubdomains; preload
Vary:
- Accept-Encoding, Accept, X-Requested-With
X-Accepted-OAuth-Scopes:
- repo
X-Content-Type-Options:
- nosniff
X-Frame-Options:
- deny
X-GitHub-Media-Type:
- github.v4
X-GitHub-Request-Id:
- AA88:D864:762CC31:8C7B0A0:5E4A962A
X-OAuth-Client-Id:
- cdeb3a60fecee4208395
X-OAuth-Scopes:
- read:org, repo
X-RateLimit-Limit:
- "5000"
X-RateLimit-Remaining:
- "4998"
X-RateLimit-Reset:
- "1581950009"
X-XSS-Protection:
- 1; mode=block
status:
code: 200
message: OK
- request:
body:
'{"query": "{\n viewer {\n repositories(\n first:
100,\n privacy: PUBLIC,\n \n )
{\n edges {\n node {\n name\n nameWithOwner\n }\n }\n pageInfo
{\n hasNextPage\n endCursor\n }\n }\n }\n }"}'
headers:
Accept:
- application/json
Accept-Encoding:
- gzip, deflate, br, zstd
Connection:
- close
Content-Length:
- "457"
Content-Type:
- application/json
User-Agent:
- storefront (commit_id;devel)
method: POST
uri: https://api.github.com/graphql
response:
body:
string: '{"message":"Bad credentials","documentation_url":"https://docs.github.com/graphql","status":"401"}'
headers:
Access-Control-Allow-Origin:
- "*"
Access-Control-Expose-Headers:
- ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining,
X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes,
X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO,
X-GitHub-Request-Id, Deprecation, Sunset
Content-Length:
- "98"
Content-Security-Policy:
- default-src 'none'
Content-Type:
- application/json; charset=utf-8
Date:
- Tue, 14 Oct 2025 14:04:16 GMT
Referrer-Policy:
- origin-when-cross-origin, strict-origin-when-cross-origin
Server:
- github.com
Strict-Transport-Security:
- max-age=31536000; includeSubdomains; preload
Vary:
- Accept-Encoding, Accept, X-Requested-With
X-Content-Type-Options:
- nosniff
X-Frame-Options:
- deny
X-GitHub-Media-Type:
- github.v4
X-GitHub-Request-Id:
- EA4D:41CE:7AFD5A:95CF9A:68EE5860
X-RateLimit-Limit:
- "0"
X-RateLimit-Remaining:
- "0"
X-RateLimit-Reset:
- "1760454256"
X-RateLimit-Resource:
- graphql
X-RateLimit-Used:
- "0"
X-XSS-Protection:
- "0"
connection:
- close
status:
code: 401
message: Unauthorized
version: 1
11 changes: 10 additions & 1 deletion webapp/api/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,16 @@ def get_user_repositories(self, end_cursor=None):
next_page = self.get_user_repositories(page_info["endCursor"])
repositories.extend(next_page)

return repositories
repos = [
(
{**repo, "owner": repo.get("nameWithOwner", "").split("/")[0]}
if "nameWithOwner" in repo and repo.get("nameWithOwner")
else {**repo, "owner": None}
)
for repo in repositories
]

return repos

def get_org_repositories(self, org_login, end_cursor=None):
"""
Expand Down