-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: add an example of syncing labels (#823)
docs: add an example of syncing labels Reviewed-by: František Lachman <[email protected]>
- Loading branch information
Showing
2 changed files
with
209 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,208 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Syncing labels between projects" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 16, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import os\n", | ||
"\n", | ||
"from ogr import GithubService\n", | ||
"\n", | ||
"service = GithubService(token=os.getenv(\"GITHUB_TOKEN\"))" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Now we will fetch the labels from the source project." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 17, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"[Label(name=\"area/cli\"),\n", | ||
" Label(name=\"area/config\"),\n", | ||
" Label(name=\"area/copr\"),\n", | ||
" Label(name=\"area/database\"),\n", | ||
" Label(name=\"area/fedora\"),\n", | ||
" Label(name=\"area/general\"),\n", | ||
" Label(name=\"area/github\"),\n", | ||
" Label(name=\"area/gitlab\"),\n", | ||
" Label(name=\"area/image-builder\"),\n", | ||
" Label(name=\"area/other\"),\n", | ||
" Label(name=\"area/rhel-ecosystem\"),\n", | ||
" Label(name=\"area/testing-farm\"),\n", | ||
" Label(name=\"area/user-experience\"),\n", | ||
" Label(name=\"blocked\"),\n", | ||
" Label(name=\"complexity/easy-fix\"),\n", | ||
" Label(name=\"complexity/epic\"),\n", | ||
" Label(name=\"complexity/single-task\"),\n", | ||
" Label(name=\"demo\"),\n", | ||
" Label(name=\"discuss\"),\n", | ||
" Label(name=\"do-not-merge\"),\n", | ||
" Label(name=\"duplicate\"),\n", | ||
" Label(name=\"gain/high\"),\n", | ||
" Label(name=\"gain/low\"),\n", | ||
" Label(name=\"good-first-issue\"),\n", | ||
" Label(name=\"GSOC\"),\n", | ||
" Label(name=\"Hacktoberfest\"),\n", | ||
" Label(name=\"has-release-notes\"),\n", | ||
" Label(name=\"help-wanted\"),\n", | ||
" Label(name=\"impact/high\"),\n", | ||
" Label(name=\"impact/low\"),\n", | ||
" Label(name=\"invalid\"),\n", | ||
" Label(name=\"kind/bug\"),\n", | ||
" Label(name=\"kind/documentation\"),\n", | ||
" Label(name=\"kind/feature\"),\n", | ||
" Label(name=\"kind/internal\"),\n", | ||
" Label(name=\"kind/other\"),\n", | ||
" Label(name=\"kind/refactor\"),\n", | ||
" Label(name=\"mergeit\"),\n", | ||
" Label(name=\"need-info\"),\n", | ||
" Label(name=\"needs-design\"),\n", | ||
" Label(name=\"pinned\"),\n", | ||
" Label(name=\"ready-for-review\"),\n", | ||
" Label(name=\"release\"),\n", | ||
" Label(name=\"RHOSC\"),\n", | ||
" Label(name=\"security\"),\n", | ||
" Label(name=\"source-git\"),\n", | ||
" Label(name=\"stale\"),\n", | ||
" Label(name=\"testing\"),\n", | ||
" Label(name=\"triaged\"),\n", | ||
" Label(name=\"wontfix\"),\n", | ||
" Label(name=\"workaround-exists\"),\n", | ||
" Label(name=\"🌞 friday 🤟\")]" | ||
] | ||
}, | ||
"execution_count": 17, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"project = service.get_project(namespace=\"packit\", repo=\"packit\")\n", | ||
"labels = project.get_labels()\n", | ||
"\n", | ||
"labels" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"In this case I only want to sync the labels we use during the refinement of the tickets." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 18, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"[Label(name=\"area/cli\"),\n", | ||
" Label(name=\"area/config\"),\n", | ||
" Label(name=\"area/copr\"),\n", | ||
" Label(name=\"area/database\"),\n", | ||
" Label(name=\"area/fedora\"),\n", | ||
" Label(name=\"area/general\"),\n", | ||
" Label(name=\"area/github\"),\n", | ||
" Label(name=\"area/gitlab\"),\n", | ||
" Label(name=\"area/image-builder\"),\n", | ||
" Label(name=\"area/other\"),\n", | ||
" Label(name=\"area/rhel-ecosystem\"),\n", | ||
" Label(name=\"area/testing-farm\"),\n", | ||
" Label(name=\"area/user-experience\"),\n", | ||
" Label(name=\"complexity/easy-fix\"),\n", | ||
" Label(name=\"complexity/epic\"),\n", | ||
" Label(name=\"complexity/single-task\"),\n", | ||
" Label(name=\"gain/high\"),\n", | ||
" Label(name=\"gain/low\"),\n", | ||
" Label(name=\"impact/high\"),\n", | ||
" Label(name=\"impact/low\"),\n", | ||
" Label(name=\"kind/bug\"),\n", | ||
" Label(name=\"kind/documentation\"),\n", | ||
" Label(name=\"kind/feature\"),\n", | ||
" Label(name=\"kind/internal\"),\n", | ||
" Label(name=\"kind/other\"),\n", | ||
" Label(name=\"kind/refactor\")]" | ||
] | ||
}, | ||
"execution_count": 18, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"wanted_labels = list(filter(lambda l: \"/\" in l.name, labels))\n", | ||
"\n", | ||
"wanted_labels" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"And now we can sync them to the other project." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 19, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"26" | ||
] | ||
}, | ||
"execution_count": 19, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"target_project = service.get_project(namespace=\"packit\", repo=\"validation\")\n", | ||
"target_project.update_labels(wanted_labels)" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.12.0" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |