Giter Site home page Giter Site logo

bradleya / markit Goto Github PK

View Code? Open in Web Editor NEW
16.0 4.0 7.0 2.99 MB

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: MIT License

Shell 95.47% Makefile 0.72% C 0.75% Go 0.68% HTML 0.42% Ruby 0.55% Scala 0.50% Perl 0.45% Dockerfile 0.27% Raku 0.18%
version release-notes release-management release-helper markit shell-script version-changer version-control versioning bash-script

markit's People

Contributors

bradleya avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

markit's Issues

Add an argument $1 to support -u for untracked files

Add an argument $1 to support -u for untracked files
UNTRACKED_FILES=${1:-no}
FILE_LIST=git status -s --untracked-files=${UNTRACKED_FILES} | awk '{print $2}'
default all; to automate vers hard code

-u[], --untracked-files[=]
Show untracked files.
The mode parameter is optional (defaults to all), and is used to specify the handling of untracked files.
The possible options are:
· no - Show no untracked files.
· normal - Shows untracked files and directories.
· all - Also shows individual files in untracked directories.
When -u option is not used, untracked files and directories are shown (i.e. the same as specifying normal), to help you avoid forgetting to add newly created files. Because it takes extra work to find untracked files in the filesystem, this mode may take some time in a large working tree. You can use no to have git status return more quickly without showing untracked files.

find-code.sh failed to find any when in ~/kubernets

find-code.sh failed to find any when in ~/kubernets

Added example:
bradley@zero:~$ cd github/

bradley@zero:~/github$ find-code.sh
2018-10-05-21-36-20-CDT /usr/local/bin/find-code.sh 3.85.235 64 [INFO]  zero.cptx86.com  bradley  1000 1000  Begin
2018-10-05-21-36-20-CDT /usr/local/bin/find-code.sh 3.85.235 67 [DEBUG]  zero.cptx86.com  bradley  1000 1000  Name_of_command >/usr/local/bin/find-code.sh< Name_of_arg1 ><
2018-10-05-21-36-20-CDT /usr/local/bin/find-code.sh 3.85.235 74 [DEBUG]  zero.cptx86.com  bradley  1000 1000  LOCALHOST >zero.cptx86.com<  HOSTFILE >/usr/local/data/us-tx-cluster-1/SYSTEMS<

  -->  zero.cptx86.com       ->find ~/.. 2>/dev/null -type d -execdir test -d '.git' \; -print -prune<-
/home/bradley/../uadmin/github/BradleyA/markit/testfiles
/home/bradley/../uadmin/github/BradleyA/markit/.git
/home/bradley/../bradley/github/BradleyA/markit/testfiles
/home/bradley/../bradley/github/BradleyA/markit/.git
/home/bradley/../bradley/github/cdatx-2016/docpad-plugin-ghpages
/home/bradley/../bradley/github/cdatx-2016/docpad-plugin-eco
/home/bradley/../bradley/github/cdatx-2016/src
/home/bradley/../bradley/github/cdatx-2016/out
/home/bradley/../bradley/github/cdatx-2016/.git
/home/bradley/../bradley/github/cdatx-2016/docpad-plugin-less
/home/bradley/../bradley/github/cdatx-2016/docpad-plugin-partials
/home/bradley/../bradley/github/cdatx-2016/docpad-plugin-marked
/home/bradley/../bradley/github/cdatx-2016/node_modules
/home/bradley/../bradley/kubernetes/.github
/home/bradley/../bradley/kubernetes/.git
/home/bradley/../bradley/Search-docker-registry-v2-script/.git
^C
bradley@zero:~$ cd kubernetes/

bradley@zero:~/kubernetes$ find-code.sh
2018-10-05-21-36-33-CDT /usr/local/bin/find-code.sh 3.85.235 64 [INFO]  zero.cptx86.com  bradley  1000 1000  Begin
2018-10-05-21-36-33-CDT /usr/local/bin/find-code.sh 3.85.235 67 [DEBUG]  zero.cptx86.com  bradley  1000 1000  Name_of_command >/usr/local/bin/find-code.sh< Name_of_arg1 ><
2018-10-05-21-36-33-CDT /usr/local/bin/find-code.sh 3.85.235 74 [DEBUG]  zero.cptx86.com  bradley  1000 1000  LOCALHOST >zero.cptx86.com<  HOSTFILE >/usr/local/data/us-tx-cluster-1/SYSTEMS<

  -->  zero.cptx86.com       ->find ~/.. 2>/dev/null -type d -execdir test -d '.git' \; -print -prune<-
/home/bradley/..
2018-10-05-21-36-33-CDT /usr/local/bin/find-code.sh 3.85.235 90 [INFO]  zero.cptx86.com  bradley  1000 1000  Done.

bradley@zero:~/kubernetes$

returned error : fatal: No names found, cannot describe anything.

returned error : fatal: No names found, cannot describe anything.

Files to be marked and pushed to GitHub:
work-notes/Dockerfile
work-notes/Dockerfile.coreos
work-notes/Response-to-search
work-notes/Search-docker-registry-v2-script.1.0
work-notes/Search-docker-registry-v2-script.2.0
work-notes/Search-docker-registry-v2-script.bak
work-notes/auth/htpasswd
work-notes/delete-docker-registry-image
work-notes/docker-search
work-notes/documation-bugreport.odt
work-notes/start-registry
work-notes/start-registry-ui
work-notes/start-registry.bak
work-notes/start-registry.old6
work-notes/test-script-images
work-notes/view-private-registry

Current release number: 0.01 

Enter release number to commit files to GitHub (example 3.01).
Press enter to use 0.01 release number or ctrl-c to stop.
0.02
/usr/local/bin/markit 135 [INFO]:	Using release number: 0.02

 Enter a one line description about the changes
    (example: Added logic for --help; closes #12, resolves #14):
initial commit
fatal: No names found, cannot describe anything.
work-notes/Dockerfile.coreos	coreos

Enter single-line  BEGINNING  comment character(s) for work-notes/Dockerfile.coreos
   (example: # // -- ' ! C !* -- // % ;;  ||  /* <!-- <!--- {- /** --[[ %{ (* <# )

#	

Enter single-line  ENDING  comment character(s) for work-notes/Dockerfile.coreos.
Press enter for none.
  (example: */ --> ---> -} */ --]] %} *) #> )

fatal: No names found, cannot describe anything.
work-notes/Response-to-search	work-notes/Response-to-search

Enter single-line  BEGINNING  comment character(s) for work-notes/Response-to-search
   (example: # // -- ' ! C !* -- // % ;;  ||  /* <!-- <!--- {- /** --[[ %{ (* <# )

when processing Dockerfile.coreos the first time but could be created from Dockerfile
error message was produced from git describe
line 206
echo "${BEGIN_COMMENT_CHAR} ${FILE_NAME} ${FILE_RELEASE}.git rev-list HEAD | wc -l ${TIME_STAMP} ${REMOTE_REPOSITORY} ${USER} hostname -f git describe ${END_COMMENT_CHAR}" >> ${TEMP_FILE}

check-markit: print commit date of local command

check-markit: print commit date of local command so user can compare that date and time with the repository date and time

This added information with the version information will allow the user more knowledge about the state of code.

README add ISO 8601 for date

README add ISO 8601 for date

#       find-code.sh  3.92.242  2018-10-06T20:00:50-05:00 (CDT)  https://github.com/BradleyA/markit  uadmin  six-rpi3b.cptx86.com 3.91  
#          check-markit add ISO 8601 for date #46 

add GitHub repository

Need to add GitHub repository between date and the submitter on line to
why
because when I found some code on a system which did have markit two line comment. I could not figure what repository it was from? I want to see if there was a newer version. Something I could cut and paste the repository information from lines 2 or 3 and check it out the code on github or ___.

git remote show origin

markit include directory with file name on line one item 2

By changing the file_name to include the directory, all the information is available to find it's location in the GitHub or GitLab repository. This could be leveraged at a later date if needed. But users could go directly to the file on GitHub or GitLab with no need to search.

Need to determine if it will effect any other tools, check-markit. I do not think it will effect anything because when head -2 /usr/local/bin/*.sh | more . I think the path is included when markit is executed in a different directory.

==> check-user-ssh.sh <==
#!/bin/bash
# 	check-user-ssh.sh  3.44.396  2018-08-12_20:50:13_CDT  https://github.com/BradleyA/docker-scripts  uadmin  three-rpi3b.cptx86.com 3.43-3-gbbb68b6  

==> check-user-tls.sh <==
#!/bin/bash
# 	docker-TLS/check-user-tls.sh  3.42.391  2018-08-12_10:59:20_CDT  https://github.com/BradleyA/docker-scripts  uadmin  three-rpi3b.cptx86.com 3.41-8-g21e9f27  

examples:

(cd $(git rev-parse --show-toplevel) ; git status --untracked-file=all -s | grep '?? ' | sed 's/^?? //')
create-message/local-create-message.sh
images/test-1
test-1

login failed during git push

add code to prompt user to run git push because GitHub login failed during git push
statement that failed || { echo "${0} ${LINENO} [ERROR]: Login fail, enter git push to complete marking code" ; exit 1; }

notes about why

I started using SCCS, RCS and CVS (%W% %G% %U%) for version control.

I had challenges with Git. I wanted to know what version a piece of code was on any system running it. The system may or may not be connected to any network. The system may or may not have Git installed. The system may or may not have the GitHub repository installed on it. I wanted the same solution for several types of code (.sh, .go, .yml, .xml, .mk, dockerfile, etc). I wanted any person without knowledge of Git or GitHub to be able to answer one question over the phone; What version are you running?

So, I wrote what I call a wrapper around a few Git commands. I use it to mark a file with a version number and some change information. It solves my challenge. It may help you.
curl -L https://api.github.com/repos/BradleyA/markit/tarball | tar -xzf - --wildcards /markit ; mv BradleyA/markit . ; rmdir BradleyA*/
or
https://github.com/BradleyA/markit

create new script to check if the current installed version is the latest version

create new script to check if the current installed version is the latest version on github or gitlab
maybe call it markit-check or markcheck

notes:

https://github.com/BradleyA/Search-docker-registry-v2-script.1.0.git
https://github.com/BradleyA/markit.git

https://github.com/BradleyA/docker-scripts.git
curl -L https://api.github.com/repos/BradleyA/docker-scripts/tarball | tar -xzf - --wildcards */c* ; mv BradleyA-docker-scripts*/docker-TLS/c* . ; rm -rf BradleyA-docker-scripts-*/

maybe down load the file with curl and grep the second line and compare line 2

grep -m 1 -e markit -e git /usr/local/bin/markit

#	markit  3.23.164  2018-07-22_23:11:39_CDT  https://github.com/BradleyA/markit  uadmin  three-rpi3b.cptx86.com 3.22-2-gac7de6c 

check-markit: error using check-markit with .ssh/config

Continue to receive error using check-markit with .ssh/config

check-markit -f .ssh/config

I think it is the directory

042120 uadmin@six-rpi3b:~/github/BradleyA/user-work-files
   $ check-markit -f .ssh/config
> DEBUG 87  MARKIT_FILE >.ssh/config< FILE_NAME >config< REPOSITORY_COMMAND >https://github.com/BradleyA/user-work-files.git< MARKIT_FILE_RELEASE >2.11.47<

/usr/local/bin/check-markit 100 [INFO]:  Checking GitHub for config repository release information

> DEBUG 117  MARKIT_FILE >.ssh/config< FILE_NAME >config< REPOSITORY_COMMAND >curl \-L https://api.github.com/repos/BradleyA/user-work-files.git/tarball | tar --directory /tmp/markit-temp -xzf - < MARKIT_FILE_RELEASE >2.11.47<
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   120  100   120    0     0    168      0 --:--:-- --:--:-- --:--:--   168

gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error is not recoverable: exiting now
^C

markit add to help information about failed login

markit add to help information about failed login to use git push --follow-tags

{ echo -e "\n${NORMAL}${0} ${LINENO} [${BOLD}ERROR${NORMAL}]: login failed, or\n\tremote respoitory contains new work or password is NOT correct.\n\tEnter; '${BOLD}git push --follow-tags${NORMAL}' to complete pushing marked file(s)." ; exit 1; }

check-markit: change grep <string-one> && <string-two |

change grep && <string-two |

This fixes the incident when the file name is on the first line of the file.

grep git .ssh/config | grep -m1 config | awk {'print$5'} 

grep git ${MARKIT_FILE} | grep -m1 ${FILE_NAME} | awk {'print$5'} 
grep git ${MARKIT_FILE} | grep -m1 ${FILE_NAME} | awk

Current it is which is acting like or not and

REPOSITORY_COMMAND=`grep -m 1 -e ${FILE_NAME} -e git ${MARKIT_FILE} | awk {'print$5'}`
MARKIT_FILE_RELEASE=`grep -m 1 -e ${FILE_NAME} -e git ${MARKIT_FILE} | awk {'print$3'}`

here is the current out put with DEBUG 1

dmin@six-rpi3b:~/github/BradleyA/user-work-files
   $ check-markit -f .ssh/config
> DEBUG 87  MARKIT_FILE >.ssh/config< FILE_NAME >config< REPOSITORY_COMMAND >< MARKIT_FILE_RELEASE ><

/usr/local/bin/check-markit 91 [ERROR]:  .ssh/config is not marked with markit or the --file option was not used or git origin did not include https address (git remote -v) when marked or file was marked with a release before markit 3.10.142

error & exit 1 if repository not setup or not git cloned from remote repository

fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git [...] -- [...]'
fatal: No remote configured to list refs from.

Example to create a new repository on the command line

echo "# " >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/BradleyA/test-markit-new.git
git push -u origin master

check argument $1

Need to add a check argument,
echo error,
display_help,
exit 1;
$1 variable no, normal, all

skip marking binary for other files

add code to skip marking a file that you do not want to mark and that is currently not supported like an *.jpg *.mpeg, or any file when prompted for comment character enter skip

Use markit solution for source code

# >>>   In the future, Use markit solution for source code and create a wrapper during compile/build time ?
# >>>       This will change the extension case statement objective: move from comments to variables in compiled code
# >>>       move from comments in source code to variables in compiled code
# >>>       very different vision
# >>>     Use markit in the source code & insert; var BUILD_VERSION="${FILE_RELEASE}.`git rev-list HEAD | wc -l`"
# >>>      Or use markit; to create CHAR variable found in compiled code ?
# >>>           opening comment x.c 'var VERSION="' and ending comment '"'
# >>>           opening comment x.c 'char VERSION[] = "$Version: ' ${FILE_NAME}    ${FILE_RELEASE}.`git rev-list HEAD | wc -l`     ${TIME_STAMP} ${USER} `hostname -f` `git describe` and ending comment '$";'
# >>>                           x.o $Version: XXXX XXXX XXXX XXXX '$'
# >>>           opening comment x.c 'char VERSION_MESSAGE[] = "$Version_message: ' ${FILE_MESSAGE} ` and ending comment '$";'
# >>>                           x.o $Version_message: XXXX '$'

Use on Gitlab

Have you considered adapting your script for pushing to Gitlab repositories? I know many devs have migrated there from here after the recent news of the MSFT acquisition.

remove deleted file when creating file list

Remove file(s) that have been git rm when creating FILE_LIST
because markit is for files being processed with version number and description of change

deleted files need to be git push to update repository

This will stop these errors:
head: cannot open 'dummy/sample.MK' for reading: No such file or directory
wc: dummy/sample.MK: No such file or directory
tail: invalid number of lines: ‘dummy/sample.MK’
cp: cannot create regular file 'dummy/sample.MK': No such file or directory
fatal: pathspec 'dummy/sample.MK' did not match any files

Test for dockerfile

Test for dockerfile which does not have a file extension

This is currently the only type of file like this
In the future when more files like this are needed a case statement will be required

markit order of tags not displaying latest

This has worked from
3.1 -> 3.2 -> 3.3 -> etc -> 3.9 but not when 3.10
it is displaying the latest tag is 3.9 not 3.10 need to change from git tag | tail -1 to git describe to display latest tag in the current branch

May need to change this in the future to support more than one branch:
This will output the tag of the latest tagged commit across all branches
git describe --tags $(git rev-list --tags --max-count=1)
or
TAG=$(git describe --tags $(git rev-list --tags --max-count=1))
or
To get the most recent tag, you can do:
$ git for-each-ref refs/tags --sort=-taggerdate --format='%(refname)' --count=1
or
TAG=$(git describe $(git rev-list --tags --max-count=1))
Technically, won't necessarily get you the latest tag, but the latest commit which is tagged, which may or may not be the thing you're looking for
or
read: https://stackoverflow.com/questions/1404796/how-to-get-the-latest-tag-name-in-current-branch-in-git

markit considered adapting it to Bitbucket

Considered adapting it to Bitbucket, since I am not a Bitbucket user. Off the top of my head it may require very little if any code changes. The script would need to change the help text from GitHub to GitHub or GitLab or Bitbucket. I would need a Bitbucket users knowledge to help me understand the differences and test the script on Bitbucket.
Thank you for the feed back.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.