Giter Site home page Giter Site logo

git-macos's Introduction

Git.framework

A high-level swift framework to work with git command line in macOS

Git is a high-level swift framework based on the command line Git utility in macOS.

Features

  • Cloning remote repositories (git clone and git fetch). Including shallow clone support (--depth option);
  • Getting the list of references (branches, tags) in repositories;
  • Checking out references (git checkout);
  • Working with remotes (listing, renaming, setting urls);
  • Committing local changes and pushing to a remote repository (git commit and git push);
  • Getting log records for a repository (git log);
  • Listing pending log records (committed locally, but not pushed yet) and upcoming log records (commited on a remote, but not presented in the working copy)
  • Working with stashes (git stash);
  • Basic merge (git merge);

Git.framework has no dependencies. Just clone and build.

Requirements

  • macOS 10.13+
  • Xcode 10+
  • Swift 4.2+
  • Git for Mac 2.15+

Installation

Before installing this framework, please make sure you're using the correct version of Git in your system. You can check the current version via Terminal app:

git --version
$ git version 2.15.1

Carthage

To install Carthage you can use Homebrew. Use the following command in Terminal app:

$ brew update
$ brew install carthage

To integrate Git.framework into your Xcode project using Carthage, specify it in your Cartfile:

github "way-to-code/git-macOS" ~> 3.1.1

Run carthage update to build the framework and drag the built Git.framework into your Xcode project.

Swift 4.2

If you want to use Git.framework on Xcode 10.1 or lower, please use version 1.5.1

github "way-to-code/git-macOS" ~> 1.5.1

Manually

You can install Git.framework manually. Clone the project locally, build and integrate to your project as a framework

XCFramework

You may download XCFramework from the latests release page and integrate it into your project.

Note that XCFramework support is available since version 3.0.0.

Swift Package dependency

When you want to use Git.framework as a dependency in other package, you may follow the given example:

let package = Package(
    name: "MyPackage",
    
    products: [
        .library(name: "myProduct", targets: ["myTarget"]),
    ],
    
    dependencies: [
        .package(name: "Git",
                 url: "https://github.com/way-to-code/git-macOS.git",
                 .upToNextMajor(from: "3.1.1")),
    ],
    
    targets: [
        .target(name: "myTarget", dependencies: [
            .product(name: "Git", package: "Git")
        ]),
    ]
)

Basics

Read more about Git.framework in the Wiki page:

Quick examples

Simple clone

To clone a remote repository you need to create an object GitRepository

let repository = GitRepository(fromUrl: URL(string: "https://github.com/github/hub.git"))

Next, just call the clone method

try? repository.clone(atPath: "/Users/youruser/hub")

Providing credentials

You can specify credentials for repository with a help of GitCredentialsProvider. If no credentials are specified, credentials from the global macOS system git config are used by default.

let credentialsProvider = GitCredentialsProvider(username:"user", password:"****")
let repository = GitRepository(from: URL(string: "https://github.com/github/hub.git"), using: credentialsProvider)

Receiving the progress

You may keep track of the clone operation progress, by setting a delegate object on repository

let progressTracker = MyCustomObject()

let repository: GitRepository
repository.delegate = progressTracker

// implement RepositoryDelegate protocol in order to track the events
extension MyCustomObject: RepositoryDelegate {
func repository(_ repository: Repository, didProgressClone progress: String) {
}
}

git-macos's People

Contributors

way-to-code avatar jagreenwood avatar angelk90 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.