rugged icon indicating copy to clipboard operation
rugged copied to clipboard

i found a good library for git branches graph but dont know how interact with rugged :(

Open rmros opened this issue 9 years ago • 0 comments

i found a good library for git branches graph , lets see ---> http://gitgraphjs.com/ i clone a repository with rugged but i cant get all branches and all commit like git rev-list --all beside other each, its operate with just one ref/head like master

my goal is generate json of git branches for gitgraphjs.com library i wrote some program but i fail :(


def branchFinder(commitOid)
	@repo.references.each do |ref|
    if ref.target_id == commitOid
    return ref.name
    end
end
end



@first_commit =  @repo.branches["origin/feature/ansible-2.1"].target_id;
@branch = @repo.head.target
walker = Rugged::Walker.new(@repo)
walker.sorting(Rugged::SORT_TOPO ) # optional
walker.push(@first_commit)
i = 0
walker.each do  |commit|

	if commit.parent_ids.count == 1
		i+=1
		if commit.parent_ids == @first_commit
			puts "its head"
		elsif  
			puts "its just a commit"
		end
	    puts commit.oid
	elsif commit.parent_ids == []
		puts "its first commite of branch"
		puts commit.oid
	elsif commit.parent_ids.count > 1
			i+=1
			puts "its merge commit"
			puts "tedad: #{commit.parent_ids.count} parentha : #{commit.parent_ids} commit_oid #{commit.oid}"

	end 
	puts i
end

rmros avatar Nov 10 '16 14:11 rmros