Skip to content

lockfix reverts changes if cannot apply the patch #256

@andrew-potachits

Description

@andrew-potachits

My repository has multiple projects, some of them are C#, others are nodejs.
The structure is like this:

solution
  some-nodejs-proj
  some-c#-proj
    another-nodejs-proj
...

when some-c#-proj has some changes (C# files, changed and added files), and in another-nodejs-proj I run lockfix -f, it reverts my changes.
I repeated the steps from the lockfix.ts, and figured out that the patch created by git diff --binary HEAD cannot be applied to my working copy, most likely because of UTF BOM in the affected hunks.
however, the tool doesn't report any error about the error for the patch apply, and (which is worse) it doesn't preserve the working copy state.

I would suggest the following improvements to the tool:

  1. don't touch the files other than package-lock.json. It will minimize the potential damage.
  2. make a copy of the files being modified, so they can be restored in case of failure (automatically or manually).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions