unisonweb / unison

A friendly programming language from the future
https://unison-lang.org
Other
5.81k stars 271 forks source link

`mergetool`: provide absolute path to `$MERGED` #5455

Open aryairani opened 6 days ago

aryairani commented 6 days ago

Is your feature request related to a problem? Please describe. Currently, $MERGED is a bare filename relative to ucm's current dir. (we want the file in ucm's current dir so it will be parsed automatically). However, if the UCM_MERGETOOL command results in being in a different directory than the ucm current directory, then $MERGED will refer to the wrong location.

Describe the solution you'd like If Haskell can resolve $MERGED to an absolute path before interpolating UCM_MERGETOOL, then it'll be a little more resilient.

Describe alternatives you've considered As a workaround, since the interpolated UCM_MERGETOOL string is passed to a shell, I can thread a cd `pwd` into the string, but it makes the messy process of authoring the command string a little messier.

e.g.

UCM_MERGETOOL='osascript -e '"'"'tell app "Terminal" to do script "cd '`pwd`';/Applications/IntelliJ\\ IDEA\\ CE.app/Contents/MacOS/idea merge \"$LOCAL\" \"$REMOTE\" \"$BASE\" \"$MERGED\""'"'" ucm

In my case this also has the side effect of rerunning nix stuff with direnv before the mergetool is launched.

I could move the pwd to something more like `pwd`/$MERGED, but then that will break if $MERGED later is an absolute path.

Open to other suggestions!

Additional context ucm 0.5.28