https://github.com/pierrot-lc/buku-merger
A small app to automatically handle merge conflicts with buku databases.
https://github.com/pierrot-lc/buku-merger
buku git gleam
Last synced: 7 months ago
JSON representation
A small app to automatically handle merge conflicts with buku databases.
- Host: GitHub
- URL: https://github.com/pierrot-lc/buku-merger
- Owner: pierrot-lc
- License: apache-2.0
- Created: 2024-10-20T21:44:05.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-11-01T18:20:21.000Z (about 1 year ago)
- Last Synced: 2025-04-04T12:11:31.020Z (7 months ago)
- Topics: buku, git, gleam
- Language: Gleam
- Homepage:
- Size: 35.2 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Buku Merger
Custom git driver to handle merge conflicts of your [buku][buku] bookmarks.
I had the idea of using git to sync my bookmarks, _which are stored as a
SQLite database_. The first merge conflict proved me that it was a bad idea. But
I am lazy and I don't want to handle the sync service myself, so I made this
tool to handle the conflicts automatically for me so that I can keep using git
as a "cloud service" for my bookmarks.
Feel free to use it for your own buku git repository!
## Installation
**From source:**
1. Clone the repository.
1. Install [Gleam][gleam].
1. Run `gleam run -m gleescript`.
1. Add the generated `buku_merger` to your `PATH`.
**Using Nix:**
This repository includes a flake which provides the package. You can test the
package directly by running:
```bash
nix run "github:pierrot-lc/buku-merger"
```
## How to Use
The tool expects the following:
```bash
buku_merger
```
Where:
- `` is the local version of the bookmarks database,
- `` is the remote version conflicting with your `` version,
and
- `` is the latest common ancestor between the two conflicting databases.
To use the tool automatically when there's a conflict, you need to add the driver
to your git configuration:
```gitconfig
# .gitconfig or config
[merge "buku-driver"]
name = "Custom buku merge driver, handling the bookmarks SQLite database"
driver = buku_merger %O %A %B
recursive = binary
```
Add those lines either in your `~/.config/git/config` globally or in your buku
repository at `.git/config`.
Then, specify in your buku repository that you want to use that driver for
bookmark conflicts:
```gitattributes
# .gitattributes
bookmarks.db merge=buku-driver
```
Place this file at the root of your buku repository.
## How it Works?
The merge conflict is handled in two phases:
1. Identify rows modified in `` compared to `` and apply those
modifications to ``.
1. Find new rows in `` that do not exist in `` and add them.
1. ~~Find removed rows from `` that are still present in `` and
remove them from ``.~~
The final file `` is used by git as the merged version.
_I no longer delete the bookmarks, as it is too easy to mess everything up._
## Shoutouts
This tool is made using the awesome [Gleam][gleam] language and uses
[sqlight][sqlight] to interface with SQLite.
The flake uses [nix-gleam][nix-gleam] to generate the package derivation
effortlessly.
[buku]: https://github.com/jarun/buku
[gleam]: https://gleam.run/
[nix-gleam]: https://github.com/arnarg/nix-gleam
[sqlight]: https://github.com/lpil/sqlight