git-sim icon indicating copy to clipboard operation
git-sim copied to clipboard

Feature Request: Do not store media in local project directory

Open deadlydog opened this issue 2 years ago • 9 comments

First off, this is a very cool project. Thank you for it!

One thing I don't like is that git-sim stores it's media files in the local project directory, and it's easy to accidentally commit them to the git repo if it hasn't been added to the .gitignore file. Most of the time I think the images/videos are only needed temporarily, and could be deleted. There is the --media-dir parameter, but having to provide it every time you use git-sim is cumbersome.

There's a few different ways you could tackle this problem. Some thoughts I had were:

  1. Allow the user to configure a global media directory that would be used instead of default local directory. The user can manually delete the global directory from time to time to clean up the media files.
  2. Save the media to the user's temporary directory, where it will eventually get cleaned up automatically. I'm not sure if this is a cross-platform concept or not and if Python has an easy way of getting the temp path, but hopefully.

Maybe you (or others) have other suggestions?

deadlydog avatar Jan 23 '23 04:01 deadlydog

Hey there,

Thanks for checking out the project, and great points! I did consider this but for the initial release didn't have the time to implement something besides the --media-dir option you mentioned. It's true that dirtying up the local repo by default isn't really a great practice...

I think for starters a configurable global media directory is a good option. This could be stored and read from a user-level or global-level configuration file similar to how Git's config works.

The only real question in my mind is whether media generated from different repos should all go into the same folder, or whether there should be separate subfolders within the global media folder on a per project basis. Probably the latter would make more sense...

Any interest in helping to implement something like this? Happy to give you the lay of the land of the Python codebase if it's something you're interested in poking at! And you would get the honor of being the first contributor! (Whatever that's worth :D)

initialcommit-io avatar Jan 23 '23 06:01 initialcommit-io

Hey @initialcommit-io

If the OP is not available to work on this, I'd like to give it a try and implement this. I agree with your suggestion for a global media dir followed by repo sub folders. Maybe the user can set an environment variable for the same ?

abhijitnathwani avatar Jan 23 '23 07:01 abhijitnathwani

Hey there!

Sure honestly there's no queue so if you want to try implementing something feel free to do so, test it locally, and submit a pull request for me to check it out.

Environment variable would be a cool addition too!

initialcommit-io avatar Jan 23 '23 07:01 initialcommit-io

Hey @initialcommit-io , would def like to work on this. Can you please add a contributions.md to let us know how to contribute/get this setup locally if possible? I think that would be of great help. Thank you!.

PaulisMatrix avatar Jan 23 '23 14:01 PaulisMatrix

Oh yes @PaulisMatrix good idea, will do that shortly!

initialcommit-io avatar Jan 23 '23 15:01 initialcommit-io

Hey @initialcommit-io To approach the solution I was thinking of the following:

  • Users could set an env variable that would point to the media dir. This global directory would have folders based on the repo name.
  • If the args --media-dir is provided, that would take precedence over the env variable, if set, as it would mean user wants to explicitly override the media dir by passing the argument
  • If no env variable or media dir args is passed, the git-sim_media directory would be created in the repo. We could ease out the confusion for tracked files by adding this folder to the .gitignore so that the user doesn't accidentally add it to their repository.

Let me know your thoughts

abhijitnathwani avatar Jan 24 '23 07:01 abhijitnathwani

A workaround I use is to define an alias that calls git-sim --media-dir="/tmp/git-sim$(git rev-parse --show-toplevel)"

Susensio avatar Jan 24 '23 09:01 Susensio

@abhijitnathwani I like that solution. It is less complex than having to worry about setting up config files at different scopes, like repo scope / user scope / system scope. I think it's a reasonable assumption for now that users who want to customize this location would be ok with a single global folder which would contain subfolders for each repo like you mentioned. That would also keep them nicely organized in one place, and I think is a good use case for an environment variable.

Just 2 things:

  1. Let's make sure to test/validate that the environment variable method works on Windows/Linux/MacOS

  2. In your third point you mentioned potentially adding an entry automatically into .gitignore, which we could do, but then the user might be confused as to why the .gitignore is suddenly modified in the repo. I think it's better to just add the git-sim_media folder and they can handle it how they want.

Let me know if that sounds ok!

initialcommit-io avatar Jan 25 '23 07:01 initialcommit-io

@PaulisMatrix FYI I just added CONTRIBUTING.md with details on how to contribute and run the source code locally.

initialcommit-io avatar Jan 25 '23 08:01 initialcommit-io

Thanks so much for making this happen! 🙌

deadlydog avatar Jan 26 '23 18:01 deadlydog