0.0
No commit activity in last 3 years
No release in over 3 years
Duplicating git repositories without forking.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

~> 1.2
~> 0.6
 Project Readme

Git Duplicator

Gem Version Build Status Coverage Status Dependency Status Code Climate

Duplicating git repositories without forking. It depends on the flow described in this article.

  • Duplicate any repository in two ways: one time usage and frequent updates.
  • Additional Github support to create and delete repositories.
  • Additional Bibucket support to create and delete repositories.

Installation

Add this line to your application's Gemfile:

gem 'git_duplicator'

And then execute:

$ bundle

Or install it yourself as:

$ gem install git_duplicator

Usage

Duplicate with no future updates

Duplicate a repository. Then you can turn off the source repo and move to the mirrored one.

Basic usage

It assumes that you have the destination repository initiated.

require 'git_duplicator'

from = GitDuplicator::Repository.new('source repo name', 'source repo url')

to = GitDuplicator::Repository.new('mirrored repo name', 'mirrored repo url')

GitDuplicator.perform(from, to)

Advanced usage

  • You can create the destination repository automatically. This needs you to provide the needed authentication credentials for the script.
  • You can set the clone working path locally for the script to work. It's a temporary workplace that will get swiped after finishing.
require 'git_duplicator'

from = GitDuplicator::Repository.new('source repo name', 'source repo url')

to = GitDuplicator::Services::GithubRepository.new(
  'mirrored repo name', 'mirrored owner',
  credentials: { oauth2_token: 'some token' },
  remote_options: { has_issues: false, has_wiki: false }
)

GitDuplicator.perform(
  from, to,
  force_create_destination: true,
  clone_path: 'path/to/clone/folder'
)

Duplicate with future updates

Duplicate a repository. To update your mirror, fetch updates and push, which could be automated by running a cron job.

Basic usage

It assumes that you have the destination repository initiated.

require 'git_duplicator'

from = GitDuplicator::Repository.new('source repo name', 'source repo url')

to = GitDuplicator::Repository.new('mirrored repo name', 'mirrored repo url')

GitDuplicator.perform_for_update(from, to)

# Later on if you want to update the mirrored one
local_repo = GitDuplicator::Repository.new(
  'source repo name',
  'source repo url',
  'path/to/working/directory'
)

local_repo.update_mirrored

Advanced usage

  • You can create the destination repository automatically. This needs you to provide the needed authentication credentials for the script.
  • You can set the clone working path locally for the script to work. It's a temporary workplace that will get swiped after finishing.
require 'git_duplicator'

from = GitDuplicator::Repository.new('source repo name', 'source repo url')

to = GitDuplicator::Services::GithubRepository.new(
  'mirrored repo name',
  'mirrored owner',
  credentials: { oauth2_token: 'some token' },
  remote_options: { has_issues: false, has_wiki: false }
)

GitDuplicator.perform_for_update(
  from, to,
  force_create_destination: true,
  clone_path: 'path/to/clone/folder'
)

# Later on if you want to update the mirrored one
local_repo = GitDuplicator::Repository.new(
  'source repo name',
  'source repo url',
  'path/to/working/directory'
)

local_repo.update_mirrored

Available Services

The script works with any repository that you have access to. However, right now, there are 2 services that are implemented to help you initiate an empty destination repository. That way, you don't need to create them manaullay before doing the duplicaton. The services are Github and Bitbucket.

Adding new Services

Adding new service, if needed, should be straight forward. You can look at the source of the Bitbucket or Github services implementations, where they inherit a base abstract class that you need to inherit as well.

Running tests

To be able to run the tests, specially the acceptance ones, you need to rename the .test.env.example to .test.env and add the needed credentials for your accounts.

Contributing

  1. Fork it ( https://github.com/Startappz/git_duplicator/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request