kekyo / gitreader Goto Github PK
View Code? Open in Web Editor NEWLightweight Git local repository traversal library for .NET/.NET Core/.NET Framework.
License: Apache License 2.0
Lightweight Git local repository traversal library for .NET/.NET Core/.NET Framework.
License: Apache License 2.0
StreamReader
DeflateStream
(optional, may not be implemented)Other features will be considered after 1.0.0.
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.
GitReader/GitReader.Core/Primitive/PrimitiveRepositoryFacade.cs
Lines 27 to 30 in ce68b63
GitReader/GitReader.Core/Structures/StructuredRepositoryFacade.cs
Lines 175 to 178 in ce68b63
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.
git submodule
git init --separate-git-dir
optionsThese 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.");
}
}
Hi,
thanks for your work on this library. I build a small source generator that uses your GitReader and generates static info into a solution.
https://github.com/aviationexam/git-reader-source-generator
I want to let you know. Have a nice day
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.
remote
name.remote
urlHaving 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!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.