njh / arduino-libraries

A website listing all the available Arduino Libraries
https://www.arduinolibraries.info/
MIT License
54 stars 12 forks source link

Bug: wrong reponame #42

Open 80avin opened 10 months ago

80avin commented 10 months ago

Caused in : https://github.com/njh/arduino-libraries/commit/21dd4df1ea7150846c5c7d71b1ac90130f187db5

Description: For some libraries, reponame is wrong. Happens when "repository" property and "website" property refer to different repos. This is not expected but in this case, we should be using "repository" property.

Example: robopoly-linear-camera library is described as

    {
      "name": "Robopoly Linear Camera",
      "version": "0.2.0",
      "author": "Marco Pagnamenta, Karl Kangur, David Perrenoud, Robopoly",
      "maintainer": "Robopoly \u003crobopoly@epfl.ch\u003e",
      "sentence": "This library allows you to get data from the Robopoly Linear Camera.",
      "website": "https://github.com/Robopoly/Robopoly_PRismino",
      "category": "Sensors",
      "architectures": [
        "avr"
      ],
      "types": [
        "Contributed"
      ],
      "repository": "https://github.com/Robopoly/Robopoly_Linear_Camera.git",
      "url": "https://downloads.arduino.cc/libraries/github.com/Robopoly/Robopoly_Linear_Camera-0.2.0.zip",
      "archiveFileName": "Robopoly_Linear_Camera-0.2.0.zip",
      "size": 6197,
      "checksum": "SHA-256:639d6baf23d2880b61eb885e0f581e6a43b52b982e981a035e971201e4cdbbc6"
    }

Here, the "repository" is correctly available, but the code derives reponame from "website"

Looks like when "URL" property was replaced with "repository" property in this commit, we should have removed the logic of looking at overrides and directly used the "repository" property, with no overriding.

Further, I found that all of the github based libraries have "repository" pointing to valid github repo and none requires guessing "username", "reponame" from "URL" property. Hence, this code can be simplified as

  if library[:repository] =~ %r|https?://github\.com/([\w\-]+)/([\w\-]+)(\.git)?|i
    username, reponame = $1, $2
    library[:username] = username
    library[:reponame] = reponame
    library[:github] = "https://github.com/#{username}/#{reponame}"
  else
  # ...rest code