remotemobprogramming / mob

Tool for smooth git handover.
https://mob.sh
MIT License
1.66k stars 149 forks source link

Opening last modified file fails when path contains a space #387

Closed kriber82 closed 5 months ago

kriber82 commented 1 year ago

I am using mob.sh on windows inside a project with a space in the project path on disk. When I run mob start, instead of opening the last modified file in my current IDEA Window, a new IDEA window opens up.

Context Info:

What happens:

When I run mob start (with last modified file "test.txt"), a new IDEA window opens with two files open:

  1. "LH-MobSh" in "..._Development\github"
  2. "test.txt" in "...\LH-MobSh Kata\Kata"

The log of mob start --debug contains the following lines:

DEBUG Try to open last modified file
DEBUG Running command <git log -1 --pretty=format:%B> in silent mode, capturing combined output
DEBUG mob next [ci-skip] [ci skip] [skip ci]
DEBUG
DEBUG lastFile:test.txt
DEBUG Running command <git log -1 --pretty=format:%B> in silent mode, capturing combined output
DEBUG mob next [ci-skip] [ci skip] [skip ci]
DEBUG
DEBUG lastFile:test.txt
DEBUG Running command <git rev-parse --show-toplevel> in silent mode, capturing combined output
DEBUG C:/_Development/github/LH-MobSh Kata
DEBUG Starting command idea C:/_Development/github/LH-MobSh Kata/test.txt
DEBUG Open last modified file: C:/_Development/github/LH-MobSh Kata/test.txt

What should happen: Preferrably, the space in the path should be handled correctly and the last modified file should be opened in my current IDEA window. If that's too hard to accomplish, I would hope to see an error message explaining that spaces in the project path (and last modified file names) are not supported. In this case, it would be nice to abort opening the last modified file.

Preliminary Analysis: The main problem seems to be split := strings.Split(injectCommandWithMessage(c.OpenCommand, filepath), " ") in func openCommandFor(c config.Configuration, filepath string) (string, []string). This strings.Split operation results in the filepath being split into multiple args. If you are interested, I could share my attempt on opening the last modified file despite spaces in the project path. It works on my machine and comes with a new test. I will go through the contributing workflow in the next few days, if you are interested.

hollesse commented 5 months ago

closed with #388