mirror of
https://github.com/initialcommit-com/git-sim.git
synced 2026-04-26 19:15:51 +03:00
[GH-ISSUE #62] Add git-dummy as a dependency to git-sim #43
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/git-sim#43
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @initialcommit-io on GitHub (Feb 16, 2023).
Original GitHub issue: https://github.com/initialcommit-com/git-sim/issues/62
Originally assigned to: @initialcommit-io on GitHub.
I want to add git-dummy as a dependency for Git-Sim so that we can add a
--generateflag to enable the creation of a dummy Git repo to run the simulation on with a single command, something like this:I set this up locally by updating the
setup.pyto add thegit-dummypackage intoinstall_requires, and also added a new entry point for it so that it can be called as a subprocess:I added some code into main to call git-dummy to create the new repo when the
--generateflag is set:This works, but I wonder if we can clean it up so we don't need a separate
git-dummyendpoint and can just call methods within the git-dummy package. This would also avoid the need to callsubprocess.Also, I wonder if there is a nifty way to handle the git-dummy command line arguments, like
--branches, --commit, --diverge-atwithout redefining them in Git-Sim.@paketb0te Any thoughts on this?
@paketb0te commented on GitHub (Feb 17, 2023):
Just to clarify: We do NOT want to use git-dummy as a subcommand for git-sim (which would look something like
git-sim generate --branches 3 --diverge-at 2), but rather use it as a flag / option to other git-sim commands, likegit-sim --generate --branches 3 --diverge-at 2 log, correct?The first would be very easy, just import the typer app from git-dummy and add it to the git-sim typer app like this:
And if there are at some point more sub-commands in git-dummy, then we could also switch to import not the single command but the whole typer app from git_dummy.
For the second option, we can still import the function from git-dummy and execute it when
--generateis set:but I'm not sure if / how we can avoid re-declaring the options for git-dummy 🤔
@initialcommit-io I'm not sure I understand why we want
--generateas an option to the other commands, could you expand a bit on that?What is the main usecase?
I assume one would typically run only a single command with the
--generateflag, because there is no need to re-create it each time for subsequent git-sim commands.In that case I think it would be easier just to make it a separate command (like
git-sim generate, as shown in my first example).Do you have a different usecase in mind?
@initialcommit-io commented on GitHub (Feb 17, 2023):
@paketb0te Thanks for the details! And good question. The reason I was thinking we would use an option like
--generateas a global Git-Sim option was in the spirit of being able to do everything in a single command. So the use case is that the user could generate a dummy repo specifically to run 1 git-sim command against it, and run the git-sim command all in 1 step. So something like:This would allow the generation of the dummy repo ready to simulate a merge on, and simulate the merge as well with a single command. Another (smaller) reason is that theoretically, each git-sim subcommand should correlate to a Git subcommand. It might be confusing to some users if "generate" is a git-sim subcommand but not a Git subcommand. That's why I thought it might work better as a global option to Git-Sim instead of a subcommand.
However, having a separate
git-sim generate ...subcommand would be a lot cleaner and more maintainable like you said. The user could do something like this if they wanted to do it all in one line:But if that's the case, then why wouldn't they just use git-dummy itself? Like this:
So in that case maybe it doesn't make sense to add git-dummy into Git-Sim... Aside from the fact that Git-Sim already has a good following of users, so more people would likely become aware of the feature if we add it into Git-Sim than if we just leave it as a separate git-dummy project.
Maybe the answer is to add git-dummy into git-sim as a dependency with an entry point so it gets installed along with git-sim, and add a section in the README for how to use it alongside Git-Sim and chain the commands together like in the example above if desired. That way we don't need to worry about maintaining the extra options in sync or adding a non-Git subcommand. And we also get the benefit of all the eyeballs on Git-Sim being aware of the generation feature.
Thoughts?
@paketb0te commented on GitHub (Feb 17, 2023):
@initialcommit-io agree on all your points.
Random thought: If we keep it as a command in git-sim, we could call it
initinstead of generate to have it match an actual git command 😄But I'm not sure if it's a good idea, seeing that it would not simulate
git init, but actually create a git repo.On that note, we should probably make sure that we don't accidentally overwrite an existing git repo (I assume that the
gitmodule throws an error in that case, but we should be extra careful there to not accidentally destroy someone's repo 😅)@initialcommit-io commented on GitHub (Feb 17, 2023):
@paketb0te Ha yes I guess it kind of is like
git init... But yes you're right that we should probably just stick to simulating instead of doing.And yes I was thinking about that for git-dummy - I will put in some explicit logic into git-dummy to stop execution and log an error if the user is already inside an existing Git repo, so it doesn't try to create a new one in that folder, or in a subdirectory.
@initialcommit-io commented on GitHub (Feb 21, 2023):
Added git-dummy as a dependency as a part of v0.2.5