Knotenbindungen an das libgit2 -Projekt.
Stabil ([email protected]): 0.28.3
Besuchen Sie Slack.libgit2.org, um sich anzumelden, und besuchen Sie #NodeGit.
Tyler Ang-Wanek @twwanek mit Hilfe von Tonnen von großartigen Mitwirkenden!
Tim Branyen @Tbranyen, John Haley @Johnhaly81, Max Korp @maxKorp, Steve Smith @Orderedlist, Michael Robinson @CodeoFinterest und Nick Kallen @nk
http://www.nodegit.org/
NodeGit arbeitet ohne native Abhängigkeiten an den meisten Systemen außerhalb des Boxs.
npm install nodegitWenn Sie Fehler zu libstdc ++ erhalten, die bei der Erstellung von Travis-CI häufig auftreten, können Sie dies beheben, indem Sie auf die neuesten LIBSTDC ++-4.9 aktualisieren.
In Ubuntu:
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install libstdc++-4.9-devIn Travis:
addons :
apt :
sources :
- ubuntu-toolchain-r-test
packages :
- libstdc++-4.9-devIn Circleci:
dependencies :
pre :
- sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
- sudo apt-get update
- sudo apt-get install -y libstdc++-4.9-devWenn Sie Fehler zu Lebenszyklenkripten vor dem Vorinstall/Installation erhalten, vermissen Sie wahrscheinlich Libsl-Dev in Ubuntu:
sudo apt-get install libssl-dev
Sie benötigen die folgenden Bibliotheken, die auf Ihrem Linux -Computer installiert sind:
Beim lokalen Bau benötigen Sie auch Entwicklungspakete für Kerberos und PCRE, sodass beide Dienstprogramme auf Ihrer Maschine vorhanden sein müssen:
Wenn Sie während der Installation immer noch auf Probleme stoßen, sollten Sie das Gebäude aus Quellanweisungen ausprobieren.
var Git = require ( "nodegit" ) ;
// Clone a given repository into the `./tmp` folder.
Git . Clone ( "https://github.com/nodegit/nodegit" , "./tmp" )
// Look up this known commit.
. then ( function ( repo ) {
// Use a known commit sha from this repository.
return repo . getCommit ( "59b20b8d5c6ff8d09518454d4dd8b7b30f095ab5" ) ;
} )
// Look up a specific file within that commit.
. then ( function ( commit ) {
return commit . getEntry ( "README.md" ) ;
} )
// Get the blob contents from the file.
. then ( function ( entry ) {
// Patch the blob to contain a reference to the entry.
return entry . getBlob ( ) . then ( function ( blob ) {
blob . entry = entry ;
return blob ;
} ) ;
} )
// Display information about the blob.
. then ( function ( blob ) {
// Show the path, sha, and filesize in bytes.
console . log ( blob . entry . path ( ) + blob . entry . sha ( ) + blob . rawsize ( ) + "b" ) ;
// Show a spacer.
console . log ( Array ( 72 ) . join ( "=" ) + "nn" ) ;
// Show the entire file.
console . log ( String ( blob ) ) ;
} )
. catch ( function ( err ) { console . log ( err ) ; } ) ; var Git = require ( "nodegit" ) ;
// Open the repository directory.
Git . Repository . open ( "tmp" )
// Open the master branch.
. then ( function ( repo ) {
return repo . getMasterCommit ( ) ;
} )
// Display information about commits on master.
. then ( function ( firstCommitOnMaster ) {
// Create a new history event emitter.
var history = firstCommitOnMaster . history ( ) ;
// Create a counter to only show up to 9 entries.
var count = 0 ;
// Listen for commit events from the history.
history . on ( "commit" , function ( commit ) {
// Disregard commits past 9.
if ( ++ count >= 9 ) {
return ;
}
// Show the commit sha.
console . log ( "commit " + commit . sha ( ) ) ;
// Store the author object.
var author = commit . author ( ) ;
// Display author information.
console . log ( "Author:t" + author . name ( ) + " <" + author . email ( ) + ">" ) ;
// Show the commit date.
console . log ( "Date:t" + commit . date ( ) ) ;
// Give some space and show the message.
console . log ( "n " + commit . message ( ) ) ;
} ) ;
// Start emitting events.
history . start ( ) ;
} ) ; Weitere Beispiele überprüfen Sie die examples/ den Ordner.
Sie müssen vor dem Ausführen der Tests lokal erstellen. Siehe oben.
npm test