Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add option to keep projects in nested directories #187

Open
LordMZTE opened this issue Jun 11, 2021 · 23 comments
Open

add option to keep projects in nested directories #187

LordMZTE opened this issue Jun 11, 2021 · 23 comments

Comments

@LordMZTE
Copy link
Contributor

I personally like keeping my projects in a nested directory.
For example, if I'm working on a project foo, then the git repo would be cloned at ~/dev/foo/foo.
With this structure, I can keep additional things needed (such as testing environments) for foo in the outer foo directory, without interfering with the repo.
However, fw doesn't seem to support this. It would be really awesome to have this, as fw currently wouldn't work with some of my projects for that reason.

@LordMZTE
Copy link
Contributor Author

I am aware that it is possible to do this by setting override_path, but it is really annoying doing this for every project, instead of it defaulting to that path when using the add command.

@bomgar
Copy link
Member

bomgar commented Jun 12, 2021

I think this is related to #23
@mriehl any other ideas?

@LordMZTE
Copy link
Contributor Author

Yeah, it seems to be related, if #23 were implemented that should fix my issue.

@mriehl
Copy link
Member

mriehl commented Jun 14, 2021

Yeah I also agree this is something #23 could tackle (along with a slew of other customizations).
I guess there is a workaround where you can "implement" your logic in a shell alias, by saying something like:

/usr/bin/fw-add-nested:

#!/bin/bash

REMOTE=${1:?"Usage: $0 <git remote>"}
NAME=$(echo "$REMOTE" | cut -d "/" -f2 | tr -d ".git")

fw add "$REMOTE" --override-path "/tmp/$NAME/$NAME"

and then you can just do fw-add-nested git@github.com:foo/bar.git

It isn't the sexiest but that would work with unlimited flexibility today and we won't break CLI backwards compatibility especially in the case of something like fw add.

@bomgar
Copy link
Member

bomgar commented Jun 14, 2021 via email

@mriehl
Copy link
Member

mriehl commented Jun 14, 2021

@bomgar what do you mean it breaks fw sync? It's basically just a project with override path.
Do you mean there's a mkdir -p missing somewhere in the sync code because the parent dir basically doesn't exist?

@bomgar
Copy link
Member

bomgar commented Jun 14, 2021

A sorry I should no reply to threads after waking up.

@bomgar
Copy link
Member

bomgar commented Jun 14, 2021

@LordMZTE is the workaround working for you? Or are you planning on working on the issue yourself? Or should we implement something if we decide what to do and have the time to implement it?

@LordMZTE
Copy link
Contributor Author

I haven't tried the workaround yet, but once we decide what to do in #23 I'd be happy to contribute!

@chevdor
Copy link
Contributor

chevdor commented Dec 13, 2024

This is a short title but would be a huge feature.
As the project list grows, it is hard keeping a flat srtucture.
Moreover some (non monorepos) projects may require a parent folder to keep things organize.
Finally for archiving purpose, it would be sweet being able to sort out projects in folders with as 2024, 2025, etc...

I discovered override_path which is already pretty nice indeed.
It would be ideal if fw add . could work for an existing project and the path automatically set to the current dir using override_path if the value does not match the standard.

@bomgar
Copy link
Member

bomgar commented Dec 13, 2024

#23

this would solve a lot. I just don't have time to work at it at the moment.

@bomgar
Copy link
Member

bomgar commented Dec 13, 2024

Also try fw import instead of fw add

@bomgar
Copy link
Member

bomgar commented Jan 2, 2025

@chevdor I just looked at the code. Tags can define the workspace. Can you try if that solves your problem?

@chevdor
Copy link
Contributor

chevdor commented Jan 5, 2025

@bomgar happy new year 🎉 :)

I am not sure I can/want to use tags for the use case.

Honnestly I did not know about --override-path and it works pretty well already.
The only drawback being the required manual step to set it up. And option may be to check if the add/imported project is in the canonical folder and if not, set the --override-path automagically. I am not sure if importing an already imported folder is "legal" but if it is, that would be an option then to "fix" a folder/project that was moved.

So say:

  • you have project under the canocial workspace => same as today
  • if you add/import a project under another folder, --override-path is set
  • importing again a project will check if --override-path still match and update the path (with confirmation maybe)

Do you think that would be possible ?

My main use case is that I have soo many projects under the canonical root and I now group them so I go from:

  • /project1
  • /project2
  • /project3

to

  • /topic1/project1
  • /topic1/project2
  • /project3

@bomgar
Copy link
Member

bomgar commented Jan 5, 2025

If you create a tag like this:

» cat ~/.config/fw/tags/default/2025

workspace = "~/development/2025"

Every project tagged with this tag will be synced to ~/development/2025

@chevdor

@chevdor
Copy link
Contributor

chevdor commented Jan 5, 2025

yes, for some subfolder per year, that seems to be a good option and that was indeed my exemple.
I take the trick about the tag too, I will help for the "archived" projects.

I may use it but I will likely sort also per "topic" or project and I find it too much to have a tag per project and having to move the project to the right place. I think it would be more convenient if fw could simply detect the folder's location and set the path accordingly.

Howver, I can foresee conflicts if say my ProjecXYZ is tagged as such and as well 2024. What would be the folder then ? In the end, the only right answer is that the folder is where the files actually are, not where they are supposed to be according to the tags.

@bomgar
Copy link
Member

bomgar commented Jan 5, 2025

fw import does set the override path
fw add has it as a cli arg

do you need fw move maybe?

tags have a priority.

@chevdor

@chevdor
Copy link
Contributor

chevdor commented Jan 6, 2025

fw import does set the override path, wait it does indeed !
I see that import creates a duplicate though. So indeed, a fw import --move or better fw move . that simply removes the older one would be awesome and solve the problem.

@bomgar
Copy link
Member

bomgar commented Jan 6, 2025

It will be more like fw mv <project-name> </new/path>

and fw will move the files. I already built something but i'm unsure about the move. It is only atomic if source and destination are on the same file system.

@bomgar bomgar mentioned this issue Jan 6, 2025
@bomgar
Copy link
Member

bomgar commented Jan 7, 2025

@chevdor can you try fw 2.20.0

@chevdor
Copy link
Contributor

chevdor commented Jan 7, 2025

So I just tested the following:

  • I had a project already under /p/e
  • I moved it (shell mv, not fw) to /tmp
  • fw was obvioulsly confused at that point, OK
  • i ran fw import . inside /tmp/e
  • fw was happy again
  • then fw mv /tmp/e /p/e
  • here it failed with Error running command: error User error: project key e found but path /private/tmp/e does not exist
  • from /p/e I ran another fw import and the issue was fixed.

The issue may be due to MacOS and its funky /tmp = /private/tmp per user.

@bomgar
Copy link
Member

bomgar commented Jan 7, 2025

if you already moved it you should use fw update --override-path
fw move is to move it for you.

@chevdor
Copy link
Contributor

chevdor commented Jan 7, 2025

AFAIC, with all those options, we are good regarding the topic. Thanks for the hard work @bomgar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants