Skip to content
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

small ultility that helps team to get all names/ids they own. #20495

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/taskIdbyowner.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// /workspaces/azure-pipelines-tasks $ node ./.github/taskIdbyowner.js

const fs = require('fs');
const path = require('path');

const codeownersFilePath = '/workspaces/azure-pipelines-tasks/.github/CODEOWNERS';
const teamName = '@microsoft/azure-artifacts-packages';

function extractTasksOwnedByTeam(filePath, team) {
const tasks = [];
const lines = fs.readFileSync(filePath, 'utf-8').split('\n');
lines.forEach(line => {
if (line.includes(team)) {
const taskPath = line.split(/\s+/)[0];
tasks.push(taskPath);
}
});
return tasks;
}

function extractTaskId(taskPath) {
const taskJsonPath = path.join(taskPath, 'task.json');
if (fs.existsSync(taskJsonPath)) {
const taskData = JSON.parse(fs.readFileSync(taskJsonPath, 'utf-8'));
return taskData.id || null;
}
return null;
}

// Extract tasks owned by the specified team
const tasksOwnedByTeam = extractTasksOwnedByTeam(codeownersFilePath, teamName);

// Extract and print the task IDs for each task
tasksOwnedByTeam.forEach(task => {
const taskId = extractTaskId(task);
if (taskId) {
console.log(`Task Path: ${task}, Task ID: ${taskId}`);
} else {
console.log(`Task Path: ${task}, Task ID: Not Found`);
}
});