Aliases and shortcuts - RedHatInsights/red-hat-ansible-automation-platform-documentation GitHub Wiki
When you are backporting commits or syncing release branches, you will check the git log frequently.
For convenience, create an alias for this command. Add the following line to your ~/.zshrc (mac) or ~/.bashrc (Linux) file:
alias gl='git log --oneline -n $1'
Run source ~/.zshrc or source ~/.bashrc afterwards, to get the alias working.
To use this alias, specify the number of commits you would like to view:
$ gl <number_of_commits> [<branch-name]
For example:
-
$ gl 3lists the 3 most recent commits in the current branch. -
$ gl 3 mainlists the 3 most recent commits in your localmainbranch. -
$ gl 3 upstream/2.1lists the 3 most recent commits in the2.1branch of theupstreamGithub repo.
Add the following lines to your ~/.bashrc or ~/.zshrc file:
# aap-search function lists the names of assemblies where a module is used.
# in /titles dir, run aap-search <module_name>.adoc
# Alternatively, run it in /assemblies dir to list assemblies where a module is used.
# Run it from the command line as follows:
# aap-search <module_name.adoc>
# You can also run this in /titles to list where assemblies are used
# aap-search <assembly_name.adoc>
aap-search() { find -L . -name "*.adoc" -exec grep -l "$1" {} + ; }
The only necessary line is the one that is not a comment. However, it is useful to include the instructions with the function.
Run source ~/.zshrc or source ~/.bashrc after you save and quit the file.
The following example calls the aap-search function to list the assemblies in the Installation guide that include con-SM-standalone-contr-ext-database.adoc:
➜ git:(main) ~~/titles/aap-installation-guide/~~ $ aap-search con-SM-standalone-contr-ext-database.adoc ./platform/assembly-planning-installation.adoc
Running the same command from the /titles directory shows all the titles that include assemblies that include the module. There is some duplication here, as several titles include same assembly. The output is useful, however, as it shows which titles are affected.
➜ git:(main) ~~/downstream/titles/~~ $ aap-search con-SM-standalone-contr-ext-database.adoc ./upgrade/platform/assembly-planning-installation.adoc ./aap-operator-installation/platform/assembly-planning-installation.adoc ./aap-installation-guide/platform/assembly-planning-installation.adoc ./automation-mesh/platform/assembly-planning-installation.adoc ./catalog/onboarding/assemblies/platform/assembly-planning-installation.adoc
-
The
-Lflag in thefindcommand enables a search in symlinks. -
The
-lflag in thegrepcommand prints the filenames that contain matches. -
Within the function,
$1refers to the first argument that you passed when you ran the function.$1refers tocon-SM-standalone-contr-ext-database.adocwhen you run the following command:$ aap-search con-SM-standalone-contr-ext-database.adoc
In the following command,
$1refers toassembly-planning-installation.adoc:$ aap-search assembly-planning-installation.adoc
Add the following lines to your ~/.bashrc or ~/.zshrc file:
alias aap-titles="grep -r '<title' --include 'docinfo.xml' "
Once you have added this line, save and close the file, then run source ~/.zshrc or source ~/.bashrc.
To use this alias, navigate to the top-level directory of your local repo and execute aap-titles.
The following example output shows some of the titles in the AAP repo:
$ aap-titles ./release-notes/docinfo.xml:<title>Red Hat Ansible Automation Platform Release Notes</title> ./downstream/titles/upgrade/docinfo.xml:<title>Red Hat Ansible Automation Platform Upgrade and Migration Guide</title> ./downstream/titles/hub/uploading-internal-collections/docinfo.xml:<title>Curating collections using namespaces in Automation Hub</title> ./downstream/titles/hub/configuring-private-hub-rh-certified/docinfo.xml:<title>Managing Red Hat Certified and Ansible Galaxy collections in Automation Hub</title>