Auto-initializing vcsh remotes
I've now for a long time (6 years it seems) happily used the vcsh script, originally scraped from madduck's zsh setup to manage my configuration files. You can read more about this and other approaches of managing configuration files at the vcs-home website.
To simplify the task of creating a new repository, I wrote, back in those days, a little companion script, which initializes a new repository and sets up the remote based on a command line parameters. As it happens, in the 6 years since, the idea behind the vcsh script has been turned into a featureful tool, packaged for Debian, so I now put my script into the dustbin and made the switch.
However, automatically setting up the remote for newly-created repositories seemed not to be part of the core functionality of vcsh. After studying the man page for a bit, I was delighted to see vcsh came with a flexible hook system. It didn't take me long to come up with a post-init hook, that added that functionality and now even initializes the remote repository. In case you can make use of that functionality yourself, I'll shortly explain the configuration settings relevant to the hook:
export VCSH_GITURL=<your-host>:<your-directory>
The setting VCSH_GITURL
specifies the base directory on the remote
host, below which all of your vcsh git repositories reside. This needs
to be a "URL" as understood by by git remote
, and will be extended
with the name of the vcsh repository being initialized. If set, the
hook will use this setting to configure the git remote you'll push
your vcsh repository to.
export VCSH_GITHOST=<your-hostname>
VCSH_GITHOST
keeps the name of an host reachable via SSH, and will
ususally be the host part of VCSH_GITURL
.
export VCSH_GITHOST_DIRECTORY=<your-directory>
The directory on VCSH_GITHOST
that will keep all of your vcsh git
repositories. Usually, this will be the directory part of
VCSH_GITURL
. If both VCSH_GITHOST
and VCSH_GITHOST_DIRECTORY
are
set, the hook will create a bare git repository on VCSH_GITHOST
below VCSH_GITHOST_DIRECTORY
.
export VCSH_GITHOST_DESCRIPTION="My \$VCSH_DIRECTORY configuration"
When a new repository is created according to VCSH_GITHOST
and
VCSH_GITHOST_DIRECTORY
, this setting will be used for generating the
description for the newly-created repository. The contents of the file
description
inside the bare repository is used by
e.g. cgit to display a
human-readable blurb for the git repository. Note that the contents of
VCSH_GITHOST_DESCRIPTION
is eval
-d by the shell as if it had been
enclosed in double quotes, so you can use it as simple template,
evaluating other environment variables, as shown above.