Skip to content

Commit 77ed662

Browse files
committed
update
1 parent 317d428 commit 77ed662

2 files changed

Lines changed: 86 additions & 6 deletions

File tree

.gitignore

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
1-
version https://git-lfs.github.com/spec/v1
2-
oid sha256:aef6816c010a1690ebfad85cbf6972b0657a08a086337a763d1ee5a3fbbe050a
3-
size 174
1+
# Ignore common binary files that might trigger Git LFS
2+
*.png
3+
*.jpg
4+
*.jpeg
5+
*.gif
6+
*.psd
7+
*.ai
8+
*.pdf
9+
*.zip
10+
*.tar.gz
11+
*.mp4
12+
*.mov
13+
*.avi
14+
*.mp3
15+
*.wav
16+
*.iso
17+
*.dmg
18+
*.exe
19+
*.dll
20+
*.jar
21+
/1_AI gifs/
22+
/'00_How do I'/
23+
/2_Hf/
24+
/3_Meta/
25+
/4_OpenAI/
26+

metadata.json

Lines changed: 60 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,60 @@
1-
version https://git-lfs.github.com/spec/v1
2-
oid sha256:8ebd148b5a695da6518569147d9648c6bf7173445e74c3cf0265d6f588873220
3-
size 2024
1+
const fetch = require('node-fetch');
2+
const fs = require('fs');
3+
const { execSync } = require('child_process');
4+
5+
async function updateMetadata() {
6+
// Get repository URL from git config
7+
const remoteUrl = execSync('git config --get remote.origin.url').toString().trim();
8+
9+
// Parse owner/repo from URL
10+
const urlRegex = /github\.com[:\/]([^\/]+)\/([^\.]+)(\.git)?/;
11+
const match = remoteUrl.match(urlRegex);
12+
13+
if (!match) {
14+
console.error('Could not parse GitHub repository URL');
15+
return;
16+
}
17+
18+
const [, owner, repo] = match;
19+
20+
// Fetch repository metadata from GitHub API
21+
const response = await fetch(`https://api.github.com/repos/${owner}/${repo}`, {
22+
headers: {
23+
'Accept': 'application/vnd.github+json',
24+
'Authorization': process.env.GITHUB_TOKEN ? `Bearer ${process.env.GITHUB_TOKEN}` : '',
25+
}
26+
});
27+
28+
if (!response.ok) {
29+
console.error(`GitHub API error: ${response.status}`);
30+
return;
31+
}
32+
33+
const repoData = await response.json();
34+
35+
// Read current metadata template
36+
const metadataTemplate = JSON.parse(fs.readFileSync('metadata_template.json', 'utf8'));
37+
38+
// Update fields with repository data
39+
metadataTemplate.title = repoData.name;
40+
metadataTemplate.description = repoData.description || metadataTemplate.description;
41+
metadataTemplate.version = repoData.pushed_at ? new Date(repoData.pushed_at).toISOString().split('T')[0] : metadataTemplate.version;
42+
43+
// Update keywords with topics
44+
if (repoData.topics && repoData.topics.length > 0) {
45+
metadataTemplate.keywords = repoData.topics;
46+
}
47+
48+
// Update related identifier
49+
if (metadataTemplate.related_identifiers && metadataTemplate.related_identifiers.length > 0) {
50+
metadataTemplate.related_identifiers[0].identifier = repoData.html_url;
51+
}
52+
53+
// Write updated metadata back to file
54+
fs.writeFileSync('CITATION.cff', JSON.stringify(metadataTemplate, null, 2));
55+
56+
console.log('Metadata successfully updated with repository information');
57+
}
58+
59+
updateMetadata().catch(console.error);
60+

0 commit comments

Comments
 (0)