Initialize Git repository on creation #380
Replies: 7 comments
-
This is a cool idea. Two potential concerns here:
I'm inclined to give this a discussion label for a while and see if people feel strongly. |
Beta Was this translation helpful? Give feedback.
-
That all makes total sense. I think you're right, it's wrong to assume everyone is going to use Git. It might be nice to give users a choice of which VCS they want to use (or do nothing if no input is provied) and then roll from there. That removes the Git-centricity at the cost of having to handle at least some of the more common options (Git, Mercurial, Subversion, etc.). To address the platform compatibility issue, we could add some exception handling for missing installations: # Bad pseudocode
try:
setup_vcs(vcs)
except ExceptionThatNeedsToBeHandled:
print('{0} binary not found. Is {0} installed?'.format(vcs)) What do you think? |
Beta Was this translation helpful? Give feedback.
-
For those interested, I'm doing this in my fork of the cookiecutter with the following bash script I then added a command to the Makefile:
|
Beta Was this translation helpful? Give feedback.
-
Nice, I like it @ConstantinoSchillebeeckx! @isms What do you think about a plug-and-play way to initialize a version control system? |
Beta Was this translation helpful? Give feedback.
-
@mattayes Cool idea - what do you think an implementation might look like? |
Beta Was this translation helpful? Give feedback.
-
Also, just a note here, I've been holding off on optional features while I watch: Unfortunately, that issue is currently stalled because the cookiecutter project needs sponsorship. For things like VCS where we want options and may have fields that are conditional on your choice, it's pretty tough to manage with the current cookiecutter workflow, which doesn't really do branching. I was hoping that the PR referenced above would get pulled in for these kinds of features, but that's not super likely. The one thing we could look at is doing is conditional files using this kind of syntax: We'd need to map out the files that would conditionally added if you chose |
Beta Was this translation helpful? Give feedback.
-
Thanks @pjbull for the context. It's too bad cookiecutter/cookiecutter#848 is held up. My thought is we provide a general API: class VCS(object):
...
def initialize(self):
<creates the repo> Then a (very rough) Git implementation: import git
class GitVCS(VCS):
def initialize(self, dir):
r = git.Repo.init(repo_dir)
<potentially add initial commit> We would ask folks which VCS they want (if any), then run the appropriate VCS subclass. |
Beta Was this translation helpful? Give feedback.
-
Could we add a post-generate hook to run
git init
after repository creation? It's not a make-or-break, just a nice convenience.Beta Was this translation helpful? Give feedback.
All reactions