Skip to main content

module util::git::Git

rascal-0.43.0
edu.appstate.cs.rascal-git-0.1.19

Access functions to git features via JGit

Usage​

import util::git::Git;

This library is a growing collection of functions that enable Rascal programmers to interact with the git version management system.

function cloneRemoteRepository​

git clone

void cloneRemoteRepository(str remotePath, loc localPath)

This has the effect git clone, and it registers this repository with rascal-git for further processing.

function openLocalRepository​

void openLocalRepository(loc localPath)

This registers an existing clone with rascal-git for further processing.

function getTags​

git tag --list

list[str] getTags(loc repoPath)

function switchToTag​

git checkout myTagName

void switchToTag(loc repoPath, str \tag)

function getTagCommitDate​

git log -1 --format=%ai myTagName

datetime getTagCommitDate(loc repoPath, str \tag)

function checkoutByDate​

git checkout git rev-list -n 1 --before="2023-01-01 12:00:00" HEAD``

void checkoutByDate(loc repoPath, datetime refDate)

This will checkout the most recent commit before the given date.

function switchRef​

git checkout myfeaturebranch

void switchRef(loc repoPath, str refName)

function switchCommit​

git checkout commmithash

void switchCommit(loc repoPath, str commitHash)

function getCommitDate​

git show -s --format=%cI commithash

datetime getCommitDate(loc repoPath, str commitHash)

function getCommitLog​

git log [--reverse] --format="%H,%ct"

list[tuple[str hash, datetime date]] getCommitLog(loc repoPath, bool reverse)

This will return a list of tuples of the commit hash and the commit date.