Giter VIP home page Giter VIP logo

depsync's People

Contributors

domchen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

imzc linecode

depsync's Issues

`depsync` fails when used against a Git worktree or submodule: incorrect assumption of `.git` being a directory

Description

Executing depsync for a Git worktree or submodule results in the following Node.js error:

Error: ENOTDIR: not a directory, chmod '/Volumes/data/workspace/repo-worktree/.git/.DEPS.unfinished'
at Object.chmodSync (node:fs:1961:3)
at Object.writeFile (/Users/sample-user/.nvm/versions/node/v20.9.0/lib/node_modules/depsync/src/Utils.js:136:12)
at DepsTask.run (/Users/sample-user/.nvm/versions/node/v20.9.0/lib/node_modules/depsync/src/tasks/DepsTask.js:80:11)
at Object.run (/Users/sample-user/.nvm/versions/node/v20.9.0/lib/node_modules/depsync/src/Program.js:108:14)
at Object. (/Users/sample-user/.nvm/versions/node/v20.9.0/lib/node_modules/depsync/bin/depsync:4:9)
at Module._compile (node:internal/modules/cjs/loader:1241:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1295:10)
at Module.load (node:internal/modules/cjs/loader:1091:32)
at Module._load (node:internal/modules/cjs/loader:938:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12) {
errno: -20,
syscall: 'chmod',
code: 'ENOTDIR',
path: '/Volumes/data/workspace/repo-worktree/.git/.DEPS.unfinished'
}

This is caused by the interruption detection feature introduced in 864f10f, released in 1.3.7:

function DepsTask(configFile, version, platform, nonRecursive) {
    // ...
    this.unfinishFile = path.join(path.dirname(this.configFile), ".git/.DEPS.unfinished");
}

DepsTask.prototype.run = function (callback) {
    // ...
    Utils.writeFile(this.unfinishFile, "depsync is syncing...");
    TaskRunner.runTasks(tasks, () => {
        Utils.deletePath(this.unfinishFile);
        Utils.deleteEmptyDir(path.dirname(this.unfinishFile));
        callback && callback();
    });
}

The implementation tries to create file ./.git/.DEPS.unfinished in order to track the current running task. It assumes that .git is always a directory, which is not the case for Git worktrees and submodules. In those scenarios, .git is a file used internally by Git to maintain the relationship between worktrees/submodules and the main repository.

Minimal reproducible sample

Run the following commands to clone a sample repository and set up a Git worktree.

git clone https://github.com/DL444/depsync-repro.git
cd depsync-repro
git worktree add ../depsync-repro-worktree repro
cd ../depsync-repro-worktree
depsync

Notice that depsync fails on 1.3.7 and later.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.