Code Monkey home page Code Monkey logo

git-subrepo-ng's Introduction

Subrepo

An experimental clone of git subrepo, to be extended with improvements.

Installation

Add this line to your application's Gemfile:

gem 'subrepo'

And then execute:

$ bundle

Or install it yourself as:

$ gem install subrepo

Usage

Summary:

git subrepo init subdir --remote remote --branch branch
git subrepo push subdir
git subrepo fetch subdir
git subrepo pull subdir
git subrepo commit subdir

What Does This Do?

This is an experimental re-implementation of git-subrepo, with the following goals:

  • Keep as much history as reasonably possible, both when pushing and pulling. In particular, do not squash history when pulling subrepo changes back into the main repo
  • Be performant
  • Have nicer generated commit messages

Initializing an Existing Directory As a Subrepo

git subrepo init subdir --remote <remote> --branch <branch>

Sets up configuration for handling the given subdirectory as a subrepo. A remote repository to push to and pull from, as well as the remote branch to use, must be provided.

This sets up a .gitrepo in the subdirectory with inital settings, and commits it.

First Push

git subrepo push subdir [--remote <remote>] [--branch <branch>]

Rewrites the history for the subrepo to a new branch, then pushes that branch to the remote.

The .gitrepo file is not pushed to the remote.

The last commit of the pushed history and the last commit of the original history are both recorded in the .gitrepo file.

Subsequent Pushes

git subrepo push subdir [--remote <remote>] [--branch <branch>]

Rewrites the new part of the history of the subrepo to a new branch, then pushes that to the remote.

The last commit of the pushed history and the last commit of the original history are both recorded in the .gitrepo file.

It is highly recommended to specify a different branch to push to, so that the pushed changes can be turned into a pull request or checked in other ways before merging into the master branch.

Pulling Changes From Upstream

git subrepo pull subdir [--remote <remote>]

Fetches commits from the remote and rewrites them as part of the history of the subrepo.

The last fetched commit is recorded in the .gitrepo file.

Status of This Project

This code is experimental. Try at your own risk. Implementation of subrepo functionality is incomplete. In particular, it is not yet possible to clone a remote into a new subrepo.

Caveats

Because git-subrepo-ng stores commit shas for fetched and pushed commits in the .gitrepo file, you should be careful when rebasing branches. In particular, you should pull from the remote's main development branch, and push from the main repository's main development branch.

Development

After checking out the repo, run script/setup to install dependencies. Then, run rake spec to run the tests. You can also run script/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/mvz/subrepo. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

Copyright © 2019-2020 Matijs van Zuijlen

This is free software, distributed under the terms of the GNU General Public License, version 3.0 or later. See the file COPYING for more information.

The test suite in test/ is based on the test suite of git-subrepo, which is licensed under the MIT License and copyright © 2013-2020 Ingy döt Net.

Code of Conduct

Everyone interacting in the Subrepo project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

git-subrepo-ng's People

Contributors

dependabot[bot] avatar mvz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

git-subrepo-ng's Issues

Improve testing of CLI wiring

I would like to test git-subrepo-ng through the command-line argument parser, e.g., call the commands like so:

runner = Subrepo::CLI.new.tap(&:setup)
runner.run ["pull", "foo", "--no-squash"]

The reason is that this will exercise the CLI wiring, which is now only really tested in the bash-based end-to-end tests.

GLI makes this hard because it will catch and process errors. There's also something funny happening where, if you forget setup, you get a help screen from cucumber. Perhaps GLI has some global state?

Alternatives to GLI would have to

  • Support subcommands
  • Not consume global ARGV
  • Be maintained

Som candidates that satisfy these conditions:

Should fetch default branch from git config

Recently git has stopped hard-coding 'master' as the default branch name and has added a configuration option for this. git-subrepo-ng should support this as well.

Steps to take

  • Look up what the setting is (again, sigh)
  • Use the setting if available, fall back got master otherwise

What does commit history look like?

You mentioned two design goals that really appeal to me, over regular git-subrepo:

  • Keep as much history as reasonably possible, both when pushing and pulling. In particular, do not squash history when pulling subrepo changes back into the main repo
  • Have nicer generated commit messages

Sounds like what you're working on might make people in this issue happy: ingydotnet/git-subrepo#246

Do you have any additional details (or example commit messages) showing what your version is doing (or will do) differently on that end?

My personal goal (as mentioned in my comment on the above link) would be something that looks like a merge commit from an orphaned branch:
image
image

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.