It's a blog

Tag: GitHub

Delete all Github releases, using the Github cli

If you are like me, at some point while developing projects on Github you will have started and stopped using releases, opting to switch back to only creating tags.

Github defaults leave you in a bit of an awkward position here where the “Releases” section in the side bar will continue to show your old releases, even if you have made hundreds of tags since.

If you’re managing lots of repositories and have made lots of legacy releases, removing them can be a pain (particularly in the UI). So, once again, GitHub CLI to the rescue!

In the repository of your choice run the following, and all of your releases will be removed!

gh release list | awk '{print $1;}' | xargs -L1 gh release delete
Code language: JavaScript (javascript)

If you want to see them ahead of removing them, list them first.

gh release list
Code language: PHP (php)

Enjoy your time saving, and your nice clear releases list!

Github repo settings sync, using the Github cli

The number of Github repositories that I end up maintaining in one way or another ends up growing week by week. And keeping all of the descriptions and settings up to date in sync can be painful todo by hand.

A little while ago I migrated my addwiki project to use a monorepo, and thus needed to bulk update all of the github repository descriptions. While doing so I made use of the github cli and created a single bash script to let me configure all of the repositories at once.

Assuming you already have the github cli install and configured getting started with this is easy.

The command

The below command is one of many in my bash script for repo configuration. This sets a description, homepage and various other flags that I want to be consistent across repositories.

gh api --method PATCH repos/addwiki/addwiki \ --field description='Monorepo containing all addwiki libraries, packages and applications'\ --field homepage='https://addwiki.github.io/'\ --field has_issues='true'\ --field has_projects='false'\ --field has_wiki='false'
Code language: JavaScript (javascript)
Continue reading

Programmatically convert Github master branch to main

Back in 2020 Github said that the default settings for new repositories would change.

On Oct. 1, 2020, any new repositories you create will use main as the default branch, instead of master

Some blog post on Medium

Github provided some advice for renaming branches focused around how this can be done in the UI. But with the Github CLI tool that was also release at the end of 2020 you can programatically make this change too.

The Github CLI tool is called gh. The README for the tool has installation instructions for a variety of platforms. One of the commands that it enables is called api, which can be used to “Make an authenticated GitHub API request”.

The Github API obviously allows you to perform most actions that can be performed by the UI, this we can use the gh cli tool to rename the branches of repositories.

For example, for the addwiki/addwiki repository, we can rename the master to main branch using the following command:

gh api --method POST repos/addwiki/addwiki/branches/master/rename --field new_name='main'
Code language: JavaScript (javascript)

And you can use such a command in whatever loops etc you want to, to quickly rename a whole bunch of branches in a whole bunch of repositories.

You can read more on the API docs here and the api cli command here.

2020 Year Review

Another year is up, and what a year it has been. I finally open sourced wbstack, I complained about fake news, looked at Minecraft mods and took a look at how COVID-19 was affecting Wikipedia page views.

I make this post mainly for me to be able to look back at each year in a small snapshot. You can find similar posts for previous years in 2019, 2018 and 2017.

Currently I generate this post in a very manual way, sifting through data from WordPress stats, Twitter Analytics and my Github user page. Maybe I should change that for next year!

Blogging

On the whole this blog continues to grow year on year, both in terms of content and readers.

Continue reading

Open Sourcing WBStack

wbstack organization on Github

Open Sourcing the code and config for WBStack has always been part of the plan, although functionality came first throughout the first year or so. Finally there is a github organization for wbstack containing 16 public repositories that make up the entire deployment for wbstack.com.

This effort took a few weeks trying to split sensible components out of the original mono repo that was started back in 2017 that now has over 1600 commits, making sure that no secrets were swept up along the way, and also trying to preserve git history where possible.

Although everything is now on Github that doesn’t mean that it is clearly understandable just yet, or in the most sensible layout, that will come with time.

Continue reading

gitgraph.js and codepen.io for git visualization

I was looking for a new tool for easily visualizing git branches and workflows to try and visually show how Gerrit works (in terms of git basics) to clear up some confusions. I spent a short while reading stackoverflow, although most of the suggestions weren’t really any good as I didn’t want to visualize a real repository, but a fake set of hypothetical branches and commits.

I was suggested Graphviz by a friend, and quickly found webgraphviz.com which was going in the right direction, but this would require me to learn how to write DOT graph files.

Eventually I found gitgraph.js, which is a small JavaScript library for visualizing branching ‘things’, such as git, well, mainly git, hence the name and produce graphics such as the one below.

Continue reading

Github release download count – Chrome Extension

The Github IconGitHub tracks the number of downloads for all assets (files) that are attached to a release, but GitHub currently makes it very hard for users to get at this information. The number of downloads is currently only accessible through the API.

I noticed this many months ago when wondering how many people were downloading the new C++ version of Huggle. At the time I started coming up with some odd little script that I could set running somewhere checking the download counts and updating a static list, I even thought about just uploading the build files to some other site that tracked this information.

A few days ago I took my first look at developing chrome extensions for a referencing tool for Wikidata, and thus today I thought, why not just make an extension for chrome that adds the download counts to the GitHub releases page!

Continue reading

© 2021 Addshore

Theme by Anders NorénUp ↑