I'm writing a script for a build script to support both SVN and Git hosted projects. It would be convenient if there is no manual settings for the projects to know which repository type it is.
The build script will be run on a fixed set of build servers, and it will do a clean checkout for each build, or do an update in continuous build mode. Before checking out the repository and doing any pre-build events such as download (or export
) a package from a repository, an repository identification step will be proceeded over the repo's URL. Based on the result, a concrete repo wrapper object will be instanced and pass on. The rest part of the build script will use the abstract interface of the repo wrapper to do the repo related job, e.g. checkout, export, get latest revision number, update, check if remote has update.
To identify a repo, I will try a list of known repo, each with a identify
function to test the repo's URL.
For a SVN repo, for example, I could use svn info --non-interactive --trust-server-cert https://path/to/repo
and check the exit code. It works as expected.
If its failed to detect as a SVN repo, I'll then try with git ls-remote https://path/to/repo
but there seems no similar options to disable user interactive when the repo has no saved credential available.
When SVN server is unreachable, it will try detecting whether a SVN repo is a Git repo, and it pops up the credential window and blocks the build script.
I could do something like checking the name of the repo for some special keywords before calling the git commands. But I think there might be better solutions already.
edit:
I think I got a workaround now:
- Switch to a user different credential helper, for example
store
ormanager
on windows and setgit config --global credential.interactive never
to prevent the pop up dialog box. And, - Pass linefeed through pipe to the command line
git ls-remote https://path/to/repo
to skip the prompted username and password.
This works for my case, I'll keep this question for better solutions though.