Git Command Line Snippets: Get Release Information

GitHubThis post is part of the series on Git Command Line Snippets where I am taking a look at performing actions on GitHub using the git command line.

In the last post, of this series, I covered the command to create a release and mentioned that uploading a release zip (extra asset) had to be handled separately. While the command to do this isn’t too complex, there is one problem; to upload the asset you need the tag d of the release. This is not the tag that you supply to create the release with, but the internal GitHub id which is automatically assigned.

The command below can be used to get the release information, in the form of json, which includes the tag id:

curl -H "Accept: application/vnd.github+json" -H "Authorization: token ghp_authorizationtoken" https://api.github.com/repos/username/repository name/releases/tags/required tag

Git Command Line Snippets: Create Release

GitHubThis post is part of the series on Git Command Line Snippets where I am taking a look at performing actions on GitHub using the git command line.

Once changes have been added, committed and pushed to the repository, we can create a release.

When developing for ClassicPress, there is also a need to upload a release zip which is used for deployment to a ClassicPress site. Unfortunately, this cannot be done while creating a release; this post is just on creating the release and a later post will cover uploading the release zip.

The following command can be used to create a release using command line:

curl -X POST -H "Accept: application/vnd.github+json" -H "Authorization: token ghp_authorizationtoken" https://api.github.com/repos/username/repository name/releases -d "{\"tag_name\":\"tagname\",\"target_commitish\":\"main\",\"name\":\"name\",\"body\":\"release comment\",\"draft\":false,\"prerelease\":false,\"generate_release_notes\":false}"

The highlighted sections need to be replaced with the parameters for your GitHub account and repo.

Git Command Line Snippets: Choose Repository

GitHubThis post is part of the series on Git Command Line Snippets where I am taking a look at performing actions on GitHub using the git command line.

I am new to working with the git command line so have spent a bit of time reading articles. One thing a lot of them say is to “choose your repository” and then tell you to run commands. When I was doing this it was a bit late and I’d been working all day (getting my excuse in early), but I didn’t immediately understand what they meant.

All it means when they say to choose your repository, is to navigate the command prompt to the repository folder on your computer.

In command line you can simply use cd followed by the path: to navigate to the required folder

cd C:\Users\azurecurve\Documents\Development\ClassicPress Development\azrcrv-smtp

In PowerShell you can largely do the same thing but must wrap the path in double quotes if the path contains a space:

cd "C:\Users\azurecurve\Documents\Development\ClassicPress Development\azrcrv-smtp"

Git Command Line Snippets: Update Name and Email

GitHubThis post is part of the series on Git Command Line Snippets where I am taking a look at performing actions on GitHub using the git command line.

Before you start using Git you need to enter your credentials to identify yourself as the author. The name and email address should both be set to the same as the ones you use in GitHub.

To set your username you can use this command:

git config --global user.name "azurecurve"

To set your email address you can use this command:

git config --global user.email "github@example.co.uk"

Git Command Line Snippets: Series Index

GitHubBack in April 2020, I did a series on using GitHub when developing for ClassicPress. More recently I have started to take a look at using the git command line to help automate making commits, releases and other actions. I’ m going to use this git snippets series to record the commands I have been using.

You can use an ordinary Windows command prompt or PowerShell to run git commands; I started out using command line, but did move onto running them in PowerShell as soon as I wanted to run commands sequentially.

If you’re reading this post on azurecurve | Ramblings of an IT Professional, then the post will automatically refresh otherwise check Git Command Line Snippets for new posts.

Continue reading “Git Command Line Snippets: Series Index”

MySQL Snippets: Update Statement

MySQL LogoThis post is part of the series on MySQL Snippets.

The following MySQL snippet shows an example UPDATE statement for MySQL; I’m posting this as I have trouble remembering that the order of the MySQL statement is different to that of Microsoft SQL Server; in MySQL the SET clause comes after the JOIN clause, whereas in Microsoft SQL Server, with which I am more experienced, the order is reversed.

/*
Created by Ian Grieve of azurecurve | Ramblings of an IT Professional (http://www.azurecurve.co.uk) This code is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0 Int). */
UPDATE bct_custom_fieldnotes AS cfn INNER JOIN bct_custom_fields AS cf ON cf.TableName = cfn.TargetTableName SET cfn.TargetDBTableName = cf.DBTableName WHERE cf.TableName <> cfn.TargetTableName;

MySQL Snippets: Series Index

MySQL LogoThis post is part of the series on MySQL Snippets.

Like the other …Snippets series, this one may not get many posts as I’ll be using it to record things I need to remember. In thie series, I’ll be posting MySQL snippets; usually ones which highlight a difference between the MySQL and Microsoft SQL query syntax.

MySQL Snippets
Update Statement

PHP Snippets: If Statements

PHPThis post is part of the PHP Snippets series where I will be covering the basics of developing in PHP.

One of the most basic statemnts you’ll use in PHP is the if statement which is used for conditional statements which perform different actions.

The most basic form is the basic if itself which executes when one condition is true:

$time = date( "H" );

if ( $time < 12 ){
	echo "Good morning.";
}

This can be extended to supply a value if the original condition fails using an if...else:

$time = date( "H" );

if ( $time < 12 ){
	echo "Good morning.";
else
	echo "Hello."
}

And can be expanded further to check if one of multiple conditions is true using an if...elseif...else:

$time = date( "H" );

if ( $time < 12 ){
	echo "Good morning.";
}elseif ( $time < 18 ){
	echo "Good afternoon."
}else{
	echo "Good evening.";
}

PHP Snippets: Sprintf

PHPThis post is part of the PHP Snippets series where I will be covering the basics of developing in PHP.

The sprintf function provides the same functionality as the printf function, but silently.

This means you would either need to echo the output or concatenate it with a string and echo that string.

$number = 500;
$string = 'miles';

echo sprintf( 'But I would walk %d %s', $number, $string );

PHP Snippets: Printf

PHPThis post is part of the PHP Snippets series where I will be covering the basics of developing in PHP.

The printf function is similar to the echo function in that it will output text, but differs in that it outputs a formatted string.

The syntax of the printf function is:

printf( string, arg 1, arg 2, ... )

Multiple arguments can be provided to the function for each of the placeholders to be replaced.

Continue reading “PHP Snippets: Printf”