Giter Site home page Giter Site logo

kekyo / gitreader Goto Github PK

View Code? Open in Web Editor NEW
58.0 3.0 5.0 5.62 MB

Lightweight Git local repository traversal library for .NET/.NET Core/.NET Framework.

License: Apache License 2.0

C# 90.72% Batchfile 0.12% F# 8.45% Shell 0.71%
dotnet git managed repository fsharp csharp

gitreader's Issues

ToDo to 1.0.0

  • Reduces Task switching costs.
    • StreamReader
    • DeflateStream (optional, may not be implemented)
  • Completion for large repository tests. (Whether the data is corrupt or not)
    • Commit messages, metadatas.
    • Blob streams.
  • Makes configurable minor execution parameters.
  • Minor interface changing.

Other features will be considered after 1.0.0.

[Feature Request] Support git submodule repository

I want to get git submodule repository information with GitReader
Currency it fails to get information with Repository does not exist. exceptions occurred at following lines.

It's due to .git directory is not exist but only exists .git file on directory that are managed by git submodule.

Requested Features
Is is able to support for following repository types.

  • Repository that is maanaged by git submodule
  • Repository that is created with git init --separate-git-dir options

These repository contains .git file. and that file contains gitdir: directory path.

Additional context
As far as I've tested. It can get git submodule information with following code modifications.

        if (!Directory.Exists(repositoryPath))
        {
            if (!File.Exists(repositoryPath))
            {
                throw new ArgumentException("Repository does not exist.");
            }

            // Read `git` file's `gitdir:` information
            var gitDirLine = File.ReadAllLines(repositoryPath).FirstOrDefault() ?? "";
            if (gitDirLine.StartsWith("gitdir: ", StringComparison.Ordinal))
            {
                var gitDirPath = gitDirLine.Substring("gitdir: ".Length);

                // Resolve to full path (And normalize path directory separators)
                // TODO: Relative path that starts with "~/" should be resolved (Currently it's resolved as `~/` directory) 
                repositoryPath = Path.IsPathRooted(gitDirPath)
                    ? Path.GetFullPath(gitDirPath)
                    : Path.GetFullPath(Utilities.Combine(path, gitDirPath));
            }

            // Check specified `gitdir` exists
            if (!Directory.Exists(repositoryPath))
            {
                throw new ArgumentException("Repository does not exist. `.git` file exists. But failed to `gitdir` or specified directory is not exists.");
            }
        }

Wrong RemoteUrls data returned when git repository contains multiple remote sections

Describe the bug
I want to get RemoteUrls information with GitReader.
But it seems to return incorrect data if the `.git/config' file contains multiple remote sections.

To Reproduce
Run the following code on a git repository that contains multiple remote sections. (e.g. forked repository)

using var repository = await Repository.Factory.OpenPrimitiveAsync("[git repository path]");
foreach(var remoteUrl in repository.RemoteUrls)
{
    Console.WriteLine($"{remoteUrl.Key}:{remoteUrl.Value}");
}

Console outputs

origin: https://github.com/kekyo/GitReader.git

Excerpt of local .git/config file

[remote "origin"]
	url = https://github.com/my-forked-repo/GitReader.git
	fetch = +refs/heads/*:refs/remotes/origin/*
[remote "upstream"]
	url = https://github.com/kekyo/GitReader.git
	fetch = +refs/heads/*:refs/remotes/upstream/*

Expected behavior
I'm expecting following RemoteUrls information returned that match with git remote -v command output..

origin: https://github.com/my-forked-repo/GitReader.git
upstrem: https://github.com/kekyo/GitReader.git

Additional context
The current RepositoryAccessor::ReadRemoteReferencesAsync' method returns the following information.

  • First remote name.
  • Last remote url

Awesome work! ๐Ÿ˜

Having a managed library to read .git repository is a plus for the .NET ecosystem.

I quickly looked at how libGit2Sharp is used in our application and I'm wondering if you have in mind to support more things in this library or keep it super minimalistic.

Here is the main struct that we fill when we inspect a repo:

internal struct GitInfos
    {
        public string RemoteUrl;
        public IGitCommit HeadCommit;
        public IGitBranch CurrentBranch;
        public IReadOnlyList<GitBranch> Branches;
        public IGitTag[] Tags;
        public IGitRemote[] Remotes;
        public IGitStash[] Stashes;
        public DateTimeOffset LastCommitDate;
        public int BehindDefaultBranch;
        public IGitBranch DefaultRemoteBranch;
        public IGitOperation CurrentOperation;
}

Your lib seems to support already the main things but is lacking things like remotes or stashes.

Let me know, I'd be much interested to contribute. Cheers!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.