-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest2.js
More file actions
79 lines (67 loc) · 2.27 KB
/
Copy pathtest2.js
File metadata and controls
79 lines (67 loc) · 2.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
const { Octokit } = require('@octokit/rest');
const t =require("git-credential-node")
const login=t.fillSync("https://github.com")
const simpleGit = require('simple-git');
// Initialiser Git
const git = simpleGit();
// Fonction pour récupérer les informations de configuration Git
async function getGitConfig() {
const config = {};
try {
config.user = login.username
config.email = await git.raw(['config', 'user.email']);
config.remoteUrl = "https://github.com/vbcq-volley/temp.git"
} catch (error) {
console.error('Error getting Git config:', error.message);
}
return config;
}
// Fonction pour extraire le propriétaire et le dépôt à partir de l'URL du dépôt distant
function extractRepoInfo(remoteUrl) {
const match = remoteUrl.match(/github\.com[:\/](.+?)\/(.+?)(?:\.git)?$/);
if (match) {
return {
owner: match[1],
repo: match[2]
};
}
return null;
}
// Fonction pour créer une issue pour une erreur
async function createIssueForError(errorMessage) {
const config = await getGitConfig();
if (!config.remoteUrl) {
console.error('Remote URL not found in Git config');
return;
}
const repoInfo = extractRepoInfo(config.remoteUrl);
if (!repoInfo) {
console.error('Could not extract repository information from remote URL');
return;
}
const { owner, repo } = repoInfo;
// Initialiser Octokit avec authentification (si nécessaire)
const octokit = new Octokit({
auth: login.password // Utilisez un token si nécessaire
});
try {
const response = await octokit.issues.create({
owner,
repo,
title: `Error Report: ${new Date().toISOString()}`,
body: `An error occurred:\n\n\`\`\`\n${errorMessage}\n\`\`\``,
labels: ['bug']
});
console.log(`Issue created: ${response.data.html_url}`);
} catch (error) {
console.error('Error creating issue:', error.message);
}
}
// Exemple d'utilisation
const errorMessages = [
'Erreur 1: Une erreur est survenue lors de lexécution du script.',
'Erreur 2: Une autre erreur est survenue.'
];
errorMessages.forEach(errorMessage => {
createIssueForError(errorMessage);
});