FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
nodegit.nodegit/guides/cloning/index.js at enable-stash · javascript-forks/nodegit.nodegit · GitHub
javascript-forks
nodegit.nodegit
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
nodegit.nodegit
/
guides
/
cloning
/
index.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
38 lines (31 loc) · 1.42 KB
Breadcrumbs
nodegit.nodegit
/
guides
/
cloning
/
index.js
Copy path
File metadata and controls
38 lines (31 loc) · 1.42 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Require in NodeGit, since we want to use the local copy, we're using a
// relative path. In your project, you will use:
//
// var NodeGit = require("nodegit");
var
NodeGit
=
require
(
"../../../"
)
;
// Using the `clone` method from the `Git.Clone` module, bring down the NodeGit
// test repository from GitHub.
var
cloneURL
=
"https://github.com/nodegit/test"
;
// Ensure that the `tmp` directory is local to this file and not the CWD.
var
localPath
=
require
(
"path"
)
.
join
(
__dirname
,
"tmp"
)
;
// Simple object to store clone options.
var
cloneOptions
=
{
}
;
// This is a required callback for OS X machines. There is a known issue
// with libgit2 being able to verify certificates from GitHub.
cloneOptions
.
remoteCallbacks
=
{
certificateCheck
:
function
(
)
{
return
1
;
}
}
;
// Invoke the clone operation and store the returned Promise.
var
cloneRepository
=
NodeGit
.
Clone
(
cloneURL
,
localPath
,
cloneOptions
)
;
// If the repository already exists, the clone above will fail. You can simply
// open the repository in this case to continue execution.
var
errorAndAttemptOpen
=
function
(
)
{
return
NodeGit
.
Repository
.
open
(
localPath
)
;
}
;
// Once the repository has been cloned or opened, you can work with a returned
// `Git.Repository` instance.
cloneRepository
.
catch
(
errorAndAttemptOpen
)
.
then
(
function
(
repository
)
{
// Access any repository methods here.
console
.
log
(
"Is the repository bare? %s"
,
Boolean
(
repository
.
isBare
(
)
)
)
;
}
)
;
Back
|
FazBrowse Home
|
New Git URL