GithubHelp home page GithubHelp logo

astrohart / xylogix.interop.gitrepos Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 571 KB

(C#/x86/.NET 4.8) Library to interface to LibGit2Sharp and Git repositories. LibGit2Sharp is great, but is not intuitive. I really like LibGit2Sharp, but desired methods and objects that mimic the Visual Studio Team Explorer experience. The C# class called 'Team' in this library is where you start.

Batchfile 0.12% C# 99.88%

xylogix.interop.gitrepos's Introduction

xyLOGIX.Interop.GitRepos

This library serves as a user-friendly wrapper for some common Git operations supported by the libgit2 / libgit2sharp project, such as git add (known as Staging), git commit, git pull and git push.

I wanted a way to encapsulate the Wiki-provided examples for these common operations so I could just call them over and over again from code.

License

This library is released under the MIT License.

1. How to Use

This section covers a basic example of how to utilize this library. It's broken up into several pieces, but the main 'workhorse' class in the library is the Team class, that implements the ITeam interface.

The Team class is called as such because it's designed to mimic the user interface nomenclature of the Team Explorer in editions of Visual Studio that have the GitHub extension installed.

NOTE Just because we mentioned GitHub just now, don't think that this library works only with GitHub. Far from it. It works with any remote that is accessible via git -- well, at least it's designed to :-)

NOTE The library assumes that whatever local repository you're working on has already been configured in advance with ignores, remotes etc.

NOTE In order to utilize this library, not only should you reference it, but you must install the LibGit2Sharp NuGet package to the project that consumes this library.

Here's an example that commits and synchronizes (i.e., pulls, then pushes) all the modified, but not ignored, items in a working directory. The path to the working directory's .git folder is in the variable WorkingDirectoryRepo:

using LibGit2Sharp;
using xyLOGIX.Interop.GitRepos.GitRepositoryConfigurations;
using xyLOGIX.Interop.GitRepos;

namespace MyProject
{
    public static class Program
    {
        public static void Main(string[] args)
        {
            using (var team =
                new Team(new GitRepository("/path/to/your/repo/.git")))
            {
                team.AddGitRepositoryConfiguration(
                    new GitRepositoryConfiguration
                    {
                        Name = "xyLOGIX.Interop.GitRepos.Actions.Committers.Interfaces bar",
                        Email = "@noneofyourbeeswax",
                        RemoteUserName = "astrohart",
                        RemotePassword = "xxxxx"
                    }
                );

                team.CommitAllAndSync("Initial add");
            }
        }
    }
}

Using this wrapper library is literally that easy.

NOTE When creating a new GitRepositoryConfiguration object, do not set the IsActive property by hand. Call Team.SetGitRepositoryConfigurationActive on it instead. It should be noted that the AddGitRepositoryConfiguration method sets the configuration passed to it as active by default. Only one configuration can be marked as active at a time. If a Team method is called when more than one configuration is set active, a TeamConfigurationException will be thrown.

2. Further Work

This library is very bare-bones. Issues and pull requests are welcome to flesh it out, although maintaining this library is not a priority for me.

xylogix.interop.gitrepos's People

Watchers

 avatar  avatar

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.