-
Notifications
You must be signed in to change notification settings - Fork 49
Aliases and shortcuts
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 3
lists the 3 most recent commits in the current branch. -
$ gl 3 main
lists the 3 most recent commits in your localmain
branch. -
$ gl 3 upstream/2.1
lists the 3 most recent commits in the2.1
branch of theupstream
Github 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
-L
flag in thefind
command enables a search in symlinks. -
The
-l
flag in thegrep
command prints the filenames that contain matches. -
Within the function,
$1
refers to the first argument that you passed when you ran the function.$1
refers tocon-SM-standalone-contr-ext-database.adoc
when you run the following command:$ aap-search con-SM-standalone-contr-ext-database.adoc
In the following command,
$1
refers 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>
-
Repository branch structure
-
Forking workflow
-
git cherry-pick
-
List open pull requests