-
-
Notifications
You must be signed in to change notification settings - Fork 28.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The Great Migration - Tools update #22201
Comments
|
The documentation update is a separate discussion which should probably be done in that repo. Migrating the docs for an integration from many platform pages into the component page is under way. But it doesn't scale for large integrations that need details for their platforms. See eg home-assistant/home-assistant.io#8593. |
It won't be necessary to merge all the docs, as long as we just treat the component as an entrypoint to the docs for that integration. The page itself will actually show its platforms. |
don't laugh at my janky modern js skills script to update component labels: const Octokit = require('@octokit/rest')
const octokit = new Octokit({
auth: 'token TOKEN_HERE'
});
const options = octokit.issues.listLabelsForRepo.endpoint.merge({
owner: 'home-assistant',
repo: 'home-assistant',
per_page: 100,
})
octokit.paginate(options)
.then(data => {
data.forEach(existing_label => {
if(existing_label.name.indexOf('component: ') !== -1) {
console.log('rename', existing_label.name, 'to', existing_label.name.replace('component: ', 'integration: '));
octokit.issues.updateLabel({
owner: 'home-assistant',
repo: 'home-assistant',
current_name: existing_label.name,
name: existing_label.name.replace('component: ', 'integration: '),
}).then(updated_label => {
console.log('Updated', existing_label.name, 'to', updated_label.name);
})
}
});
}); script to update platform labels: const Octokit = require('@octokit/rest')
const octokit = new Octokit({
auth: 'token TOKEN_HERE'
});
const options = octokit.pulls.list.endpoint.merge({
owner: 'home-assistant',
repo: 'home-assistant',
state: 'open',
per_page: 100,
})
octokit.paginate(options).then(data => {
data.forEach(pull_request => {
var needsLabelUpdate = false;
var newLabels = [];
pull_request.labels.forEach(label => {
if(label.name.indexOf('platform: ') !== -1) {
needsLabelUpdate = true;
var splitName = label.name.split('.');
label.name = 'integration: '+splitName[1];
}
newLabels.push(label.name);
});
if(needsLabelUpdate) {
console.log('newLabels', pull_request.number, newLabels);
octokit.issues.update({
owner: 'home-assistant',
repo: 'home-assistant',
number: pull_request.number,
labels: newLabels,
}).then(({data, headers, status}) => {
console.log('Updated labels for PR', data.number);
})
}
});
}); |
Here's one related helpful script to get a detailed breakdown of label usage in a repo. It output these stats. const graphql = require('@octokit/graphql').defaults({
headers: {
authorization: `token TOKEN_HERE`
}
})
async function getCounts(owner, repoName, labelMap, cursor){
if(!labelMap) labelMap = {};
const labelsWithCursor = await graphql(`query labelsWithCursor($owner: String!, $repoName: String! $after: String = null) {
repository(owner:$owner, name:$repoName) {
labels(first: 100, after:$after) {
edges {
cursor
node {
name
openIssues: issues(states: [OPEN]) {
totalCount
}
closedIssues: issues(states: [CLOSED]) {
totalCount
}
openPRs: pullRequests(states: [OPEN]) {
totalCount
}
mergedPRs: pullRequests(states: [MERGED]) {
totalCount
}
closedPRs: pullRequests(states: [CLOSED]) {
totalCount
}
}
}
}
}
}`, {
owner: owner,
repoName: repoName,
after: cursor
});
labelsWithCursor.repository.labels.edges.forEach(edge => {
if(!labelMap[edge.node.name]) {
labelMap[edge.node.name] = {
'Open Issues': edge.node.openIssues.totalCount,
'Closed Issues': edge.node.closedIssues.totalCount,
'Open Pull Requests': edge.node.openPRs.totalCount,
'Merged Pull Requests': edge.node.mergedPRs.totalCount,
'Closed Pull Requests': edge.node.closedPRs.totalCount
};
}
labelMap[edge.node.name]['Open Issues'] = labelMap[edge.node.name]['Open Issues'] + edge.node.openIssues.totalCount;
labelMap[edge.node.name]['Closed Issues'] = labelMap[edge.node.name]['Closed Issues'] + edge.node.closedIssues.totalCount;
labelMap[edge.node.name]['Open Pull Requests'] = labelMap[edge.node.name]['Open Pull Requests'] + edge.node.openPRs.totalCount;
labelMap[edge.node.name]['Merged Pull Requests'] = labelMap[edge.node.name]['Merged Pull Requests'] + edge.node.mergedPRs.totalCount;
labelMap[edge.node.name]['Closed Pull Requests'] = labelMap[edge.node.name]['Closed Pull Requests'] + edge.node.closedPRs.totalCount;
});
var lastElm = labelsWithCursor.repository.labels.edges.pop();
if(!lastElm) {
return labelMap;
}
return await getCounts(owner, repoName, labelMap, lastElm.cursor);
};
const start = async function(){
const labelMap = await getCounts("home-assistant", "home-assistant");
console.log(JSON.stringify(labelMap));
}
start(); |
List of broken labels that need fixing:
Choose one to keep:
|
Hopefully final list of labels after migration is completed, please point out any that should be cleaned up (or even better, do it yourself):
|
|
Implemented all of @Swamp-Ig's suggestions. |
Deletion of |
Thanks all but mostly me! |
With the great migration coming to an end, it's time to track the final tasks and make sure they are done before 0.91.
component: hue
tointegration: hue
platform: light.hue
->integration: hue
. (let's not do all PRs or we hit all the rate limits)integration: hue
labels (this function)The text was updated successfully, but these errors were encountered: