Skip to content

Bash script that adds Git Version Control information into files and pushes them to GitHub, Bitbucket, or GitLab (Supported files: Bash, Go, Dockerfile, YAML, Makefile, Scala, Python, Java, PHP, C, C++, JavaScript, perl, ruby, PowerShell, Ri, . . .)

License

Notifications You must be signed in to change notification settings

BradleyA/markit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

markit

GitHub Stable Release GitHub Release Date GitHub Commits Since GitHub Last Commits

Open GitHub Issue GitHub Open Issues GitHub Closed Issues GitHub pull requests GitHub pull requests

GitHub Repo Clones GitHub Repo Views GitHub Size Language Bash MIT License

Goal

Answer one question over the phone by looking at the code; *What version are you running?

If you like this repository, select in the upper-right corner, GitHub stars, thank you.

Table of content



Description

Bash script that adds Git Verion Control information into files and git add, git commit, git pushes them to GitHub, Bitbucket, and/or GitLab. Most scripts in this repository support --help and --usage options.

Markit is a bash script that is a wrapper around these Git commands; git add ${FILE_NAME}, git commit -m "${FILE_MESSAGE}", git tag -a ${RELEASE_VERSION}, and git push --follow-tags. It automates this Git commit process and adds two comment lines of metadata about file changes to all tracked modified files in your local Git repository. This metadata allows any person to answer the question; What version are you running?

Markit supports Semantic Versioning (MAJOR.MINOR.PATCH) and alphanumeric versioning (1.2.5-beta.1). Markit will display the current version before prompting you to enter the next version. Markit includes the number of commits with the version in the file(s). I find this helpful when commiting several different changes while working on the same PATCH.

If environment variable MARKITLOCAL is set to 1, markit automates this git commit process, but does not push to GitHub repository or Bitbucket repository or GitLab project. I find this helpful when working without network access to a remote Git repository. If using the bash shell, enter; 'export MARKITLOCAL=1' on the command line to set the MARKITLOCAL environment variable to '1'. Use the command, 'unset MARKITLOCAL' to remove the exported information from the MARKITLOCAL environment variable. You are on your own defining environment variables if you are using other shells.

The two comment lines of metadata include:

  • file_name, version.commits, date, time, time zone, repository URL, Git branch, user, hostname, previous version
  • file name(s) updated and a one line breif description about changes made to the file(s)

Markit currently supports files with these file extensions:

c(c), C++(cc|cpp|c++|cxx), C header(h|H|hpp), C++ header(hxx|Hxx|HXX), Go(go), HTML(html|htm), Java(java|class|jar), JavaScript(js), Kotlin(kt|kts), Makefile(mk|MK), Pascal(p|pp|paa), Perl(pl|PL|psh), PHP(php|php3|php4|ph3|ph4), PowerShell(ps1|msh), Python(py), R(R), Ruby(rb), Rust(rs|rlib), Scala(scala|sc), Shell(sh|bash|csh|tcsh|ksh), Terraform(tf|tfstate), Text(txt), XML(xml), YAML(yml|yaml)

Markit currently supports these files without file extensions: Dockerfile, Makefile. There will be a prompt to add comment character(s) for unknown file names when needed and a prompt to add a description about the changes.

Return to top

Objectives

  • Any person without knowledge of Git or GitHub or Bitbucket or GitLab or markit to be able to answer one question; What version are you running?
  • Supports Semantic Versioning (MAJOR.MINOR.PATCH) and alphanumeric versioning (v0.1.64-alpha)
  • Only update modified files by inserting two comment lines with metadata
  • Insert the lines of metadata after the first line in files
  • Support GitHub
  • Use git commit message as part of metadata
  • Use git tag as part of metadata
  • Include date and remote Git repository as part of metadata
  • Include path with filename in remote Git repository as part of metadata
  • Don't create any requirements for markit other than the version and those required by Git
  • Support several file extensions for comment character
  • Support Bitbucket and GitLab
  • Support Git local repository without network access (without 'git push')
  • Support push to multiple Git remote repositories at once (edit .git/config)
  • I use alias release-notes='git log --graph --pretty=format:'''%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset''' --abbrev-commit' to help build release notes

Return to top

Quick Start Tutorials

  1. First make a copy of or fork this GitHub repository so you can modify the test files while learning how simple it is to work with markit.
  1. Second download or clone the forked copy of markit from your GitHub <YOUR-USERNAME>/markit to your Linux system.
  • Enter the following command with the name of your repository,

    git clone https://github.com/<YOUR-USERNAME>/markit.git
    
  • Change into the cloned directory on your Linux system.

    cd markit
    
  1. Third make a change to the file, testfiles/sample.sh, then git tag, git commit, and git push the change to your local and remote GitHub repository.
  • Make any change to testfiles/sample.sh.

    vi testfiles/sample.sh
    
  • Run ./markit and enter the next version number when prompted and a brief description of the changes to testfiles/sample.sh. You will be prompted for your GitHub password when Git pushes testfiles/sample.sh to your remote GitHub repository.

    ./markit

That is it!

Check if your local version of testfiles/sample.sh is the same version that is on your remote Git repository.

./check-markit -f ./testfiles/sample.sh

On GitHub go to your Forked markit repository settings page and check the box next to Issues. Then open the first GitHub issue on your forked markit Git repository, #1.

Modify test file, testfiles/sample.sh, by adding a blank line to learn how markit works.

vi testfiles/sample.sh

#!/bin/bash
#   testfiles/sample.sh  3.197.368  2019-02-08T20:33:53.600661-06:00 (CST)  https://github.com/BradleyA/markit  uadmin  six-rpi3b.cptx86.com 3.196-1-g46f4c0d  
#      test markit for sample.sh 
#
#   ./sample.sh
###

echo "Hello World"

Run ./markit. Enter the next version number when prompted and this brief description 'testing markit issue changes close #1'. You will be prompted for your GitHub password when git pushes testfiles/sample.sh to your remote forked markit Git repository.

./markit

The file testfiles/sample.sh has been updated with metadata, git tag, git commit, git push, and the issue #1 on GitHub has been closed.

View ./markit help pages to learn more about how markit works with tracked and untracked files and without network access to remote Git repository.

./markit --help

Continue testing with the other test files to help you integrate markit with your development solutions. Open a GitHub issue and then modify two test files. When running markit enter a message and include the GitHub issue number and GitHub will update the issue.

If you like this repository, select in the upper-right corner, GitHub stars, thank you.

Return to top

Clone

To Install, change into a directory that you want to download the scripts. Use git to pull or clone these scripts into the directory. If you do not have Git installed then enter; "sudo apt-get install git" if using Debian/Ubuntu. Other Linux distribution install methods can be found here: https://git-scm.com/download/linux. On the GitHub page of this script use the "HTTPS clone URL" with the 'git clone' command.

git clone https://github.com/BradleyA/markit
cd markit

Copy markit, check-markit, and find-code.sh to a directory that is included in your PATH (/usr/local/bin or ~/bin).

cp -p {./markit,./check-markit,./find-code.sh} /usr/local/bin

Return to top

Install latest markit command

To install the latest commit of markit, change to the directory you want to download the script to (cd /usr/local/bin) and enter the follow command.

curl -L https://api.github.com/repos/BradleyA/markit/tarball | tar -xzf - --wildcards BradleyA-markit-*/markit ; mv BradleyA-markit-*/markit . ; rm -r BradleyA-markit-*

To install the latest commit of check-markit, change markit to check-markit in the above command.

Return to top

Usage: markit

Mark tracked modified file(s), in your local Git repository and push those changes to a remote Git repository. This example shows markit pushing to three remote Git repositories; GitHub, GitLab, and Bitbucket. Enter markit --help to see how .git/config was edited to support three repositories.

markit 

Return to top

Output: markit

Note: The above markit output includes the output from git-TEST-commit-automation solution.

Return to top

Usage: check-markit

Check the release version of a file with the remote Git repository release version. The check-markit script allows you to check if there is a newer release version of a file. The following example uses the file 'markit', but can be used with any file that was marked with markit.

check-markit markit 

Return to top

Output: check-markit

Return to top

Usage: find-code.sh

Search each system found in <DATA_DIR>//<SYSTEMS_FILE> file for .git repositories in ~/.. directories.

find-code.sh

Return to top

Output: find-code.sh

2020-10-19T08:52:23.693833-05:00 (CDT) six-rpi3b.cptx86.com find-code.sh[8972] 4.1.10.856 169 uadmin 10000:10000 [INFO]    Started...

  -->  five-rpi3b.cptx86.com    ->find ~/.. 2>/dev/null -type d -name '.git' -print | sed 's/^.*\.\./   \~/' | sed 's/\/\.git//'<-
 # #####   All connections monitored   ##### #
   ~/uadmin/github/BradleyA/Linux-admin
   ~/uadmin/github/BradleyA/docker-security-infrastructure
   ~/uadmin/github/BradleyA/git-TEST-commit-automation
   ~/uadmin/github/BradleyA/pi-display
   ~/uadmin/github/BradleyA/markit
   ~/uadmin/github/BradleyA/git-TEST-commit
   ~/uadmin/github/BradleyA/Search-docker-registry-v2-script
   ~/uadmin/github/BradleyA/user-files
   ~/uadmin/github/animated-GIF/ttygif
   ~/uadmin/github/animated-GIF/ttyrec
   ~/uadmin/github/animated-GIF/gifsicle
   ~/uadmin/github/animated-GIF/giflossy
   ~/uadmin/temp/temp/docker-security-infrastructure
Connection to five-rpi3b.cptx86.com closed.

  -->  six-rpi3b.cptx86.com    ->find ~/.. 2>/dev/null -type d -name '.git' -print | sed 's/^.*\.\./   \~/' | sed 's/\/\.git//'<-
   ~/uadmin/github/animated-GIF/ttygif
   ~/uadmin/github/animated-GIF/ttyrec
   ~/uadmin/github/animated-GIF/gifsicle
   ~/uadmin/github/animated-GIF/giflossy
   ~/uadmin/github/franiglesias/versiontag
   ~/bob/github/BradleyA/pi-display
2020-10-19T08:52:24.919012-05:00 (CDT) six-rpi3b.cptx86.com find-code.sh[8972] 4.1.10.856 230 uadmin 10000:10000 [INFO]    Operation finished...

Return to top


Contribute

Please do contribute! Issues, comments, and pull requests are welcome. Thank you for your help improving software.

Return to top

Author

Follow @bradleyaustintx GitHub followers

Return to top

Stars

Stargazers repo roster for @BradleyA/markit

Return to top

Forks

Forkers repo roster for @BradleyA/markit

Return to top

Tested OS

  • Ubuntu 14.04.6 LTS (amd64,armv7l)
  • Ubuntu 16.04.7 LTS (amd64,armv7l)
  • Ubuntu 18.04.5 LTS (amd64,armv7l)
  • Raspbian GNU/Linux 10 (buster)

Return to top

Design Principles

  • Have a simple setup process and a minimal learning curve
  • Be usable as non-root
  • Be easy to install and configure

Return to top

License

MIT License

Copyright (c) 2020 Bradley Allen

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Return to top

About

Bash script that adds Git Version Control information into files and pushes them to GitHub, Bitbucket, or GitLab (Supported files: Bash, Go, Dockerfile, YAML, Makefile, Scala, Python, Java, PHP, C, C++, JavaScript, perl, ruby, PowerShell, Ri, . . .)

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Packages

No packages published