我是GitHub上的一个组织的成员,该组织中有各种不同的项目。我正在寻找一种检查项目类型的方法,而不是实际打开它。
例如,如果它是Maven项目,我希望我的程序返回pom.xml
,如果它是Python项目,则返回requirements.txt
,如果它是Ruby项目,则返回{ {1}}等等。
有什么方法可以确定项目的类型吗?我尝试在线搜索,但无法在任何API中找到此功能。
感谢任何帮助。
答案 0 :(得分:0)
以下内容适用于curl
,jq
和XMLStarlet
。另见GitHub API Overview。还有a Ruby library to access the API。
$ curl -s https://api.github.com/orgs/apache/repos?per_page=4 | \
jq ".[] | {project: .full_name}"
{
"project": "apache/tapestry3"
}
{
"project": "apache/apr-iconv"
}
{
"project": "apache/tapestry4"
}
{
"project": "apache/tapestry5"
}
$ curl -s https://raw.githubusercontent.com/apache/maven/master/pom.xml_does_not_exist
404: Not Found
$ curl -s https://raw.githubusercontent.com/apache/maven/master/pom.xml | \
xml sel -t -o "[" -v "//_:project/_:parent/_:groupId" -o "|" \
-v "//_:project/_:groupId" -o "]:" -v "//_:project/_:artifactId" -o ":" \
-v "//_:project/_:version" -n -t -v "//_:project/_:name" -n -v "//_:project/_:description"
[org.apache.maven|]:maven:3.5.0-SNAPSHOT
Apache Maven
Maven is a software build management and
comprehension tool. Based on the concept of a project object model:
builds, dependency management, documentation creation, site
publication, and distribution publication are all controlled from
the declarative file. Maven can be extended by plugins to utilise a
number of other development tools for reporting or the build
process.