Skip to content

Add URL to repo & fix some spelling/grammar #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
# ---------------------------------------------------------------------------- #
#
# Copyright (c) 2020 C++ Modern Framework
# https://github.com/cppmf/GitInfo.cmake
#
# ---------------------------------------------------------------------------- #

# ---------------------------------------------------------------------------- #
#
# Following variables will be set when calling GitInfo
# The following variables will be set when calling GitInfo
#
# GIT_DIR: path to the project .git directory
# GIT_IS_DIRTY: whether or not the working tree is dirty
# GIT_HEAD_BRANCH : name of the branch associated te HEAD
# GIT_HEAD_BRANCH : name of the branch associated with HEAD
# GIT_REVISION_HASH: current HEAD sha hash
# GIT_REVISION: shorten version of GIT_REVISION_HASH
# GIT_REVISION_NAME: name associated to GIT_REVISION_HASH
# GIT_REVISION: short version of GIT_REVISION_HASH
# GIT_REVISION_NAME: name associated with GIT_REVISION_HASH
# GIT_AUTHOR_NAME : author name
# GIT_AUTHOR_EMAIL : author email
# GIT_AUTHOR_DATE : author date
Expand All @@ -32,7 +33,7 @@
# source should point to the root project directory
function(GitInfo source)

# Check is source is a valid path
# Check if source is a valid path
if(NOT EXISTS ${source})
message(FATAL_ERROR "'${source}' is not a valid path")
endif()
Expand All @@ -43,7 +44,6 @@ function(GitInfo source)
# Check if .git folder exist
if(EXISTS ${GIT_DIR})

#
set(GIT_DIR "${GIT_DIR}" CACHE PATH "Project .git directory")

# Check if git is installed
Expand All @@ -70,29 +70,29 @@ function(GitInfo source)
set(GIT_IS_DIRTY OFF CACHE BOOL "Indicate if current branch is dirty")
endif()

# name of the brack associated te HEAD
# name of the branch associated with HEAD
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${source}
OUTPUT_VARIABLE GIT_HEAD_BRANCH OUTPUT_STRIP_TRAILING_WHITESPACE)
set(GIT_HEAD_BRANCH "${GIT_HEAD_BRANCH}" CACHE INTERNAL "name of the brack associated te HEAD")
set(GIT_HEAD_BRANCH "${GIT_HEAD_BRANCH}" CACHE INTERNAL "name of the branch associated with HEAD")

# git revision full hash
execute_process(COMMAND ${GIT_EXECUTABLE} show -s "--format=%H" HEAD
WORKING_DIRECTORY ${source}
OUTPUT_VARIABLE GIT_REVISION_HASH OUTPUT_STRIP_TRAILING_WHITESPACE)
set(GIT_REVISION_HASH "${GIT_REVISION_HASH}" CACHE INTERNAL "git revision full hash")

# shorten version of git revision
# short version of git revision
execute_process(COMMAND ${GIT_EXECUTABLE} show -s "--format=%h" HEAD
WORKING_DIRECTORY ${source}
OUTPUT_VARIABLE GIT_REVISION OUTPUT_STRIP_TRAILING_WHITESPACE)
set(GIT_REVISION "${GIT_REVISION}" CACHE INTERNAL "shorten version of git revision")
set(GIT_REVISION "${GIT_REVISION}" CACHE INTERNAL "short version of git revision")

# shorten version of git revision name
# short version of git revision name
execute_process(COMMAND ${GIT_EXECUTABLE} show -s "--format=%s" HEAD
WORKING_DIRECTORY ${source}
OUTPUT_VARIABLE GIT_REVISION_NAME OUTPUT_STRIP_TRAILING_WHITESPACE)
set(GIT_REVISION_NAME "${GIT_REVISION_NAME}" CACHE INTERNAL "shorten version of git revision name")
set(GIT_REVISION_NAME "${GIT_REVISION_NAME}" CACHE INTERNAL "short version of git revision name")

# author name
execute_process(COMMAND ${GIT_EXECUTABLE} show -s "--format=%an" HEAD
Expand Down
40 changes: 20 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
---

## Usage

The easiest way to use [GitInfo.cmake](https://github.com/cppmf/GitInfo.cmake) is by adding [GetCPM.cmake](https://github.com/cppmf/GetCPM.cmake) to your project.

First add GetCPM.cmake module :
Expand All @@ -20,7 +21,6 @@ wget -O cmake/GetCPM.cmake https://raw.githubusercontent.com/cppmf/GetCPM.cmake/

Then add the following lines to the project's `CMakeLists.txt`.


```bash
# include CPM.cmake module
include(cmake/GetCPM.cmake)
Expand All @@ -40,22 +40,22 @@ GitInfo(${CMAKE_CURRENT_SOURCE_DIR})

After calling GitInfo function, the following variables will be set

variable | description
---------|------------
GIT_DIR | path to the project .git directory
GIT_IS_DIRTY | whether or not the working tree is dirty
GIT_HEAD_BRANCH | name of the branch associated to HEAD
GIT_REVISION_HASH | current HEAD sha hash
GIT_REVISION | shorten version of GIT_REVISION_HASH
GIT_REVISION_NAME | name associated to GIT_REVISION_HASH
GIT_AUTHOR_NAME | author name
GIT_AUTHOR_EMAIL | author email
GIT_AUTHOR_DATE | author date
GIT_AUTHOR_DATE_ISO | author date, strict ISO 8601 format
GIT_COMMITTER_NAME | committer name
GIT_COMMITTER_EMAIL | committer email
GIT_COMMITTER_DATE | committer date
GIT_COMMITTER_DATE_ISO | committer date, strict ISO 8601 format
GIT_REMOTE_ORIGIN_URL | origin remote url
GIT_LATEST_TAG_LONG | most recent tag of the current branch
GIT_LATEST_TAG | most recent tagname of the current branch
| variable | description |
| ---------------------- | ----------------------------------------- |
| GIT_DIR | path to the project .git directory |
| GIT_IS_DIRTY | whether or not the working tree is dirty |
| GIT_HEAD_BRANCH | name of the branch associated with HEAD |
| GIT_REVISION_HASH | current HEAD sha hash |
| GIT_REVISION | short version of GIT_REVISION_HASH |
| GIT_REVISION_NAME | name associated to GIT_REVISION_HASH |
| GIT_AUTHOR_NAME | author name |
| GIT_AUTHOR_EMAIL | author email |
| GIT_AUTHOR_DATE | author date |
| GIT_AUTHOR_DATE_ISO | author date, strict ISO 8601 format |
| GIT_COMMITTER_NAME | committer name |
| GIT_COMMITTER_EMAIL | committer email |
| GIT_COMMITTER_DATE | committer date |
| GIT_COMMITTER_DATE_ISO | committer date, strict ISO 8601 format |
| GIT_REMOTE_ORIGIN_URL | origin remote url |
| GIT_LATEST_TAG_LONG | most recent tag of the current branch |
| GIT_LATEST_TAG | most recent tagname of the current branch |