{"id":20916166,"url":"https://github.com/emosheeep/lockfile-conflicts","last_synced_at":"2025-07-06T13:33:36.692Z","repository":{"id":218390637,"uuid":"745900693","full_name":"emosheeep/lockfile-conflicts","owner":"emosheeep","description":"A custom merge driver, aims to handle lockfile conflicts automatically in merge/rebase process.","archived":false,"fork":false,"pushed_at":"2024-06-16T05:56:00.000Z","size":622,"stargazers_count":11,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-01T23:07:44.899Z","etag":null,"topics":["automerge","cli","conflicts","cooperation","git","infra","lockfile","merge","merge-driver","monorepo","pnpm","rebase","workflow"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/emosheeep.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-20T13:48:19.000Z","updated_at":"2025-02-13T09:58:47.000Z","dependencies_parsed_at":"2024-06-16T06:49:54.387Z","dependency_job_id":null,"html_url":"https://github.com/emosheeep/lockfile-conflicts","commit_stats":null,"previous_names":["emosheeep/lockfile-conflicts"],"tags_count":5,"template":false,"template_full_name":"emosheeep/cli-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emosheeep%2Flockfile-conflicts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emosheeep%2Flockfile-conflicts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emosheeep%2Flockfile-conflicts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emosheeep%2Flockfile-conflicts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/emosheeep","download_url":"https://codeload.github.com/emosheeep/lockfile-conflicts/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253932703,"owners_count":21986441,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automerge","cli","conflicts","cooperation","git","infra","lockfile","merge","merge-driver","monorepo","pnpm","rebase","workflow"],"created_at":"2024-11-18T16:20:11.476Z","updated_at":"2025-05-13T11:30:28.450Z","avatar_url":"https://github.com/emosheeep.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Lockfile Conflicts Merging Driver\n\n[![npm version](https://img.shields.io/npm/v/lockfile-conflicts)](https://npmjs.com/package/lockfile-conflicts)\n![weekly downloads](https://img.shields.io/npm/dw/lockfile-conflicts)\n![license](https://img.shields.io/npm/l/lockfile-conflicts)\n![stars](https://img.shields.io/github/stars/emosheeep/lockfile-conflicts)\n\nHelps to merge lockfile conflicts and update automatically after merge/rebase.\n\n![example](https://raw.githubusercontent.com/emosheeep/lockfile-conflicts/HEAD/assets/lockfile-conflicts.gif)\n\n## Quick start\n\nFirst of all, install the dependencies in your project.\n\n```shell\npnpm install lockfile-conflicts -D\n```\n\nEdit `package.json` \u003e prepare script and run it once:\n\n```shell\nnpm pkg set scripts.prepare=\"lockfile install\"\nnpm run prepare\n```\n\nAnd then commit the changes made by the command. After installed, a custom merge driver will be defined and applied to merge certain files.\n\n## Use with git hook\n\nIn order to execute custom scripts automatically at proper time, we need to inject some shell script to git hooks, **which may cause conflicts with other git hook tools**, e.g. _husky, simple-git-hooks_ and so on.\n\nIn this case, you can place install script right after theirs. For an example:\n\n```json\n{\n  \"scripts\": {\n    \"prepare\": \"husky install \u0026\u0026 lockfile install\",\n    \"prepare\": \"simple-git-hooks \u0026\u0026 lockfile install\",\n    \"prepare\": \"\u003cother git hooks tool\u003e \u0026\u0026 lockfile install\"\n  }\n}\n```\n\n## What does it do\n\nWhen it was installed. it has done these things:\n\n1. Initialize config directory (default is .lockfile), see [Introduction](./config/README.md).\n2. Add git config to local repository, you can view them through `git config -l --local`.\n3. Inject shell scripts to some git hooks, which helps to execute custom script at proper time.\n\nDon't worry, all of these can be removed easily by execute `npx lockfile uninstall [--force]`, they can hardly make pollution.\n\n# About merge driver\n\n\u003e This section is revised from [Example of how to configure a custom git merge driver](https://github.com/Praqma/git-merge-driver)\n\nA merge driver defines how git merge a certain file, it usually uses with `.gitattributes`. For more, visit [Docs - Git Attributes](https://git-scm.com/docs/gitattributes).\n\n## Define the driver\n\nThis is done in the `.git/config` file using `git config` command:\n```shell\ngit config merge.[driver-name].name xxx\ngit config merge.[driver-name].driver xxx\n```\n\n```properties\n[merge \"lockfile-conflicts\"]\n  name = A custom merge driver used to resolve conflicts in certain files\n  driver = lockfile merge %O %A %B %P\n```\n\nThe `merge` block contains the merge driver's **identifier**, it\n's `lockfile-conflicts` here, used to reference the merge driver later.\n\nThe `name` property contains a description of the merge driver, this project doesn't use this property because it's not necessary.\n\nThe `driver` property contains the command that will be called when a conflict occurs. There's a handful of predefined parameters, most notably:\n\n- `%O`: ancestor’s version of the conflicting file\n- `%A`: ours version of the conflicting file\n- `%B`: theirs branch's version of the conflicting file\n- `%P`: the conflicting file relative path\n\n_Note: Any tools or scripts called by the merge driver must be available on `$PATH`_.\n\n## Use driver to merge file\n\nAdd patterns you want the merge driver to be used for in the `.gitattributes` file:\n\n```properties\n# .gitattributes\n*pnpm-lock.yaml merge=my-custom-driver\n```\n\n## Distribution\n\nNote that, much like git hooks, the `.git/config` file can't be checked in/shared through the repository.\n\nA common way of distributing merge drivers is to check the configuration file in elsewhere and provide a script to copy it to `.git/config`.\n\nIn this project, the step above is included by `lockfile install` command.\n\n# Questions\n\n## Why does `runAfter` to be triggered weirdly?\n\nWe execute `runAfter` by checking if there's a **conflicts information file** exist. \n\nThe file will be recorded in a temp location under the config directory when it happened, and will be removed when you successfully rebase or merge. All of these steps depend on specified git hooks and also will be triggered by them.\n\nBut unfortunately, the lifecycle hooks that git provides are incomplete, which means we'll lose context and causes temp file remains if you abort a rebase or merge process.\n\nNext time you succeed to make a commit action, the `post-commit` hook triggers as usual but it will execute `runAfter` because the temp file exist. This is why the case happens.\n\nDon't worry about this, because **we'll delete temp file first to avoid mis-executing and these hook won't affect your commit result**. Just ignore it and then everything will be okay in next execution.\n\n# Contribution\n\nPlease read the documentations of these useful tools before developing:\n\n- [zx](https://github.com/google/zx) - Execute shell command conveniently in Node.js workflow.\n- [commander](https://github.com/tj/commander.js) - Node.js command-line interfaces.\n- [tsup](https://github.com/egoist/tsup) - A simple and fast builder based on esbuild.\n- [changesets](https://github.com/changesets/changesets) - A way to manage your versioning and changelogs.\n- and so do the other tools you'll develop with, please read the docs by yourself.\n\nPR welcome if you have any constructive suggestions.\nPR welcome if you have any constructive suggestions.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femosheeep%2Flockfile-conflicts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Femosheeep%2Flockfile-conflicts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femosheeep%2Flockfile-conflicts/lists"}