-
Notifications
You must be signed in to change notification settings - Fork 45
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
Run gitdist from anywhere in repo #203
Conversation
Look at the current working directory when gitdist is executed, determine the top-level git repo in that path, and change to it before continuing. This allows gitdist to be run from anywhere in a git repository, including within a nesting of repositories. For instance, if you have a directory structure like the following metaRepo/ .git/ .gitdist repo1/ .git repo2/ .git etc. executing gitdist anywhere in that directory tree will change you to the metaRepo directory, execute gitdist, and then leave you back where you started when gitdist finishes.
This is closing but does not quite work for all use cases. It fails when there is a set of nested git repos and .gitdist[.default] files like: Trilinos/ .git/ .gitdist.default TriBITS/ .git/ .gitdist.default TriBITSDoc/ .git/ kokkos/ .git/ When I run the new gitdist in Trilinos/ or Trilinos/kokkos/, it finds the right directory to run in. But when I try to run in Trilinos/TriBITS/ or Trilinos/TriBITS/TriBITSDoc/, it always goes back to the base Trilinos/ dir. It should stop at the first directory where .gitdist or .gitdist.default is found.
I checked out the branch and it seems to have broken the usage for me. For example, the current version of gitdist shows:
But with the version on this branch, it shows:
The issue is that I use git to manage my home directory so when I run gitdist it will always just run in my home dir. I think I know how to fix this so I will give it a shot based on your branch real quick. But before we can push to TirBITS, we will need some automated tests to demonstrate and protect correct behavior. |
It may be better for me to just write a little wrapper script for my own personal use case, which is totally fine. |
But that is the problem with changing this behavior. Different people will want different behavior for different use cases. We might be able to resolve this with some system-level preferences. We might, for example, allow the definition of a If this sounds like a good idea to you, we can create a new GitHub issue for gitdist to support a P.S. the updated commit I just pushed implements the mode |
ToDo: Add documentation and automated testing.
I just pushed the commit 82822cb to your branch for this PR which causes gitdist to read an env var
(where That should skip over the Trilinos/ dir and move down to the charonMetaRepo/ dir and run gitdist from there and print the status table starting with charonMetaRepo/. If setting and env var is an acceptable solution, then I can add documentation and automated testing and push to the 'master' branch. That way, you would not need to create your own script for this behavior. Let me know if you are interested. |
If the Again, think of the use case where a user will use git to manage their home directory files (see, for example, http://www.bitflop.dk/tutorials/keeping-your-home-in-git.html). If they do that, then looking for the base most Again, let me know if you are okay with having to set |
When the GITDIST_MOVE_TO_BASE_DIR environment variable is set to IMMEDIATE_BASE, gitdist will move up the directory tree from where it's run until it finds a .gitdist[.default] file and then run from there.
@bartlettroscoe, this all sounds good to me. I also just pushed 442848e, which I think gives you the |
@jmgate, this looks great. Now I will need to add some unit testing and documentation before this gets merged to the 'master' branch. I will likely need to refactor this some to make it easier to unit test as well, but we will see. But I many not be able to get to that cleanup until later next week (unless you need this merged urgently). I think it is best to keep the default behavior not to move to the base directory since I think that should be the least surprising to people. But I suspect that once they read the documentation on this feature most users will want to set either Thanks for this great addition to the code! |
Thanks, @bartlettroscoe—no rush on my end. It'd be nice if it was available to users whenever I try to transition Charon, Drekar, and EMPIRE over to the meta-repo way of doing things, but that's still a ways out. |
Sounds good. Thanks @bartlettroscoe. |
Looks better formatted especially when using --dist-help=all. Also, moved --dist-help=move-to-base-dir above 'usage-tips' and 'script-dependencies' since I think that order seems a little better, especially for --dist-help=all. I also had to fix the tests to work when GITDIST_MOVE_TO_BASE_DIR is not set in the outer shell.
…e exists (TriBITSPub#203) Currently, this unit test just causes gitdist to hang until the overall test times out.
Look at the current working directory when
gitdist
is executed, determine the top-levelgit
repo in that path, and change to it before continuing. This allowsgitdist
to be run from anywhere in agit
repository, including within a nesting of repositories. For instance, if you have a directory structure like the followingexecuting
gitdist
anywhere down in themetaRepo
directory tree will change you to themetaRepo
directory, executegitdist
, and then leave you back where you started whengitdist
finishes.If, for whatever reason, this change is not a good idea, just let me know and I can simply write a shell script to wrap
gitdist
for my own personal use.