Skip to content

Instantly share code, notes, and snippets.

@mxdvl
Last active April 27, 2022 10:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mxdvl/db5f781599931631235373d015e7c720 to your computer and use it in GitHub Desktop.
Save mxdvl/db5f781599931631235373d015e7c720 to your computer and use it in GitHub Desktop.
git.io in public repos
  • File PULL_REQUEST_TEMPLATE.md from guardian/content-atom

  • git.io/v7cQshttps://github.com/guardian/content-api/blob/master/docs/adding-a-new-field-to-capi.md/

  • File index.ts from guardian/consent-management-platform

  • git.io/JUmoihttps://github.com/InteractiveAdvertisingBureau/GDPR-Transparency-and-Consent-Framework/blob/master/TCFv2/IAB%20Tech%20Lab%20-%20CMP%20API%20v2.md

  • git.io/JUmw8https://github.com/InteractiveAdvertisingBureau/GDPR-Transparency-and-Consent-Framework/blob/master/TCFv2/IAB%20Tech%20Lab%20-%20CMP%20API%20v2.md

  • File onConsentChange.ts from guardian/consent-management-platform

  • git.io/JUOdqhttps://github.com/InteractiveAdvertisingBureau/USPrivacy/blob/master/CCPA/USP%20API.md

  • git.io/JfrZrhttps://github.com/InteractiveAdvertisingBureau/GDPR-Transparency-and-Consent-Framework/blob/master/TCFv2/IAB%20Tech%20Lab%20-%20CMP%20API%20v2.md

  • File getConsentFor.ts from guardian/consent-management-platform

  • git.io/JUzVLhttps://github.com/guardian/consent-management-platform/issues

  • File TCData.ts from guardian/consent-management-platform

  • git.io/JJtY6https://github.com/InteractiveAdvertisingBureau/GDPR-Transparency-and-Consent-Framework/blob/master/TCFv2/IAB%20Tech%20Lab%20-%20CMP%20API%20v2.md

  • File README.md from guardian/consent-management-platform

  • git.io/JUzVLhttps://github.com/guardian/consent-management-platform/issues

  • File codeql-analysis.yml from guardian/node-modules

  • git.io/codeqlhttps://git.io/codeql

  • git.io/JvXDlhttps://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions

  • File check-node.js from guardian/gateway

  • git.io/vKTnKhttps://gist.github.com/sndrs/5940e9e8a3f506b287233ed65365befb

  • File PULL_REQUEST_TEMPLATE.md from guardian/security-hq

  • git.io/vNUJthttps://github.com/guardian/security-hq/blob/main/.github/CONTRIBUTING.md

  • File check-node.js from guardian/dotcom-rendering

  • git.io/vKTnKhttps://gist.github.com/sndrs/5940e9e8a3f506b287233ed65365befb

  • File codeql-analysis.yml from guardian/editorial-tools-integration-tests

  • git.io/JvXDlhttps://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions

  • File reset.overrides from guardian/https-ready

  • git.io/normalizehttps://github.com/anishathalye/?normalize

  • git.io/normalizehttps://github.com/anishathalye/?normalize

  • File reset.css from guardian/https-ready

  • git.io/normalizehttps://github.com/anishathalye/?normalize

  • git.io/normalizehttps://github.com/anishathalye/?normalize

  • File types.ts from guardian/discussion-rendering

  • git.io/JiKSdhttps://github.com/guardian/identity/blob/4d5410aeb789fae8d9440042d548167fca1fa53f/identity-model-play/src/main/scala/com/gu/identity/model/play/PrivateFields.scala

  • File codeql-analysis.yml from guardian/media-atom-maker

  • git.io/JvXDlhttps://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions

  • File setup.sh from guardian/support-frontend

  • git.io/vKTnKhttps://gist.github.com/sndrs/5940e9e8a3f506b287233ed65365befb

  • File _normalize.scss from guardian/interactive-supporting-text

  • git.io/normalizehttps://github.com/anishathalye/?normalize

  • File normalize.less from guardian/human-sensors

  • git.io/normalizehttps://github.com/anishathalye/?normalize

  • File bootstrap.css from guardian/human-sensors

  • git.io/normalizehttps://github.com/anishathalye/?normalize

  • File lib-normalize.css from guardian/open-platform-site

  • git.io/normalizehttps://github.com/anishathalye/?normalize

  • File _normalize.scss from guardian/contributions-frontend

  • git.io/normalizehttps://github.com/anishathalye/?normalize

  • File _normalize.scss from guardian/contributions-frontend

  • git.io/normalizehttps://github.com/anishathalye/?normalize

  • File _normalize.scss from guardian/membership-frontend

  • git.io/normalizehttps://github.com/anishathalye/?normalize

  • File _normalize.scss from guardian/membership-frontend

  • git.io/normalizehttps://github.com/anishathalye/?normalize

  • File _normalize.scss from guardian/subscriptions-frontend

  • git.io/normalizehttps://github.com/anishathalye/?normalize

  • File bootstrap.css from guardian/asset-frequency-graph

  • git.io/normalizehttps://github.com/anishathalye/?normalize

  • File _normalize.scss from guardian/interactive-brexit-companion

  • git.io/normalizehttps://github.com/anishathalye/?normalize

  • File _normalize.scss from guardian/reader-revenue-components

  • git.io/normalizehttps://github.com/anishathalye/?normalize

  • File normalize.scss from guardian/walled-worlds

  • git.io/normalizehttps://github.com/anishathalye/?normalize

  • File normalize.css from guardian/quiz-builder

  • git.io/normalizehttps://github.com/anishathalye/?normalize

  • File normalize.css from guardian/projectlocker

  • git.io/normalizehttps://github.com/anishathalye/?normalize

  • File normalize.css from guardian/you-make-the-tax-cuts-2016

  • git.io/normalizehttps://github.com/anishathalye/?normalize

  • File normalize.css from guardian/quizzes

  • git.io/normalizehttps://github.com/anishathalye/?normalize

  • File bootstrap.css from guardian/scala-automation-tstash

  • git.io/normalizehttps://github.com/anishathalye/?normalize

  • File materialize.css from guardian/amiable

  • git.io/normalizehttps://github.com/anishathalye/?normalize

  • File CHANGELOG.md from guardian/australian-federal-election-polling-places-voronoi

  • git.io/djbhttps://github.com/davidjb

  • File CHANGELOG.md from guardian/land-clearing-gis-relocator-tool-global

  • git.io/djbhttps://github.com/davidjb

  • File index.js from guardian/actions-source-analysis

  • git.io/upgradehttps://axkzer.github.io/upgrade.html

  • File CHANGELOG.md from guardian/australian-frontier-massacres

  • git.io/djbhttps://github.com/davidjb

  • File index.js from guardian/typescript-monitor-action

  • git.io/upgradehttps://axkzer.github.io/upgrade.html

  • File index.js from guardian/actions-merge-release-changes-to-protected-branch

  • git.io/upgradehttps://axkzer.github.io/upgrade.html

const [token] = Deno.args;
console.log("using token", token);
export const auth = {
Authorization: `token ${token}`,
};
export const asJsonWithAuth = <T>(url: string): Promise<T> =>
fetch(url, { headers: auth }).then((r) => r.json());
import type { Match } from "./main.ts";
export const format = (matches: Match[]): string => {
const repos = matches.reduce<Record<string, Match[]>>((acc, curr) => {
const repo = curr.repository.full_name;
if (!repo) return acc;
if (!acc[repo]) acc[repo] = [];
acc[repo].push(curr);
return acc;
}, {});
const md = Object.entries(repos)
.map(([repo, matches]) => {
const working = matches
.map(({ name, url, links }) => {
const title = `- File [\`${name}\`](${url}) from ${repo}`;
const resovled = links
.map(([from, to]) => ` - [ ] \`${from}\` &rarr; \`${to}\``)
.join("\n");
return [title, "", resovled].join("\n");
})
.join("\n");
return [`## [\`${repo}\`](https://github.com/${repo})`, working].join(
"\n"
);
})
.join("\n\n");
return md;
};
import { asJsonWithAuth, auth } from "./auth.ts";
import { search, SearchResult } from "./search.ts";
import { format } from "./formatting.ts";
const matches = await search('org:guardian "git.io"');
type Content = {
node_id: string;
sha: string;
size: number;
url: string;
content: string;
message?: string;
};
const contents: Promise<[SearchResult, Content][]> = Promise.all(
matches.map(async (file) => [file, await asJsonWithAuth(file.git_url)])
);
const getResolvedLink = async (url: string): Promise<[string, string]> => {
return [
url,
(
await fetch(`https://${url}`, {
headers: {
...auth,
},
})
).url,
];
};
export type Match = {
name: string;
repository: SearchResult["repository"];
url: string;
links: [string, string][];
};
const promises = (await contents).map(
async ([{ name, repository }, { content, url }]) => {
const rawLinks = atob(content).match(/git\.io\/.+?\b/gi) ?? [];
const links = await Promise.all(rawLinks.map(getResolvedLink));
return <Match>{ name, repository, url, links };
}
);
const results = await Promise.all(promises);
const markdown = format(results);
console.log(markdown);
// Deno.writeTextFileSync("./git-io-files.json", JSON.stringify(urls));
import { asJsonWithAuth } from "./auth.ts";
export type SearchResult = {
name: string;
path: string;
sha: string;
url: string;
git_url: string;
html_url: string;
repository: {
id: number;
node_id: string;
name: string;
full_name: string;
private: boolean;
};
};
export const search = async (q: string) => {
const params = new URLSearchParams({ q, per_page: "100" });
const {
incomplete_results,
total_count,
items,
}: {
total_count: number;
incomplete_results: boolean;
items: SearchResult[];
} = await asJsonWithAuth(
"https://api.github.com/search/code?" + params.toString()
);
console.log({ total_count, incomplete_results });
return items.filter((item) => !item.repository.private);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment