Skip to content

Commit

Permalink
Trying something
Browse files Browse the repository at this point in the history
  • Loading branch information
rmanaem committed Aug 24, 2024
1 parent 5aa5f66 commit 1d8e16e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions scripts/fetch-repos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,9 @@ fetch_repos() {
while true; do
RESPONSE=$(fetch_repos)

# Debug: Output the raw response
echo "Response: $RESPONSE" >> debug.log

# Parse the JSON response to extract repository names
REPO_NAMES=$(echo "$RESPONSE" | jq -r '.[] | select(.name != ".github") | .name')

# Debug: Output the extracted repository names
echo "Repository Names: $REPO_NAMES" >> debug.log

# Check if no more repositories were returned
if [ -z "$REPO_NAMES" ]; then
break
Expand All @@ -46,9 +40,6 @@ while true; do
# Check if the .jsonld file exists in the annotations repository
FILE_EXISTS=$(curl -s -H "Authorization: token $GH_TOKEN" "https://api.github.com/repos/$ANNOTATIONS_REPO/contents/${JSONLD_FILE}" | jq -r '.name // empty')

# Debug: Output the result of the file existence check
echo "Checking $JSONLD_FILE: $FILE_EXISTS" >> debug.log

if [ -n "$FILE_EXISTS" ]; then
ANNOTATED=true
fi
Expand All @@ -61,9 +52,14 @@ while true; do
((PAGE++))
done

# Write repository information to the JSON file, ensuring it's clean
echo "[${REPOS[*]}]" | jq '.' > "$OUTPUT_FILE"
# Refactor JSON output handling
if [ ${#REPOS[@]} -eq 0 ]; then
# If no repositories were found, write an empty array
echo "[]" > "$OUTPUT_FILE"
else
# Join the REPOS array into a single JSON array
JSON_ARRAY=$(printf "%s," "${REPOS[@]}" | sed 's/,$//') # Remove trailing comma
echo "[$JSON_ARRAY]" | jq '.' > "$OUTPUT_FILE"
fi

# Debug: Output final JSON file content
cat "$OUTPUT_FILE" >> debug.log
echo "Repository information has been fetched and saved to $OUTPUT_FILE"
Empty file removed src/assets/repos.json
Empty file.

0 comments on commit 1d8e16e

Please sign in to comment.