Repository navigation
Changes since v1.6.0.
1.7 prepares the upgrade to 2.0: it has the API of 2.0 that can be added without breaking 1.x, and deprecates what 2.0 replaces or breaks. Code without deprecations with 1.7 runs with 2.0 too, so a library can require ^1.7 || ^2.0 with a single code path. The exceptions, the changes of 2.0 1.7 can't bring, are listed in the UPGRADE-2.0.md of 2.0.
1.7 breaks nothing of 1.6: the parameters keep their names, the arguments added to the methods of classes that aren't final are read with func_get_arg(), commented out in their signature (@psalm-variadic for Psalm), and gitlib keeps calling the deprecated methods that a subclass overrides. Deprecations are triggered through symfony/deprecation-contracts, a new dependency.
1.7 requires PHP 8.1, for the DiffLineType enum: on PHP 8.0, Composer keeps 1.6.
Features
Gitonomy\Git\Driver\Cli\CliDriverconfigures git: the binary, the environment variables, the timeout and the logger. It takes the arguments of theCliDriverof 2.0.new Repository($dir, $workingDir, $driver): the second argument may be the working directory, the third one is aCliDriver.Repository::init(),initBare(),cloneFrom(),cloneBareFrom(),mirrorFrom(),isValidRepository()andisValidRepositoryAndBranch()take the URL before the path and aCliDriveras last argument. Like in 2.0,isValidRepositoryAndBranch()checks the exact name of the branch, and both read a relative path as a path, never as the name of a remote of the working directory of PHP.Repository::getDiff($from, $to), with two arguments, compares two revisions,Repository::getMergeBase()returns their best common ancestor,WorkingCopy::getDiff()compares the working tree with a revision. Like in 2.0, they throw aReferenceNotFoundExceptionfor an unknown revision, asWorkingCopy::checkoutNewBranch().Diff::parse(),Diff::fromArray()andFile::fromArray()take the repository to read the blobs from, the constructor ofDiff\Filethe changes and the repository.File::isModeChange(),File::isCopy(),FileChange::getAdditions()andFileChange::getDeletions().FileChange::getDiffLines()returns the lines of a hunk asDiff\DiffLineobjects, withgetType(), aDiff\DiffLineType, andgetContent(). The constructor ofFileChangetakesDiffLineobjects.Repository::getBlame()andBlametake the first and the last lines to blame, as integers.Blame::getHunks()returnsBlame\Hunkobjects, numbered like the file;Blame\Line::getNumber()andgetOriginalNumber().Log::withOffset()andwithLimit()return another log.Branch::isMergedInto()andBranch::moveTo().ReferenceBag::createBranch()andcreateTag()take aRevisiontoo.PushReference::getFullname(),getRange(),isCreation()andisDeletion().- Iterating a
Treegives its entries,TreeEntryobjects withgetName(),getMode()andgetObject(), by name;Tree::getBlobs(),getTrees()andgetSubmodules()return those of one type. Submodule, withgetHash(). The submodules of trees are stillCommitReferenceobjects, which extendSubmodule.WorkingCopy::checkoutNewBranch().WorkingCopy::checkout()takes anyRevision.Repository::getSizeInBytes(), which doesn't follow links.
Deprecations
- An array of options as second argument of
Repository, thedebugoption set tofalse,Repository::setLogger()andgetLogger(): use theworkingDiranddriverarguments. AdminandRepository::cloneTo(): use the static methods ofRepository.Repository::getDiff()with one argument andLog::getDiff(): useRepository::getDiff($from, $to)orWorkingCopy::getDiff().Diff::setRepository(),File::setRepository(),File::addChange(),File::isChangeMode(),File::isDelete(),File::getAnchor()andFileChange::getCount().FileChange::getLines(), which returns the lines as arrays, theFileChange::LINE_*constants, and passing the lines to the constructor ofFileChangeas arrays: usegetDiffLines(),DiffLineTypeandDiffLineobjects.- A range of lines as a string in
Repository::getBlame()andBlame,Blame::getGroupedLines()andBlame\Line::getLine(). Log::setOffset(),setLimit(), a negative offset or limit, an option ofgit logbut--allas revision, andcount()of a log whose offset or limit leaves commits out: it counts them all, where 2.0 counts the commits the log iterates. UsecountCommits().ReferenceBag::update(),Branch::isMergedTo(), arguments ofCommit::getIncludingBranches(), creating a branch or a tag that exists already, deleting a reference by another name than its full name underrefs/.- Passing an argument to
Repository::getReferences(), to read the references again: open a newRepository. PushReference::getReference(),getRevision(),isCreate()andisDelete().CommitReference.Tree::getEntries(),getBlobEntries(),getTreeEntries()andgetCommitReferenceEntries(), which return the entries as arrays: iterate the tree, or usegetBlobs(),getTrees()andgetSubmodules().- The second argument of
WorkingCopy::checkout(): usecheckoutNewBranch(). A localBranchobject, whichcheckout()detaches HEAD on, where 2.0 attaches HEAD to the branch: pass its name, or its commit. - Passing a revision name to
Repository::getTree()orgetBlob()instead of a hash, and passing data to the constructor ofCommit, internal in 2.0. Repository::getSize(),Repository::shell(),Commit::getShortMessage(),Commit::getFixedShortHash()andUtil\StringHelper.- The parsers that 2.0 moves to its
CliDriver, all butDiffParserandParserBase. - The classes
finalin 2.0 are@final since gitonomy/gitlib 1.7. The constructors internal in 2.0 (Commit,Tree,Blob,Revision,Reference,ReferenceBag) say so.
Full Changelog: v1.6.0...v1.7.0