简体   繁体   中英

Github-Linguist, Ruby version run over multiple repositories?

I am trying to run the github linguist ruby verision, It runs on my computer, I am using visual studio. If i run the github-linguist it does give me the stats of percentage and type of language my repository have that is on local system. ( using terminal commands )

OutPut running Linguist using terminal visual code

Goal: To write a scripts in ruby that takes provided repository and provide me with the stats (similar to above screenshot) as described by github-linguist functionality.

Based on some research so far, all i have is following code.

require 'rugged'
require 'linguist'
target=""
repo = Rugged::Repository.new('https://github.com/NameOfRepo')
project=Linguist::Repository.new(repo,repo.head.target)
project.language
project.languages

But having error, and I need a guidance related to the error and a better way to reach my goal. Error: Error from script, Visual Code I am new to ruby and I would like for some help ?

I am aware of how to change my path to local clone repository path in above code. I am looking for help with writing scripts that traverse through online github repository and provide me the stats.

You need to pass the path to a directory to Rugged::Repository.new() , not a URL:

repo = Rugged::Repository.new('/home/ShaishavMaisuria/NameOfRepo')

FYI, the source code for the github-linguist executable is at https://github.com/github/linguist/blob/master/bin/github-linguist .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM