Git Product home page Git Product logo

gitcovery's Introduction

Gitcovery

Build Status

A Python module that allows you to explore git repositories. It abstracts over the git system, hiding the command-line arguments behind simple function calls and objects. This makes the module useful when you want to run analyses on git repositories.
As an example of its simplicity, only 6 lines of Python code are needed to create a graph that shows evolution of the number of lines in this README-file over time. This includes the two lines that are always needed to draw any graph at all. Try running python examples/filesizePlot/filesizePlot.py from the root of this repository to check it out, or take a look at the other examples in the exmples folder.

Usage

This module wraps the git repository in the following ways, making it simple to get data from it without parsing the commandline output.

git = Git.set_root('path/to/repo')                                      # Select local dir
git = Git.clone('/tmp', 'https://github.com/ChielBruin/Gitcovery.git')  # Clone and select remote dir
git = Git.checkout('<branch>')
commit = Commit.get_commit('<commitHash>')

# Get the files in the tests folder
folder = git.get_folder('src/tests').children()
folder = git.src.tests.children()               # Functionally equivalent

# Get the author of the latest commit
print(git.history()[0].author)

# Get changes made to a file in the last commit
print(git.get_file('README.md').history()[0].changes(file='README.md'))
print(git.get_file('README.md').history()[0].changes().get_file('README.md'))
print(git.get_file('README.md').changes()[0])

# Compare the length of the full history with the length of that of the 'README.md' file
print(len(git.history()), len(git.get('README.md').history()))

# Get the status of a file
print(folder.get_file('a/file.txt').status())

# Print the name of all the files
git.for_each_file(lambda x: print(x.path))

To get a more in depth understanding of the module, take a look at the following sources:

  • exmples/
    A folder containing examples on how this module can be used. These examples include:
    • A basic example showing a little bit of everything
    • Plotting the file size of README.md over the evolution of a repository
  • REFERENCE.md
    A reference document with all the available classes and their functions and fields

Installation

To install the module simply run pip install . in the root of this repository.
Now, the module can simply be imported with

from gitcovery import Git

To run the tests for the module run: python setup.py test

Future work

  • Improve the implementation for diffs
    It now only records the metadata, making it impossible to reconstruct a file using all the Diffs in his history (except for its size).
  • Add more tests
  • More examples

gitcovery's People

Contributors

chielbruin avatar

Stargazers

 avatar

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.