isomorphic-git 1.28.0 → 1.30.0

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/README.md CHANGED
@@ -17,7 +17,7 @@ By providing functionality as individual functions, code bundlers can produce sm
17
17
  The project includes type definitions so you can enjoy static type-checking and intelligent code completion in editors like VS Code and [CodeSandbox](https://codesandbox.io).
18
18
 
19
19
  ## Project status
20
- The original author of the project ([Billie Hilton](https://github.com/wmhilton)) left the project, but the project is still maintained by two volunteers:
20
+ The original author of the project ([Billie Hilton](https://github.com/billiegoose)) left the project, but the project is still maintained by two volunteers:
21
21
 
22
22
  * [@jcubic](https://github.com/jcubic) (most active)
23
23
  * [@mojavelinux](https://github.com/mojavelinux)
@@ -114,14 +114,14 @@ Unfortunately, due to the same-origin policy by default `isomorphic-git` can onl
114
114
  For this purpose [@isomorphic-git/cors-proxy](https://github.com/isomorphic-git/cors-proxy) exists which you can clone or [`npm install`](https://www.npmjs.com/package/@isomorphic-git/cors-proxy).
115
115
  For testing or small projects, you can also use [https://cors.isomorphic-git.org](https://cors.isomorphic-git.org) - a free proxy sponsored by [Clever Cloud](https://www.clever-cloud.com/?utm_source=ref&utm_medium=link&utm_campaign=isomorphic-git).
116
116
 
117
- I'm hoping to get CORS headers added to all the major Git hosting platforms eventually, and will list my progress here:
117
+ We hope to get CORS headers added to all the major Git hosting platforms eventually, and will list the progress made here:
118
118
 
119
119
  | Service | Supports CORS requests |
120
120
  | ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
121
121
  | Gogs (self-hosted) | [✔](https://isomorphic-git.github.io/blog/2018/04/07/gogs-adds-cors-headers-for-isomorphic-git.html) |
122
122
  | Gitea (self-hosted) | [✔](https://github.com/go-gitea/gitea/pull/5719) |
123
123
  | Azure DevOps | [✔](https://github.com/isomorphic-git/isomorphic-git/issues/678#issuecomment-452402740) (Usage Note: requires authentication) |
124
- | Gitlab | ❌ My [PR](https://gitlab.com/gitlab-org/gitlab-workhorse/merge_requests/219) was rejected, but the [issue](https://gitlab.com/gitlab-org/gitlab/issues/20590) is still open! |
124
+ | Gitlab | ❌ Our [PR](https://gitlab.com/gitlab-org/gitlab-workhorse/merge_requests/219) was rejected, but the [issue](https://gitlab.com/gitlab-org/gitlab/issues/20590) is still open! |
125
125
  | Bitbucket | ❌ |
126
126
  | Github | ❌ |
127
127
 
@@ -140,7 +140,7 @@ The CLI is more of a lark for quickly testing `isomorphic-git` and isn't really
140
140
 
141
141
  ## Supported Git commands
142
142
 
143
- This project follows semantic versioning, so I may continue to make changes to the API but they will always be backwards compatible
143
+ This project follows semantic versioning, so we may continue to make changes to the API but they will always be backwards compatible
144
144
  unless there is a major version bump.
145
145
 
146
146
  ### commands
@@ -183,6 +183,7 @@ unless there is a major version bump.
183
183
  - [listBranches](https://isomorphic-git.github.io/docs/listBranches.html)
184
184
  - [listFiles](https://isomorphic-git.github.io/docs/listFiles.html)
185
185
  - [listNotes](https://isomorphic-git.github.io/docs/listNotes.html)
186
+ - [listRefs](https://isomorphic-git.github.io/docs/listRefs.html)
186
187
  - [listRemotes](https://isomorphic-git.github.io/docs/listRemotes.html)
187
188
  - [listServerRefs](https://isomorphic-git.github.io/docs/listServerRefs.html)
188
189
  - [listTags](https://isomorphic-git.github.io/docs/listTags.html)
@@ -266,7 +267,7 @@ Check out the [`CONTRIBUTING`](./CONTRIBUTING.md) document for more instructions
266
267
 
267
268
  Isomorphic-git would not have been possible without the pioneering work by
268
269
  @creationix and @chrisdickinson. Git is a tricky binary mess, and without
269
- their examples (and their modules!) I would not have been able to come even
270
+ their examples (and their modules!) we would not have been able to come even
270
271
  close to finishing this. They are geniuses ahead of their time.
271
272
 
272
273
  Cross-browser device testing is provided by:
@@ -373,13 +374,17 @@ Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds
373
374
  <td align="center"><a href="http://www.codeproject.com/script/Articles/MemberArticles.aspx?amid=62372"><img src="https://avatars.githubusercontent.com/u/865809?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Modesty Zhang</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=modesty" title="Code">💻</a> <a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=modesty" title="Documentation">📖</a> <a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=modesty" title="Tests">⚠️</a></td>
374
375
  <td align="center"><a href="https://github.com/amrc-benmorrow"><img src="https://avatars.githubusercontent.com/u/120477944?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Ben Morrow</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=amrc-benmorrow" title="Code">💻</a></td>
375
376
  </tr>
376
- <tr>
377
+ <tr>
377
378
  <td align="center"><a href="https://github.com/jayree"><img src="https://avatars.githubusercontent.com/u/14836154?v=4?s=60" width="60px;" alt=""/><br /><sub><b>jayree</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=jayree" title="Code">💻</a> <a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=jayree" title="Tests">⚠️</a></td>
378
379
  <td align="center"><a href="https://github.com/lsegurado"><img src="https://avatars.githubusercontent.com/u/27731047?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Lucas Martin Segurado</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=lsegurado" title="Documentation">📖</a> <a href="https://github.com/isomorphic-git/isomorphic-git/issues?q=author%3Alsegurado" title="Bug reports">🐛</a></td>
379
380
  <td align="center"><a href="https://github.com/limond"><img src="https://avatars.githubusercontent.com/u/1025682?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Leon Kaucher</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=limond" title="Code">💻</a> <a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=limond" title="Tests">⚠️</a></td>
380
381
  <td align="center"><a href="https://github.com/gilisho"><img src="https://avatars.githubusercontent.com/u/40733156?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Gili Shohat</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=gilisho" title="Code">💻</a> <a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=gilisho" title="Documentation">📖</a> <a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=gilisho" title="Tests">⚠️</a></td>
381
382
  <td align="center"><a href="https://github.com/hhourani27"><img src="https://avatars.githubusercontent.com/u/61935766?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Habib</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=hhourani27" title="Code">💻</a> <a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=hhourani27" title="Documentation">📖</a> <a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=hhourani27" title="Tests">⚠️</a></td>
382
383
  <td align="center"><a href="https://github.com/Vinzent03"><img src="https://avatars.githubusercontent.com/u/63981639?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Vinzent</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=Vinzent03" title="Code">💻</a></td>
384
+ <td align="center"><a href="https://github.com/LokiMidgard"><img src="https://avatars.githubusercontent.com/u/389101?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Patrick Kranz</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=LokiMidgard" title="Code">💻</a> <a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=LokiMidgard" title="Documentation">📖</a> <a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=LokiMidgard" title="Tests">⚠️</a></td>
385
+ </tr>
386
+ <tr>
387
+ <td align="center"><a href="https://github.com/lukecotter"><img src="https://avatars.githubusercontent.com/u/4013877?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Luke Cotter</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=lukecotter" title="Code">💻</a></td>
383
388
  </tr>
384
389
  </table>
385
390
 
@@ -1,12 +1,8 @@
1
1
  [
2
2
  "Chrome Headless 79.0.3945.0 (Linux x86_64)",
3
- "Firefox 132.0 (Ubuntu 0.0.0)",
4
- "X Chrome 128.0.0.0 (Android 10)",
3
+ "Firefox 136.0 (Ubuntu 0.0.0)",
4
+ "Chrome 128.0.0.0 (Android 10)",
5
5
  "Edge 79.0.309.65 (Windows 10)",
6
- "Safari 13.1 (Mac OS 10.15.4)",
7
- "Mobile Safari 13.0 (iOS 13.0)",
8
- "Chrome Headless 79.0.3945.0 (Linux x86_64)",
9
- "X Chrome 128.0.0.0 (Android 10)",
10
- "Chrome Headless 79.0.3945.0 (Linux x86_64)",
11
- "Chrome 128.0.0.0 (Android 10)"
6
+ "Safari 14.1 (Mac OS 10.15.7)",
7
+ "Mobile Safari 14.0 (iOS 14.0.1)"
12
8
  ]
@@ -13,13 +13,13 @@ export type GitHttpRequest = {
13
13
  /**
14
14
  * - The HTTP method to use
15
15
  */
16
- method?: string;
16
+ method?: string | undefined;
17
17
  /**
18
18
  * - Headers to include in the HTTP request
19
19
  */
20
20
  headers?: {
21
21
  [x: string]: string;
22
- };
22
+ } | undefined;
23
23
  /**
24
24
  * - An HTTP or HTTPS agent that manages connections for the HTTP client (Node.js only)
25
25
  */
@@ -27,15 +27,15 @@ export type GitHttpRequest = {
27
27
  /**
28
28
  * - An async iterator of Uint8Arrays that make up the body of POST requests
29
29
  */
30
- body?: any;
30
+ body?: AsyncIterableIterator<Uint8Array>;
31
31
  /**
32
32
  * - Reserved for future use (emitting `GitProgressEvent`s)
33
33
  */
34
- onProgress?: ProgressCallback;
34
+ onProgress?: ProgressCallback | undefined;
35
35
  /**
36
36
  * - Reserved for future use (canceling a request)
37
37
  */
38
- signal?: any;
38
+ signal?: object;
39
39
  };
40
40
  export type GitHttpResponse = {
41
41
  /**
@@ -45,17 +45,17 @@ export type GitHttpResponse = {
45
45
  /**
46
46
  * - The HTTP method that was used
47
47
  */
48
- method?: string;
48
+ method?: string | undefined;
49
49
  /**
50
50
  * - HTTP response headers
51
51
  */
52
52
  headers?: {
53
53
  [x: string]: string;
54
- };
54
+ } | undefined;
55
55
  /**
56
56
  * - An async iterator of Uint8Arrays that make up the body of the response
57
57
  */
58
- body?: any;
58
+ body?: AsyncIterableIterator<Uint8Array>;
59
59
  /**
60
60
  * - The HTTP status code
61
61
  */
@@ -13,13 +13,13 @@ export type GitHttpRequest = {
13
13
  /**
14
14
  * - The HTTP method to use
15
15
  */
16
- method?: string;
16
+ method?: string | undefined;
17
17
  /**
18
18
  * - Headers to include in the HTTP request
19
19
  */
20
20
  headers?: {
21
21
  [x: string]: string;
22
- };
22
+ } | undefined;
23
23
  /**
24
24
  * - An HTTP or HTTPS agent that manages connections for the HTTP client (Node.js only)
25
25
  */
@@ -27,15 +27,15 @@ export type GitHttpRequest = {
27
27
  /**
28
28
  * - An async iterator of Uint8Arrays that make up the body of POST requests
29
29
  */
30
- body?: any;
30
+ body?: AsyncIterableIterator<Uint8Array>;
31
31
  /**
32
32
  * - Reserved for future use (emitting `GitProgressEvent`s)
33
33
  */
34
- onProgress?: ProgressCallback;
34
+ onProgress?: ProgressCallback | undefined;
35
35
  /**
36
36
  * - Reserved for future use (canceling a request)
37
37
  */
38
- signal?: any;
38
+ signal?: object;
39
39
  };
40
40
  export type GitHttpResponse = {
41
41
  /**
@@ -45,17 +45,17 @@ export type GitHttpResponse = {
45
45
  /**
46
46
  * - The HTTP method that was used
47
47
  */
48
- method?: string;
48
+ method?: string | undefined;
49
49
  /**
50
50
  * - HTTP response headers
51
51
  */
52
52
  headers?: {
53
53
  [x: string]: string;
54
- };
54
+ } | undefined;
55
55
  /**
56
56
  * - An async iterator of Uint8Arrays that make up the body of the response
57
57
  */
58
- body?: any;
58
+ body?: AsyncIterableIterator<Uint8Array>;
59
59
  /**
60
60
  * - The HTTP status code
61
61
  */
package/index.cjs CHANGED
@@ -1489,6 +1489,10 @@ function compareRefNames(a, b) {
1489
1489
 
1490
1490
  // This is straight from parse_unit_factor in config.c of canonical git
1491
1491
  const num = val => {
1492
+ if (typeof val === 'number') {
1493
+ return val
1494
+ }
1495
+
1492
1496
  val = val.toLowerCase();
1493
1497
  let n = parseInt(val);
1494
1498
  if (val.endsWith('k')) n *= 1024;
@@ -1499,6 +1503,10 @@ const num = val => {
1499
1503
 
1500
1504
  // This is straight from git_parse_maybe_bool_text in config.c of canonical git
1501
1505
  const bool = val => {
1506
+ if (typeof val === 'boolean') {
1507
+ return val
1508
+ }
1509
+
1502
1510
  val = val.trim().toLowerCase();
1503
1511
  if (val === 'true' || val === 'yes' || val === 'on') return true
1504
1512
  if (val === 'false' || val === 'no' || val === 'off') return false
@@ -1614,6 +1622,7 @@ const normalizePath = path => {
1614
1622
  name,
1615
1623
  path: getPath(section, subsection, name),
1616
1624
  sectionPath: getPath(section, subsection, null),
1625
+ isSection: !!section,
1617
1626
  }
1618
1627
  };
1619
1628
 
@@ -1674,7 +1683,7 @@ class GitConfig {
1674
1683
 
1675
1684
  async getSubsections(section) {
1676
1685
  return this.parsedConfig
1677
- .filter(config => config.section === section && config.isSection)
1686
+ .filter(config => config.isSection && config.section === section)
1678
1687
  .map(config => config.subsection)
1679
1688
  }
1680
1689
 
@@ -1696,7 +1705,9 @@ class GitConfig {
1696
1705
  name,
1697
1706
  path: normalizedPath,
1698
1707
  sectionPath,
1708
+ isSection,
1699
1709
  } = normalizePath(path);
1710
+
1700
1711
  const configIndex = findLastIndex(
1701
1712
  this.parsedConfig,
1702
1713
  config => config.path === normalizedPath
@@ -1738,6 +1749,7 @@ class GitConfig {
1738
1749
  } else {
1739
1750
  // Add a new section
1740
1751
  const newSection = {
1752
+ isSection,
1741
1753
  section,
1742
1754
  subsection,
1743
1755
  modified: true,
@@ -4124,6 +4136,8 @@ class GitWalkerFs {
4124
4136
  this.cache = cache;
4125
4137
  this.dir = dir;
4126
4138
  this.gitdir = gitdir;
4139
+
4140
+ this.config = null;
4127
4141
  const walker = this;
4128
4142
  this.ConstructEntry = class WorkdirEntry {
4129
4143
  constructor(fullpath) {
@@ -4210,7 +4224,7 @@ class GitWalkerFs {
4210
4224
  if ((await entry.type()) === 'tree') {
4211
4225
  entry._content = undefined;
4212
4226
  } else {
4213
- const config = await GitConfigManager.get({ fs, gitdir });
4227
+ const config = await this._getGitConfig(fs, gitdir);
4214
4228
  const autocrlf = await config.get('core.autocrlf');
4215
4229
  const content = await fs.read(`${dir}/${entry._fullpath}`, { autocrlf });
4216
4230
  // workaround for a BrowserFS edge case
@@ -4226,6 +4240,7 @@ class GitWalkerFs {
4226
4240
 
4227
4241
  async oid(entry) {
4228
4242
  if (entry._oid === false) {
4243
+ const self = this;
4229
4244
  const { fs, gitdir, cache } = this;
4230
4245
  let oid;
4231
4246
  // See if we can use the SHA1 hash in the index.
@@ -4234,7 +4249,7 @@ class GitWalkerFs {
4234
4249
  ) {
4235
4250
  const stage = index.entriesMap.get(entry._fullpath);
4236
4251
  const stats = await entry.stat();
4237
- const config = await GitConfigManager.get({ fs, gitdir });
4252
+ const config = await self._getGitConfig(fs, gitdir);
4238
4253
  const filemode = await config.get('core.filemode');
4239
4254
  const trustino =
4240
4255
  typeof process !== 'undefined'
@@ -4273,6 +4288,14 @@ class GitWalkerFs {
4273
4288
  }
4274
4289
  return entry._oid
4275
4290
  }
4291
+
4292
+ async _getGitConfig(fs, gitdir) {
4293
+ if (this.config) {
4294
+ return this.config
4295
+ }
4296
+ this.config = await GitConfigManager.get({ fs, gitdir });
4297
+ return this.config
4298
+ }
4276
4299
  }
4277
4300
 
4278
4301
  // @ts-check
@@ -5066,6 +5089,8 @@ async function add({
5066
5089
 
5067
5090
  const fs = new FileSystem(_fs);
5068
5091
  await GitIndexManager.acquire({ fs, gitdir, cache }, async index => {
5092
+ const config = await GitConfigManager.get({ fs, gitdir });
5093
+ const autocrlf = await config.get('core.autocrlf');
5069
5094
  return addToIndex({
5070
5095
  dir,
5071
5096
  gitdir,
@@ -5074,6 +5099,7 @@ async function add({
5074
5099
  index,
5075
5100
  force,
5076
5101
  parallel,
5102
+ autocrlf,
5077
5103
  })
5078
5104
  });
5079
5105
  } catch (err) {
@@ -5090,6 +5116,7 @@ async function addToIndex({
5090
5116
  index,
5091
5117
  force,
5092
5118
  parallel,
5119
+ autocrlf,
5093
5120
  }) {
5094
5121
  // TODO: Should ignore UNLESS it's already in the index.
5095
5122
  filepath = Array.isArray(filepath) ? filepath : [filepath];
@@ -5118,6 +5145,7 @@ async function addToIndex({
5118
5145
  index,
5119
5146
  force,
5120
5147
  parallel,
5148
+ autocrlf,
5121
5149
  })
5122
5150
  );
5123
5151
  await Promise.all(promises);
@@ -5131,12 +5159,11 @@ async function addToIndex({
5131
5159
  index,
5132
5160
  force,
5133
5161
  parallel,
5162
+ autocrlf,
5134
5163
  });
5135
5164
  }
5136
5165
  }
5137
5166
  } else {
5138
- const config = await GitConfigManager.get({ fs, gitdir });
5139
- const autocrlf = await config.get('core.autocrlf');
5140
5167
  const object = stats.isSymbolicLink()
5141
5168
  ? await fs.readlink(pathBrowserify.join(dir, currentFilepath)).then(posixifyPathBuffer)
5142
5169
  : await fs.read(pathBrowserify.join(dir, currentFilepath), { autocrlf });
@@ -7605,8 +7632,8 @@ function filterCapabilities(server, client) {
7605
7632
 
7606
7633
  const pkg = {
7607
7634
  name: 'isomorphic-git',
7608
- version: '1.28.0',
7609
- agent: 'git/isomorphic-git@1.28.0',
7635
+ version: '1.30.0',
7636
+ agent: 'git/isomorphic-git@1.30.0',
7610
7637
  };
7611
7638
 
7612
7639
  class FIFO {
@@ -11070,6 +11097,40 @@ async function listNotes({
11070
11097
 
11071
11098
  // @ts-check
11072
11099
 
11100
+ /**
11101
+ * List refs
11102
+ *
11103
+ * @param {object} args
11104
+ * @param {FsClient} args.fs - a file system client
11105
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
11106
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
11107
+ * @param {string} [args.filepath] - [required] The refs path to list
11108
+ *
11109
+ * @returns {Promise<Array<string>>} Resolves successfully with an array of ref names below the supplied `filepath`
11110
+ *
11111
+ * @example
11112
+ * let refs = await git.listRefs({ fs, dir: '/tutorial', filepath: 'refs/heads' })
11113
+ * console.log(refs)
11114
+ *
11115
+ */
11116
+ async function listRefs({
11117
+ fs,
11118
+ dir,
11119
+ gitdir = pathBrowserify.join(dir, '.git'),
11120
+ filepath,
11121
+ }) {
11122
+ try {
11123
+ assertParameter('fs', fs);
11124
+ assertParameter('gitdir', gitdir);
11125
+ return GitRefManager.listRefs({ fs: new FileSystem(fs), gitdir, filepath })
11126
+ } catch (err) {
11127
+ err.caller = 'git.listRefs';
11128
+ throw err
11129
+ }
11130
+ }
11131
+
11132
+ // @ts-check
11133
+
11073
11134
  /**
11074
11135
  * @param {object} args
11075
11136
  * @param {import('../models/FileSystem.js').FileSystem} args.fs
@@ -16056,6 +16117,7 @@ var index = {
16056
16117
  listBranches,
16057
16118
  listFiles,
16058
16119
  listNotes,
16120
+ listRefs,
16059
16121
  listRemotes,
16060
16122
  listServerRefs,
16061
16123
  listTags,
@@ -16127,6 +16189,7 @@ exports.isIgnored = isIgnored;
16127
16189
  exports.listBranches = listBranches;
16128
16190
  exports.listFiles = listFiles;
16129
16191
  exports.listNotes = listNotes;
16192
+ exports.listRefs = listRefs;
16130
16193
  exports.listRemotes = listRemotes;
16131
16194
  exports.listServerRefs = listServerRefs;
16132
16195
  exports.listTags = listTags;