Skip to content

A git wrapper for flutter/dart to facilitate the execution of common and useful git commands.

License

Notifications You must be signed in to change notification settings

gbrandtio/rw-git

Repository files navigation

License: MIT

About

rw_git is a git wrapper that facilitates the out-of-the-box execution of common git operations.

Documentation

Features

rw_git offers a variety of features which are separated into relevant classes. To use this library you can either refer directly to the class which implements the implementation needed, or refer to an instance of it through the RwGit class.

GitCommon

  • init: Initialize a local GIT directory. If the local directory does not exist, it will be created.
  • clone: Clone a remote repository into a local folder. If the local directory does not exist, it will be created.
  • checkout: Checkout a GIT branch on the specified, existing directory.
  • fetchTags: Retrieve a list of tags of the specified repository.
  • getCommitsBetween: Retrieve a list of commits between two given tags.

GitStats

  • stats: Get the number of lines inserted, deleted and number of files changed.
  • contibutionsByAuthor: Returns the number of contributions for every author of the repository.

Getting started

pubspec.yaml: rw_git: 1.0.3

Usage

Import library:

import 'package:rw_git/rw_git.dart';

Initialize RwGit:

RwGit rwGit = RwGit();

Clone a remote repository:

String localDirectoryToCloneInto = _createCheckoutDirectory(localDirectoryName);
rwGit.gitCommon.clone(localDirectoryToCloneInto, repositoryToClone);

Fetch tags of a remote repository:

List<String> tags = await rwGit.gitCommon.fetchTags(localDirectoryToCloneInto);
print("Number of tags: ${tags.length}");

Retrieve the commits between two tags:

  List<String> listOfCommitsBetweenTwoTags = await rwGit.gitCommon.getCommitsBetween(localDirectoryToCloneInto, oldTag, newTag);
  print("Number of commits between $oldTag and $newTag: ${listOfCommitsBetweenTwoTags.length}");

Retrieve code-change statistics between two tags:

  ShortStatDto shortStatDto = await rwGit.gitStats.stats(localDirectoryToCloneInto, oldTag, newTag);
  print('Number of lines inserted: ${shortStatDto.insertions}'
      ' Number of lines deleted: ${shortStatDto.deletions}'
      ' Number of files changed: ${shortStatDto.numberOfChangedFiles}');

Additional information

Please file any issues on the github issue tracker.

About

A git wrapper for flutter/dart to facilitate the execution of common and useful git commands.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages