@swimlane/nodegit 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.dockerignore +2 -0
- package/.github/workflows/publish.yml +126 -0
- package/.github/workflows/tests.yml +85 -0
- package/LICENSE +19 -0
- package/README.md +193 -0
- package/lib/attr.js +20 -0
- package/lib/blob.js +51 -0
- package/lib/branch.js +19 -0
- package/lib/buf.js +43 -0
- package/lib/commit.js +437 -0
- package/lib/config.js +48 -0
- package/lib/convenient_hunks.js +61 -0
- package/lib/convenient_patch.js +131 -0
- package/lib/credential.js +33 -0
- package/lib/deprecated/structs/ApplyOptions.js +3 -0
- package/lib/deprecated/structs/BlameOptions.js +6 -0
- package/lib/deprecated/structs/BlobFilterOptions.js +3 -0
- package/lib/deprecated/structs/CheckoutOptions.js +8 -0
- package/lib/deprecated/structs/CherrypickOptions.js +5 -0
- package/lib/deprecated/structs/CloneOptions.js +6 -0
- package/lib/deprecated/structs/DescribeFormatOptions.js +4 -0
- package/lib/deprecated/structs/DescribeOptions.js +6 -0
- package/lib/deprecated/structs/DiffFindOptions.js +8 -0
- package/lib/deprecated/structs/DiffOptions.js +8 -0
- package/lib/deprecated/structs/FetchOptions.js +7 -0
- package/lib/deprecated/structs/MergeFileInput.js +4 -0
- package/lib/deprecated/structs/MergeFileOptions.js +5 -0
- package/lib/deprecated/structs/MergeOptions.js +8 -0
- package/lib/deprecated/structs/ProxyOptions.js +3 -0
- package/lib/deprecated/structs/PushOptions.js +5 -0
- package/lib/deprecated/structs/RebaseOptions.js +6 -0
- package/lib/deprecated/structs/RemoteCreateOptions.js +3 -0
- package/lib/deprecated/structs/RepositoryInitOptions.js +4 -0
- package/lib/deprecated/structs/RevertOptions.js +5 -0
- package/lib/deprecated/structs/StashApplyOptions.js +4 -0
- package/lib/deprecated/structs/StatusOptions.js +4 -0
- package/lib/deprecated/structs/SubmoduleUpdateOptions.js +5 -0
- package/lib/diff.js +67 -0
- package/lib/diff_file.js +38 -0
- package/lib/diff_line.js +32 -0
- package/lib/error.js +17 -0
- package/lib/filter_registry.js +22 -0
- package/lib/graph.js +15 -0
- package/lib/index.js +103 -0
- package/lib/merge.js +41 -0
- package/lib/note.js +17 -0
- package/lib/object.js +45 -0
- package/lib/odb_object.js +9 -0
- package/lib/oid.js +23 -0
- package/lib/rebase.js +86 -0
- package/lib/reference.js +213 -0
- package/lib/remote.js +45 -0
- package/lib/repository.js +1973 -0
- package/lib/reset.js +51 -0
- package/lib/revparse.js +18 -0
- package/lib/revwalk.js +142 -0
- package/lib/signature.js +38 -0
- package/lib/stash.js +16 -0
- package/lib/status.js +16 -0
- package/lib/status_file.js +106 -0
- package/lib/submodule.js +10 -0
- package/lib/tag.js +141 -0
- package/lib/tree.js +175 -0
- package/lib/tree_entry.js +99 -0
- package/lib/utils/lookup_wrapper.js +39 -0
- package/lib/utils/shallow_clone.js +14 -0
- package/lifecycleScripts/clean.js +5 -0
- package/lifecycleScripts/install.js +32 -0
- package/lifecycleScripts/postinstall.js +83 -0
- package/lifecycleScripts/preinstall.js +47 -0
- package/lifecycleScripts/submodules/getStatus.js +50 -0
- package/lifecycleScripts/submodules/index.js +84 -0
- package/package.json +83 -0
- package/prebuilds/darwin-arm64/@swimlane+nodegit.glibc.node +0 -0
- package/prebuilds/darwin-x64/@swimlane+nodegit.glibc.node +0 -0
- package/prebuilds/linux-arm64/@swimlane+nodegit.glibc.node +0 -0
- package/prebuilds/linux-x64/@swimlane+nodegit.glibc.node +0 -0
- package/prebuilds/linux-x64/@swimlane+nodegit.musl.node +0 -0
- package/scripts/Dockerfile.alpine +10 -0
- package/scripts/Dockerfile.debian +15 -0
- package/utils/acquireOpenSSL.js +436 -0
- package/utils/build-openssl.bat +13 -0
- package/utils/buildFlags.js +19 -0
- package/utils/configureLibssh2.js +54 -0
- package/utils/defaultCxxStandard.js +18 -0
- package/utils/execPromise.js +24 -0
- package/utils/getElectronOpenSSLRoot.js +10 -0
- package/utils/gitExecutableLocation.js +23 -0
- package/utils/isBuildingForElectron.js +30 -0
- package/utils/retry.js +51 -0
package/.dockerignore
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
on:
|
|
2
|
+
push:
|
|
3
|
+
tags:
|
|
4
|
+
- v*
|
|
5
|
+
workflow_dispatch:
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
build:
|
|
9
|
+
# TODO: should we run the tests, or can we assume that a v* tag ought to
|
|
10
|
+
# get published?
|
|
11
|
+
name: build
|
|
12
|
+
strategy:
|
|
13
|
+
matrix:
|
|
14
|
+
node: [18.17.0]
|
|
15
|
+
os:
|
|
16
|
+
# macos-14 is arm64 (m1)
|
|
17
|
+
- name: darwin
|
|
18
|
+
host: macos-14
|
|
19
|
+
|
|
20
|
+
# macos-13 is x86
|
|
21
|
+
- name: mac-x64
|
|
22
|
+
host: macos-13
|
|
23
|
+
|
|
24
|
+
# ubuntu-20.04 is x86. Still no arm linux runners yet
|
|
25
|
+
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-public-repositories
|
|
26
|
+
- name: linux
|
|
27
|
+
host: ubuntu-20.04
|
|
28
|
+
env:
|
|
29
|
+
CC: clang
|
|
30
|
+
CXX: clang++
|
|
31
|
+
npm_config_clang: 1
|
|
32
|
+
GYP_DEFINES: use_obsolete_asm=true
|
|
33
|
+
runs-on: ${{ matrix.os.host }}
|
|
34
|
+
steps:
|
|
35
|
+
- uses: actions/checkout@v4
|
|
36
|
+
with:
|
|
37
|
+
submodules: true
|
|
38
|
+
- uses: actions/setup-node@v4
|
|
39
|
+
with:
|
|
40
|
+
node-version: 20
|
|
41
|
+
check-latest: true
|
|
42
|
+
- name: Prebuildify
|
|
43
|
+
run: |
|
|
44
|
+
[[ $(uname -o) == *Linux ]] && \
|
|
45
|
+
sudo apt-get update && \
|
|
46
|
+
sudo apt-get install -y software-properties-common git build-essential clang libssl-dev libkrb5-dev libc++-dev wget python3
|
|
47
|
+
npm ci --ignore-scripts
|
|
48
|
+
npm run preinstall
|
|
49
|
+
npx prebuildify --napi --strip --tag-libc -t "$(node --version | tr -d 'v')"
|
|
50
|
+
- uses: actions/upload-artifact@v4
|
|
51
|
+
with:
|
|
52
|
+
name: prebuild-${{ runner.os }}-${{ runner.arch }}
|
|
53
|
+
path: ./prebuilds
|
|
54
|
+
retention-days: 14
|
|
55
|
+
|
|
56
|
+
cross-compile:
|
|
57
|
+
name: "cross compile linux/arm"
|
|
58
|
+
runs-on: ubuntu-20.04
|
|
59
|
+
steps:
|
|
60
|
+
- uses: actions/checkout@v4
|
|
61
|
+
- uses: docker/setup-qemu-action@v3
|
|
62
|
+
- name: build linux glibc arm
|
|
63
|
+
run: |
|
|
64
|
+
docker build --platform=linux/arm64 --tag nodegit-linux-glibc-arm64 -f scripts/Dockerfile.debian .
|
|
65
|
+
docker create --platform=linux/arm64 --name nodegit-linux-glibc-arm64 nodegit-linux-glibc-arm64
|
|
66
|
+
docker cp "nodegit-linux-glibc-arm64:/app/prebuilds" .
|
|
67
|
+
- name: build linux musl x64
|
|
68
|
+
run: |
|
|
69
|
+
docker build --platform=linux/amd64 --tag nodegit-linux-musl-amd64 -f scripts/Dockerfile.alpine .
|
|
70
|
+
docker create --platform=linux/amd64 --name nodegit-linux-musl-amd64 nodegit-linux-musl-amd64
|
|
71
|
+
docker cp "nodegit-linux-musl-amd64:/app/prebuilds" .
|
|
72
|
+
# - name: build linux musl arm
|
|
73
|
+
# run: |
|
|
74
|
+
# docker build --platform=linux/arm64 --tag nodegit-linux-musl-arm64 -f scripts/Dockerfile.alpine .
|
|
75
|
+
# docker create --platform=linux/arm64 --name nodegit-linux-musl-arm64 nodegit-linux-musl-arm64
|
|
76
|
+
# docker cp "nodegit-linux-musl-arm64:/app/prebuilds" .
|
|
77
|
+
- name: "list the generated files"
|
|
78
|
+
run: find prebuilds
|
|
79
|
+
- uses: actions/upload-artifact@v4
|
|
80
|
+
with:
|
|
81
|
+
name: prebuild-linux-arm64
|
|
82
|
+
path: ./prebuilds
|
|
83
|
+
retention-days: 14
|
|
84
|
+
|
|
85
|
+
# https://docs.npmjs.com/generating-provenance-statements#publishing-packages-with-provenance-via-github-actions
|
|
86
|
+
publish:
|
|
87
|
+
runs-on: ubuntu-latest
|
|
88
|
+
needs: [build, cross-compile]
|
|
89
|
+
permissions:
|
|
90
|
+
id-token: write
|
|
91
|
+
steps:
|
|
92
|
+
- uses: actions/checkout@v4
|
|
93
|
+
with:
|
|
94
|
+
submodules: true
|
|
95
|
+
- uses: actions/setup-node@v4
|
|
96
|
+
with:
|
|
97
|
+
node-version: 20
|
|
98
|
+
check-latest: true
|
|
99
|
+
registry-url: "https://registry.npmjs.org"
|
|
100
|
+
scope: "swimlane"
|
|
101
|
+
- name: download built libraries
|
|
102
|
+
id: download
|
|
103
|
+
uses: actions/download-artifact@v4
|
|
104
|
+
with:
|
|
105
|
+
path: prebuilds
|
|
106
|
+
- name: copy libs
|
|
107
|
+
run: |
|
|
108
|
+
set -x
|
|
109
|
+
mkdir -p prebuilds/linux-arm64
|
|
110
|
+
mkdir -p prebuilds/linux-x64
|
|
111
|
+
mkdir -p prebuilds/darwin-arm64
|
|
112
|
+
mkdir -p prebuilds/darwin-x64
|
|
113
|
+
find ${{ steps.download.outputs.download-path }}
|
|
114
|
+
mv ${{ steps.download.outputs.download-path}}/prebuild-Linux-X64/linux-x64/* ./prebuilds/linux-x64/
|
|
115
|
+
mv ${{ steps.download.outputs.download-path}}/prebuild-linux-arm64/linux-arm64/* ./prebuilds/linux-arm64/
|
|
116
|
+
mv ${{ steps.download.outputs.download-path}}/prebuild-linux-arm64/linux-x64/* ./prebuilds/linux-x64/
|
|
117
|
+
mv ${{ steps.download.outputs.download-path}}/prebuild-macOS-ARM64/darwin-arm64/* ./prebuilds/darwin-arm64/
|
|
118
|
+
mv ${{ steps.download.outputs.download-path}}/prebuild-macOS-X64/darwin-x64/* ./prebuilds/darwin-x64/
|
|
119
|
+
find ./prebuilds
|
|
120
|
+
- name: npm install
|
|
121
|
+
run: npm ci --ignore-scripts
|
|
122
|
+
- name: publish
|
|
123
|
+
run: |
|
|
124
|
+
(cat "$NPM_CONFIG_USERCONFIG" || true) && npm publish --provenance --access public
|
|
125
|
+
env:
|
|
126
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
on:
|
|
2
|
+
push:
|
|
3
|
+
branches:
|
|
4
|
+
- master
|
|
5
|
+
- backport/*
|
|
6
|
+
tags:
|
|
7
|
+
- v*.*.*
|
|
8
|
+
pull_request:
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
linux-test:
|
|
12
|
+
name: "test on linux"
|
|
13
|
+
env:
|
|
14
|
+
CC: clang
|
|
15
|
+
CXX: clang++
|
|
16
|
+
npm_config_clang: 1
|
|
17
|
+
GYP_DEFINES: use_obsolete_asm=true
|
|
18
|
+
DEBIAN_FRONTEND: "noninteractive"
|
|
19
|
+
runs-on: ubuntu-20.04
|
|
20
|
+
container: ubuntu:20.04
|
|
21
|
+
steps:
|
|
22
|
+
- name: prerequisites
|
|
23
|
+
run: |
|
|
24
|
+
apt-get update
|
|
25
|
+
apt-get install -y software-properties-common git build-essential clang libssl-dev libkrb5-dev libc++-dev wget python3
|
|
26
|
+
- uses: actions/checkout@v4
|
|
27
|
+
with:
|
|
28
|
+
submodules: true
|
|
29
|
+
- uses: actions/setup-node@v4
|
|
30
|
+
with:
|
|
31
|
+
node-version: 20
|
|
32
|
+
check-latest: true
|
|
33
|
+
- name: Test
|
|
34
|
+
run: |
|
|
35
|
+
set -xe
|
|
36
|
+
mkdir ~/.ssh_tests
|
|
37
|
+
chmod 700 ~/.ssh_tests
|
|
38
|
+
printf "%b" "Host *\n\tStrictHostKeyChecking no\n" > ~/.ssh_tests/config
|
|
39
|
+
printf "%b" "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDBkHMoNRRkHYNE7En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global user.name "John Doe"
|
|
44
|
+
git config --global user.email johndoe@example.com
|
|
45
|
+
|
|
46
|
+
eval "$(ssh-agent -s)"
|
|
47
|
+
ssh-add ~/.ssh_tests/id_rsa
|
|
48
|
+
|
|
49
|
+
npm install
|
|
50
|
+
npm test
|
|
51
|
+
|
|
52
|
+
mac-test:
|
|
53
|
+
name: "macOS tests"
|
|
54
|
+
env:
|
|
55
|
+
CC: clang
|
|
56
|
+
CXX: clang++
|
|
57
|
+
npm_config_clang: 1
|
|
58
|
+
GYP_DEFINES: use_obsolete_asm=true
|
|
59
|
+
runs-on: macos-13
|
|
60
|
+
steps:
|
|
61
|
+
- uses: actions/checkout@v4
|
|
62
|
+
with:
|
|
63
|
+
submodules: true
|
|
64
|
+
- uses: actions/setup-node@v4
|
|
65
|
+
with:
|
|
66
|
+
node-version: 20
|
|
67
|
+
check-latest: true
|
|
68
|
+
- name: Test
|
|
69
|
+
run: |
|
|
70
|
+
set -xe
|
|
71
|
+
mkdir ~/.ssh_tests
|
|
72
|
+
chmod 700 ~/.ssh_tests
|
|
73
|
+
printf "%b" "Host *\n\tStrictHostKeyChecking no\n" > ~/.ssh_tests/config
|
|
74
|
+
printf "%b" "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDBkHMoNRRkHYNE7EnQLdFxMgVcqGgNPYDhrWiLMlYuzpmEcUnhwW3zNaIa4J2JlGkRNgYZVia1Ic1V3koJPE3YO2+exAfJBIPeb6O1qDADc2hFFHzd28wmHKUkO61yzo2ZjDQfaEVtjN39Yiy19AbddN3bzNrgvuQT574fa6Rghl2RfecKYO77iHA1RGXIFc8heXVIUuUV/jHjb56WqoHH8vyt1DqUz89oyiHq8Cku0qzKN80COheZPseA1EvT0zlIgbXBxwijN4xRmvInK0fB5Kc9r3kddH2tT7V09bOFJsvGQaQmQ1WFTCqjpBFw1CHKcbfPLOxbLpVIR9gyx03R\n" > ~/.ssh_tests/id_rsa.pub
|
|
75
|
+
printf "%b" "-----BEGIN RSA PR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5rrSMprXsuRv2O4c5u8qtJ5ByaOJBjOr0CgYBMlkAxzkpUssS5CaaZDiLv\nLbfEr3HRLjYdc5KpzLBQ8NpJzhmfiIJsK1Wf8B0qb2J1XJg2Oy0KwFOgPbWIoryY\nSg19Pq98Cdn1UWCOrSabr8ZIaKe55WTgGcc8/O3k6BsNfaO9PJZfSssNUlCCtml1\n18u+uo9RJPhPDBd7Gj7r8QKBgFraxWy7t24xkZMDgK4fiM/3tQhFvhz/CY2wPbxG\n5Ae8UfkmLcOCUfTIReqfd9fAnsAFZNIKa5izHRu/wsh9NwYIJSlvm8PsEVtTrPRy\nfgvWet+i24/2eYZGsag8b19gaLCNKQzXDT1czYg8RNVsRSX427BoLzXeXNkW9uNu\nFbI9AoGAV2kxcdcKS4BtNHKPeGgV87dM0DWhQaAtEXEIcQquFtba0lAXioGHg8U4\nzeiugl4Qzchwk5qd3wnZ4SOhx0s16/5gQDlnkbjFR6EREUnvLRwV92zBXUTOGIkh\nZ7Z4rcgUKlVAaHT3OHN/lTyqJG/ib+K4wZhbztl/ox+JUFsvD98=\n-----END RSA PRIVATE KEY-----\n" > ~/.ssh_tests/id_rsa
|
|
76
|
+
ls ~/.ssh_tests
|
|
77
|
+
chmod 600 ~/.ssh_tests/id_rsa*
|
|
78
|
+
git config --global user.name "John Doe"
|
|
79
|
+
git config --global user.email johndoe@example.com
|
|
80
|
+
|
|
81
|
+
eval "$(ssh-agent -s)"
|
|
82
|
+
ssh-add ~/.ssh_tests/id_rsa
|
|
83
|
+
|
|
84
|
+
npm install
|
|
85
|
+
npm test
|
package/LICENSE
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (c) 2014 Tim Branyen
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
4
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
5
|
+
the Software without restriction, including without limitation the rights to
|
|
6
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
7
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
|
8
|
+
so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
# NodeGit
|
|
2
|
+
|
|
3
|
+
> Node bindings to the [libgit2](http://libgit2.github.com/) project.
|
|
4
|
+
|
|
5
|
+
[](https://github.com/nodegit/nodegit/actions)
|
|
6
|
+
|
|
7
|
+
**Stable (libgit2@v0.28.3): 0.28.3**
|
|
8
|
+
|
|
9
|
+
## Have a problem? Come chat with us!
|
|
10
|
+
|
|
11
|
+
Visit [slack.libgit2.org](http://slack.libgit2.org/) to sign up, then join us in #nodegit.
|
|
12
|
+
|
|
13
|
+
## Maintained by
|
|
14
|
+
|
|
15
|
+
Readme
|
|
16
|
+
|
|
17
|
+
### Alumni Maintainers
|
|
18
|
+
|
|
19
|
+
Tim Branyen [@tbranyen](http://twitter.com/tbranyen),
|
|
20
|
+
John Haley [@johnhaley81](http://twitter.com/johnhaley81),
|
|
21
|
+
Max Korp [@maxkorp](http://twitter.com/MaximilianoKorp),
|
|
22
|
+
Steve Smith [@orderedlist](https://twitter.com/orderedlist),
|
|
23
|
+
Michael Robinson [@codeofinterest](http://twitter.com/codeofinterest), and
|
|
24
|
+
Nick Kallen [@nk](http://twitter.com/nk)
|
|
25
|
+
|
|
26
|
+
## API Documentation.
|
|
27
|
+
|
|
28
|
+
[http://www.nodegit.org/](http://www.nodegit.org/)
|
|
29
|
+
|
|
30
|
+
## Getting started.
|
|
31
|
+
|
|
32
|
+
NodeGit will work on most systems out-of-the-box without any native
|
|
33
|
+
dependencies.
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
npm install nodegit
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
If you receive errors about libstdc++, which are commonly experienced when
|
|
40
|
+
building on Travis-CI, you can fix this by upgrading to the latest
|
|
41
|
+
libstdc++-4.9.
|
|
42
|
+
|
|
43
|
+
In Ubuntu:
|
|
44
|
+
|
|
45
|
+
```sh
|
|
46
|
+
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
|
|
47
|
+
sudo apt-get update
|
|
48
|
+
sudo apt-get install libstdc++-4.9-dev
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
In Travis:
|
|
52
|
+
|
|
53
|
+
```yaml
|
|
54
|
+
addons:
|
|
55
|
+
apt:
|
|
56
|
+
sources:
|
|
57
|
+
- ubuntu-toolchain-r-test
|
|
58
|
+
packages:
|
|
59
|
+
- libstdc++-4.9-dev
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
In CircleCI:
|
|
63
|
+
|
|
64
|
+
```yaml
|
|
65
|
+
dependencies:
|
|
66
|
+
pre:
|
|
67
|
+
- sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
|
|
68
|
+
- sudo apt-get update
|
|
69
|
+
- sudo apt-get install -y libstdc++-4.9-dev
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
If you receive errors about _lifecycleScripts_ preinstall/install you probably miss _libssl-dev_
|
|
73
|
+
In Ubuntu:
|
|
74
|
+
|
|
75
|
+
```
|
|
76
|
+
sudo apt-get install libssl-dev
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
You will need the following libraries installed on your linux machine:
|
|
80
|
+
|
|
81
|
+
- libpcre
|
|
82
|
+
- libpcreposix
|
|
83
|
+
- libkrb5
|
|
84
|
+
- libk5crypto
|
|
85
|
+
- libcom_err
|
|
86
|
+
|
|
87
|
+
When building locally, you will also need development packages for kerberos and pcre, so both of these utilities must be present on your machine:
|
|
88
|
+
|
|
89
|
+
- pcre-config
|
|
90
|
+
- krb5-config
|
|
91
|
+
|
|
92
|
+
If you are still encountering problems while installing, you should try the
|
|
93
|
+
[Building from source](http://www.nodegit.org/guides/install/from-source/)
|
|
94
|
+
instructions.
|
|
95
|
+
|
|
96
|
+
## API examples.
|
|
97
|
+
|
|
98
|
+
### Cloning a repository and reading a file:
|
|
99
|
+
|
|
100
|
+
```javascript
|
|
101
|
+
var Git = require("nodegit");
|
|
102
|
+
|
|
103
|
+
// Clone a given repository into the `./tmp` folder.
|
|
104
|
+
Git.Clone("https://github.com/nodegit/nodegit", "./tmp")
|
|
105
|
+
// Look up this known commit.
|
|
106
|
+
.then(function (repo) {
|
|
107
|
+
// Use a known commit sha from this repository.
|
|
108
|
+
return repo.getCommit("59b20b8d5c6ff8d09518454d4dd8b7b30f095ab5");
|
|
109
|
+
})
|
|
110
|
+
// Look up a specific file within that commit.
|
|
111
|
+
.then(function (commit) {
|
|
112
|
+
return commit.getEntry("README.md");
|
|
113
|
+
})
|
|
114
|
+
// Get the blob contents from the file.
|
|
115
|
+
.then(function (entry) {
|
|
116
|
+
// Patch the blob to contain a reference to the entry.
|
|
117
|
+
return entry.getBlob().then(function (blob) {
|
|
118
|
+
blob.entry = entry;
|
|
119
|
+
return blob;
|
|
120
|
+
});
|
|
121
|
+
})
|
|
122
|
+
// Display information about the blob.
|
|
123
|
+
.then(function (blob) {
|
|
124
|
+
// Show the path, sha, and filesize in bytes.
|
|
125
|
+
console.log(blob.entry.path() + blob.entry.sha() + blob.rawsize() + "b");
|
|
126
|
+
|
|
127
|
+
// Show a spacer.
|
|
128
|
+
console.log(Array(72).join("=") + "\n\n");
|
|
129
|
+
|
|
130
|
+
// Show the entire file.
|
|
131
|
+
console.log(String(blob));
|
|
132
|
+
})
|
|
133
|
+
.catch(function (err) {
|
|
134
|
+
console.log(err);
|
|
135
|
+
});
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### Emulating git log:
|
|
139
|
+
|
|
140
|
+
```javascript
|
|
141
|
+
var Git = require("nodegit");
|
|
142
|
+
|
|
143
|
+
// Open the repository directory.
|
|
144
|
+
Git.Repository.open("tmp")
|
|
145
|
+
// Open the master branch.
|
|
146
|
+
.then(function (repo) {
|
|
147
|
+
return repo.getMasterCommit();
|
|
148
|
+
})
|
|
149
|
+
// Display information about commits on master.
|
|
150
|
+
.then(function (firstCommitOnMaster) {
|
|
151
|
+
// Create a new history event emitter.
|
|
152
|
+
var history = firstCommitOnMaster.history();
|
|
153
|
+
|
|
154
|
+
// Create a counter to only show up to 9 entries.
|
|
155
|
+
var count = 0;
|
|
156
|
+
|
|
157
|
+
// Listen for commit events from the history.
|
|
158
|
+
history.on("commit", function (commit) {
|
|
159
|
+
// Disregard commits past 9.
|
|
160
|
+
if (++count >= 9) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// Show the commit sha.
|
|
165
|
+
console.log("commit " + commit.sha());
|
|
166
|
+
|
|
167
|
+
// Store the author object.
|
|
168
|
+
var author = commit.author();
|
|
169
|
+
|
|
170
|
+
// Display author information.
|
|
171
|
+
console.log("Author:\t" + author.name() + " <" + author.email() + ">");
|
|
172
|
+
|
|
173
|
+
// Show the commit date.
|
|
174
|
+
console.log("Date:\t" + commit.date());
|
|
175
|
+
|
|
176
|
+
// Give some space and show the message.
|
|
177
|
+
console.log("\n " + commit.message());
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
// Start emitting events.
|
|
181
|
+
history.start();
|
|
182
|
+
});
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
For more examples, check the `examples/` folder.
|
|
186
|
+
|
|
187
|
+
## Unit tests.
|
|
188
|
+
|
|
189
|
+
You will need to build locally before running the tests. See above.
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
npm test
|
|
193
|
+
```
|
package/lib/attr.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
var util = require("util");
|
|
2
|
+
var NodeGit = require("../");
|
|
3
|
+
|
|
4
|
+
NodeGit.Attr.STATES = {};
|
|
5
|
+
var DEPRECATED_STATES = {
|
|
6
|
+
UNSPECIFIED_T: "UNSPECIFIED",
|
|
7
|
+
TRUE_T: "TRUE",
|
|
8
|
+
FALSE_T: "FALSE",
|
|
9
|
+
VALUE_T: "STRING"
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
Object.keys(DEPRECATED_STATES).forEach((key) => {
|
|
13
|
+
const newKey = DEPRECATED_STATES[key];
|
|
14
|
+
Object.defineProperty(NodeGit.Attr.STATES, key, {
|
|
15
|
+
get: util.deprecate(
|
|
16
|
+
() => NodeGit.Attr.VALUE[newKey],
|
|
17
|
+
`Use NodeGit.Attr.VALUE.${newKey} instead of NodeGit.Attr.STATES.${key}.`
|
|
18
|
+
)
|
|
19
|
+
});
|
|
20
|
+
});
|
package/lib/blob.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
var util = require("util");
|
|
2
|
+
var NodeGit = require("../");
|
|
3
|
+
var Blob = NodeGit.Blob;
|
|
4
|
+
var LookupWrapper = NodeGit.Utils.lookupWrapper;
|
|
5
|
+
var TreeEntry = NodeGit.TreeEntry;
|
|
6
|
+
|
|
7
|
+
var _filteredContent = Blob.filteredContent;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Retrieves the blob pointed to by the oid
|
|
11
|
+
* @async
|
|
12
|
+
* @param {Repository} repo The repo that the blob lives in
|
|
13
|
+
* @param {String|Oid|Blob} id The blob to lookup
|
|
14
|
+
* @return {Blob}
|
|
15
|
+
*/
|
|
16
|
+
Blob.lookup = LookupWrapper(Blob);
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Retrieve the content of the Blob.
|
|
20
|
+
*
|
|
21
|
+
* @return {Buffer} Contents as a buffer.
|
|
22
|
+
*/
|
|
23
|
+
Blob.prototype.content = function() {
|
|
24
|
+
return this.rawcontent().toBuffer(this.rawsize());
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Retrieve the Blob's type.
|
|
29
|
+
*
|
|
30
|
+
* @return {Number} The filemode of the blob.
|
|
31
|
+
*/
|
|
32
|
+
Blob.prototype.filemode = function() {
|
|
33
|
+
var FileMode = TreeEntry.FILEMODE;
|
|
34
|
+
|
|
35
|
+
return this.isBinary() ? FileMode.EXECUTABLE : FileMode.BLOB;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Retrieve the Blob's content as String.
|
|
40
|
+
*
|
|
41
|
+
* @return {String} Contents as a string.
|
|
42
|
+
*/
|
|
43
|
+
Blob.prototype.toString = function() {
|
|
44
|
+
return this.content().toString();
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
Blob.filteredContent = util.deprecate(
|
|
48
|
+
_filteredContent,
|
|
49
|
+
"NodeGit.Blob.filteredContent is deprecated" +
|
|
50
|
+
" use NodeGit.Blob.prototype.filter instead."
|
|
51
|
+
);
|
package/lib/branch.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
var NodeGit = require("../");
|
|
2
|
+
var Branch = NodeGit.Branch;
|
|
3
|
+
|
|
4
|
+
var _remoteName = Branch.remoteName;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Retrieve the Branch's Remote Name as a String.
|
|
8
|
+
*
|
|
9
|
+
* @async
|
|
10
|
+
* @param {Repository} repo The repo to get the remote name from
|
|
11
|
+
* @param {String} the refname of the branch
|
|
12
|
+
* @return {String} remote name as a string.
|
|
13
|
+
*/
|
|
14
|
+
Branch.remoteName = function(repo, remoteRef) {
|
|
15
|
+
return _remoteName.call(this, repo, remoteRef)
|
|
16
|
+
.then(function(remoteNameBuffer) {
|
|
17
|
+
return remoteNameBuffer.toString();
|
|
18
|
+
});
|
|
19
|
+
};
|
package/lib/buf.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
var util = require("util");
|
|
2
|
+
var NodeGit = require("../");
|
|
3
|
+
var Buf = NodeGit.Buf;
|
|
4
|
+
|
|
5
|
+
var _set = Buf.prototype.set;
|
|
6
|
+
var _grow = Buf.prototype.grow;
|
|
7
|
+
var _isBinary = Buf.prototype.isBinary;
|
|
8
|
+
var _containsNul = Buf.prototype.containsNul;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Sets the content of a GitBuf to a string.
|
|
12
|
+
* @param {string} The utf8 value to set in the buffer.
|
|
13
|
+
* The string will be null terminated.
|
|
14
|
+
*/
|
|
15
|
+
var _setString = function(content) {
|
|
16
|
+
const buf = Buffer.from(content + "\0", "utf8");
|
|
17
|
+
this.set(buf, buf.length);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
Buf.prototype.set = util.deprecate(
|
|
21
|
+
_set,
|
|
22
|
+
"NodeGit.Buf.prototype.set is deprecated."
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
Buf.prototype.setString = util.deprecate(
|
|
26
|
+
_setString,
|
|
27
|
+
"NodeGit.Buf.prototype.setString is deprecated."
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
Buf.prototype.grow = util.deprecate(
|
|
31
|
+
_grow,
|
|
32
|
+
"NodeGit.Buf.prototype.grow is deprecated."
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
Buf.prototype.isBinary = util.deprecate(
|
|
36
|
+
_isBinary,
|
|
37
|
+
"NodeGit.Buf.prototype.isBinary is deprecated."
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
Buf.prototype.containsNul = util.deprecate(
|
|
41
|
+
_containsNul,
|
|
42
|
+
"NodeGit.Buf.prototype.containsNul is deprecated."
|
|
43
|
+
);
|