Git Product home page Git Product logo

git-relevant-history's Introduction

git-relevant-history

Extract software component from git repo into a new repo, taking complete relevant history with it.

Background

When software evolves, it is typical for a stable, established software component to be moved out of a git repository to facilitate more comprehensive reuse. One of the pain points of such a move would be losing git history, breaking the possibility of using git blame or git log to understand what led to the current design.

Historically git filter-branch was used for such extracting, and https://github.com/newren/git-filter-repo is a much faster alternative recommended by git now. Both tools work on a static list of path patterns to preserve, so file renames in the past are usually "cut point."

This tool also starts with "what is subcomponent in the current repo to extract?" but then analyzes the history of renames for any existing file. Such a list is used to create a list of patterns for git filter-repo so that effectively the old repo/component becomes standalone repo with a full history of every file, as long as git --follow catches the rename.

So from the extracted component perspective, the only history "lost" is one that would require manual analysis of commits to find file merging/splitting.

Help

Usage documentation for the tool is available via cmdline:

git-relevant-history --help:

Extract enough git history to facilitate git blame and have each line correctly annotated

Wipe all history that has no connection to the current state of the repository.

The resulting repository is a drop-in replacement for the old directory and has all history needed for typical git history use.

Usage:
  git-relevant-history [options] --source=<source_repo> --subdir=<subdir> --target=<target_repo>

Where git repo at <source_repo> would be processed into <target_repo>, in a way that only files starting with
<subdir> would be preserved.


Options:
  --only-specs         Only print git filter-repo specs file as expected by git filter-repo --paths-from-file
  -h --help            show this help message and exit
  -f --force           remove <target_repo> if exists
  -v --verbose         print status messages

Calling when git-relevant-history repo is cloned locally:

./gitrelevanthistory/main.py --source= --subdir= --target=

git-relevant-history's People

Contributors

hterik avatar kwesolowski avatar robakbartlomiej avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

git-relevant-history's Issues

Basic sanity tests should be implemented using github pipelines

Basic integration test like:

  • --help flag
  • filter some small oss project (i.e. fmtlib?)

Should be run for pull requests and post merge to master.

Ideally they should run after checkout && build && local install in clean VENV (to check missing dependencies).
Ideally it should also check with older python version (starting with ubuntu 16.04 default and up)

"pip install git-relevant-history" is not working

I think there are two issues with installing this with pip.

I think you used the old "gitrelevanthistory.py" to create the package but had it pointing to "main.py".

Repro steps

$ python3 -m venv venv               # create a python virtual environment
$ source venv/bin/activate
$ pip3 install git-relevant-history
$ git-relevant-history --help
Traceback (most recent call last):
  File "/usr/local/bin/git-relevant-history", line 5, in <module>
    from gitrelevanthistory import main
ImportError: cannot import name 'main' from 'gitrelevanthistory' (/OBFUSCATED PATH/gitrelevanthistory/__init__.py)
$ mv /OBFUSCATED PATH/gitrelevanthistory/gitrelevanthistory.py /OBFUSCATED PATH/gitrelevanthistory/main.py
$ git-relevant-history --help
Traceback (most recent call last):
  File "/usr/local/bin/git-relevant-history", line 5, in <module>
    from gitrelevanthistory import main
  File "/OBFUSCATED PATH/gitrelevanthistory/main.py", line 33, in <module>
    from docopt import docopt
ModuleNotFoundError: No module named 'docopt' 
$ pip install docopt
$ git-relevant-history --help         # works

Also, is it typical that we need to install docopt ourselves or should it automatically have been installed?

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.