summaryrefslogtreecommitdiff
path: root/source/features/pr-commit-lines-changed.tsx
diff options
context:
space:
mode:
authorGravatar Federico Brigante <me@fregante.com> 2023-05-24 02:07:43 +0800
committerGravatar GitHub <noreply@github.com> 2023-05-23 18:07:43 +0000
commitf589546ddd9a1a1147620c15499b56ce5aa8e7d0 (patch)
tree9216d0575b303878c8a0725a218dd9302fd2188c /source/features/pr-commit-lines-changed.tsx
parent4a9a27982f487375070b623c16a76d92e2c6efad (diff)
downloadrefined-github-f589546ddd9a1a1147620c15499b56ce5aa8e7d0.tar.gz
refined-github-f589546ddd9a1a1147620c15499b56ce5aa8e7d0.tar.zst
refined-github-f589546ddd9a1a1147620c15499b56ce5aa8e7d0.zip
Meta: Use variables in GraphQL (#6674)
Diffstat (limited to 'source/features/pr-commit-lines-changed.tsx')
-rw-r--r--source/features/pr-commit-lines-changed.tsx26
1 files changed, 20 insertions, 6 deletions
diff --git a/source/features/pr-commit-lines-changed.tsx b/source/features/pr-commit-lines-changed.tsx
index 9513b85d..58bfddb0 100644
--- a/source/features/pr-commit-lines-changed.tsx
+++ b/source/features/pr-commit-lines-changed.tsx
@@ -9,15 +9,21 @@ import pluralize from '../helpers/pluralize.js';
const getCommitChanges = cache.function('commit-changes', async (commit: string): Promise<[additions: number, deletions: number]> => {
const {repository} = await api.v4(`
- repository() {
- object(expression: "${commit}") {
- ... on Commit {
- additions
- deletions
+ query getCommitChanges($owner: String!, $name: String!, $commit: String!) {
+ repository(owner: $owner, name: $name) {
+ object(expression: $commit) {
+ ... on Commit {
+ additions
+ deletions
+ }
}
}
}
- `);
+ `, {
+ variables: {
+ commit,
+ },
+ });
return [repository.object.additions, repository.object.deletions];
});
@@ -47,3 +53,11 @@ void features.add(import.meta.url, {
deduplicate: 'has-rgh-inner',
init,
});
+
+/*
+
+Test URLs:
+
+https://github.com/refined-github/refined-github/pull/6674/commits/3d93b7823e3c31d3bd1900ab1ec98f5ce41203bf
+
+*/