Github-Linguist, Ruby version run over multiple repositories?

138 views Asked by At

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.

1

There are 1 answers

5
pchaigno On

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.