強調表示: 同期貢献度グラフ
8265 ワード
数週間前、私は sync-contribution-graph の .見てみよう!
このツールを使用して、使用している他のアカウントからの貢献を GitHub 貢献グラフに正確に反映させることができます.たとえば、仕事以外ではハンドル mtfoley を使用していますが、仕事用に別のアカウントを使用しています.これを使用して自分の活動レベルを正確に反映でき、その作業ハンドルに関する個人情報が公開されないというアイデアが気に入っています.
それが機能する方法は非常に簡単です.ユーザー名と期間 (年) で構成すると、適切な URL への HTTP 要求が実行され、応答の HTML が解析されて、貢献の日付/カウントが求められます (これらは小さな緑色の四角に対応します).このデータに基づいて、適切な
リポジトリのセットアップ ワークフローでいくつかの提案を行い、 PR to update the README を送信しました.この作品や他の作品に興味を持っていただければ幸いです.
このツールを使用して、使用している他のアカウントからの貢献を GitHub 貢献グラフに正確に反映させることができます.たとえば、仕事以外ではハンドル mtfoley を使用していますが、仕事用に別のアカウントを使用しています.これを使用して自分の活動レベルを正確に反映でき、その作業ハンドルに関する個人情報が公開されないというアイデアが気に入っています.
それが機能する方法は非常に簡単です.ユーザー名と期間 (年) で構成すると、適切な URL への HTTP 要求が実行され、応答の HTML が解析されて、貢献の日付/カウントが求められます (これらは小さな緑色の四角に対応します).このデータに基づいて、適切な
git
シェル コマンドを作成します.シェル コマンドは、必要に応じてすぐに実行できるファイルに保存されます. src/index.js の要点であるスニペットを次に示します.import { parse } from "node-html-parser";
import axios from "axios";
import fs from "fs";
import shell from "shelljs";
// Gathers needed git commands for bash to execute per provided contribution data.
const getCommand = (contribution) => {
return `GIT_AUTHOR_DATE=${contribution.date}T12:00:00 GIT_COMMITER_DATE=${contribution.date}T12:00:00 git commit --allow-empty -m "Rewriting History!" > /dev/null\n`.repeat(
contribution.count
);
};
export default async (input) => {
// Returns contribution graph html for a full selected year.
const res = await axios.get(
`https://github.com/users/${input.username}/contributions?tab=overview&from=${input.year}-12-01&to=${input.year}-12-31`
);
// Retrieves needed data from the html, loops over green squares with 1+ contributions,
// and produces a multi-line string that can be run as a bash command.
const script = parse(res.data)
.querySelectorAll("[data-count]")
.map((el) => {
return {
date: el.attributes["data-date"],
count: parseInt(el.attributes["data-count"]),
};
})
.filter((contribution) => contribution.count > 0)
.map((contribution) => getCommand(contribution))
.join("")
.concat("git pull origin main\n", "git push -f origin main");
fs.writeFile("script.sh", script, () => {
console.log("\nFile was created successfully.");
if (input.execute) {
console.log("This might take a moment!\n");
shell.exec("sh ./script.sh");
}
});
};
リポジトリのセットアップ ワークフローでいくつかの提案を行い、 PR to update the README を送信しました.この作品や他の作品に興味を持っていただければ幸いです.
Reference
この問題について(強調表示: 同期貢献度グラフ), 我々は、より多くの情報をここで見つけました https://dev.to/mtfoley/highlighting-sync-contribution-graph-6o8テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol