Fryboyter

Clone all repositories of a user at Github

Sometimes you want to clone all of a user’s repositories on Github onto your own computer. Depending on the number of repositories, this can be a bit time-consuming to download each one manually with “git clone”. To automate this you can use the following script. For example, let’s call the script gitdownload.sh.

#!/bin/bash

if [ $# -eq 0 ]
  then
    echo "Usage: $0 <user_name> "
    exit;
fi

USER=$1

for repo in $(curl -s https://api.github.com/users/"$USER"/repos?per_page=1000 |grep git_url |awk '{print $2}'| sed 's/"\(.*\)",/\1/');do
git clone "$repo";
done;

To download the repositories in question, simply run ./gitdownload.sh $username. Instead of $username, enter the name of the user at Github.

General

Find active fork on Github

From time to time I like to use sshfs to mount a directory locally via SSH. However, the development of the project was stopped a few months ago. Today I wanted to see if there is an actively developed fork of sshfs.

Unfortunately, this is not so easy, at least directly via github.com. Via https://github.com/libfuse/sshfs/network/members you can view the forks but they are sorted alphabetically. Because there are currently 403 forks of sshfs on github, it could take a while to find the most current fork. Or you can use https://techgaun.github.io/active-forks/index.html. There you only have to enter the address of the project (e.g. https://github.com/libfuse/sshfs) and you will get a list of forks sorted by activity. With the button “Add Condition” you can customize the search query according to your needs.

Of course, it would be better if you could sort the list directly at Github. However, Codeberg.org, which is based on Gitea, is no better in this respect and also only offers the alphabetically sorted list.

General

Use Github with Mercurial

A week or two ago I broke one of my git repositories. Because the solution cost me a lot of time, too many nerves and two commits, I have now returned to Mercurial. This tool may not be as powerful as Git, but the error messages and documentation are much easier to understand in my opinion.

However, I still want to use Github because of its widespread use. Be it to publish something there myself or to participate in third-party projects. Mercurial offers a plugin called Hg-Git for this purpose. With it, you can download a Git repository and it is automatically converted into a Mercurial repository locally. If you now make changes, they are then changed to be compatible with Git before being uploaded to a Git repository. Setting up Hg-Git is also quite simple.

For the following instructions, I assume that both Mercurial and python-dulwich are installed on the computer and that the directory Projects exists in the home directory. Of course, you can give the directory a different name.

First, change to the Projects directory in the terminal emulator of your choice and download the Hg-Git files there.

cd ~/Projects
hg clone https://foss.heptapod.net/mercurial/hg-git hg-git

Alternatively, you can install Hg-Git via the package management of your distribution.

Next, add the following content to the .hgrc file in the home directory. If the file does not yet exist, simply create it and enter the three lines.

[extensions]
hgext.bookmarks =
hggit = ~/Projects/hg-git/hggit

Line two activates the plugin Bookmarks, which in this case simulates branches. Line three activates the Hg-Git plugin that we just downloaded.

In the Projects directory, we now download a Git repository with the following command (please adapt the Github address and the target directory fryboyter.git to your own circumstances).

hg clone git@github.com:Fryboyter/Hugo.git fryboyter.hg

Because this converts from Git to Merurial, it may take some time depending on the size of the repository.

Next, change to the directory in which the Mercurial repository now created is located. In this example, this is fryboyter.hg. Finally, execute the command hg bookmark -f main there. Instead of main, you must enter the name of the main branch. Otherwise Mercurial will not recognise any changes during a push.

Now everything should work. In my tests, I was able to pull from Github and push to Github without any problems. That’s all I really need in my case. What I noticed during the whole process is that the local Mercurial repository is less than 30 MB in size. The local Git repository, on the other hand, takes up a bit more than 60 MB of space. That’s not the end of the world, but it’s still an interesting detail.

OSBN | General