MCPcopy Create free account
hub / github.com/isomorphic-git/isomorphic-git / normalizeMode

Function normalizeMode

src/utils/normalizeMode.js:15–42  ·  view source on GitHub ↗
(mode)

Source from the content-addressed store, hash-verified

13 * Symbolic links and gitlinks have value 0 in this field.
14 */
15export function normalizeMode(mode) {
16 // Note: BrowserFS will use -1 for "unknown"
17 // I need to make it non-negative for these bitshifts to work.
18 let type = mode > 0 ? mode >> 12 : 0
19 // If it isn't valid, assume it as a "regular file"
20 // 0100 = directory
21 // 1000 = regular file
22 // 1010 = symlink
23 // 1110 = gitlink
24 if (
25 type !== 0b0100 &&
26 type !== 0b1000 &&
27 type !== 0b1010 &&
28 type !== 0b1110
29 ) {
30 type = 0b1000
31 }
32 let permissions = mode & 0o777
33 // Is the file executable? then 755. Else 644.
34 if (permissions & 0b001001001) {
35 permissions = 0o755
36 } else {
37 permissions = 0o644
38 }
39 // If it's not a regular file, scrub all permissions
40 if (type !== 0b1000) permissions = 0
41 return (type << 12) + permissions
42}

Callers 2

normalizeStatsFunction · 0.90
modeMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…