I have a project in which I need to access a (local) directory of bare git repositories in order to get specific items from their history. I need a function which will iterate through the directory and do something like:
repo = pygit2.discover_repository("/path/to/repo")
but I need to be able to do this in a for
loop.
Each of the repositories is for a different project, the names of which are located and stored in a list through the use of some nested loops elsewhere in my code.
1) Does it make sense to use the project names in place of repo
above if I will only be referencing the project names based on their list index throughout my code (or should I instead give each repo a name like repo_n
where n is an integer that gets incremented in each iteration of the loop that discovers the repos)?
2) Is it possible to discover these repos in a for
loop so that I can get them all in one go, or will I need to do them one by one?
3) If it is possible to do this in a loop, how can I go about creating a tuple (or maybe a dictionary) that contains the project name and the newly discovered repository object?