libgit2 / libgit2/rugged

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

Open
#652 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
2.3k
Forks
293
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Rugged::Walker usage, @repo.references, @repo.branches, and @repo.head shown in the issue, then compare the requested traversal with the gitgraphjs output goal. Done means establishing how all branches and commits should be represented as JSON for gitgraphjs; no repository file or test is named.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, ruby
Domain
devtools
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.