Archived
1
0

Adding list of modified files to the cli version command.

This commit is contained in:
Jacob Alexander 2015-02-28 23:50:13 -08:00
parent a9c5898ba5
commit bf3b06aa22
3 changed files with 39 additions and 28 deletions

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2014 by Jacob Alexander /* Copyright (C) 2014-2015 by Jacob Alexander
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@ -422,7 +422,7 @@ void cliFunc_version( char* args )
print( NL ); print( NL );
print( " \033[1mRevision:\033[0m " CLI_Revision NL ); print( " \033[1mRevision:\033[0m " CLI_Revision NL );
print( " \033[1mBranch:\033[0m " CLI_Branch NL ); print( " \033[1mBranch:\033[0m " CLI_Branch NL );
print( " \033[1mTree Status:\033[0m " CLI_ModifiedStatus NL ); print( " \033[1mTree Status:\033[0m " CLI_ModifiedStatus CLI_ModifiedFiles NL );
print( " \033[1mRepo Origin:\033[0m " CLI_RepoOrigin NL ); print( " \033[1mRepo Origin:\033[0m " CLI_RepoOrigin NL );
print( " \033[1mCommit Date:\033[0m " CLI_CommitDate NL ); print( " \033[1mCommit Date:\033[0m " CLI_CommitDate NL );
print( " \033[1mCommit Author:\033[0m " CLI_CommitAuthor NL ); print( " \033[1mCommit Author:\033[0m " CLI_CommitAuthor NL );

View File

@ -157,7 +157,7 @@ find_package ( Ctags ) # Optional
# #
#| Manufacturer name #| Manufacturer name
set( MANUFACTURER "Kiibohd" ) set ( MANUFACTURER "Kiibohd" )
#| Serial Number #| Serial Number
@ -165,19 +165,29 @@ set( MANUFACTURER "Kiibohd" )
#| Modified #| Modified
#| Takes a bit of work to extract the "M " using CMake, and not using it if there are no modifications #| Takes a bit of work to extract the "M " using CMake, and not using it if there are no modifications
execute_process( COMMAND ${GIT_EXECUTABLE} status -s -uno --porcelain execute_process ( COMMAND ${GIT_EXECUTABLE} status -s -uno --porcelain
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
OUTPUT_VARIABLE Git_Modified_INFO OUTPUT_VARIABLE Git_Modified_INFO
ERROR_QUIET ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_STRIP_TRAILING_WHITESPACE
) )
string( LENGTH "${Git_Modified_INFO}" Git_Modified_LENGTH ) string ( LENGTH "${Git_Modified_INFO}" Git_Modified_LENGTH )
set( Git_Modified_Status "Clean" ) set ( Git_Modified_Status "Clean" )
if ( ${Git_Modified_LENGTH} GREATER 2 ) if ( ${Git_Modified_LENGTH} GREATER 2 )
string( SUBSTRING "${Git_Modified_INFO}" 1 2 Git_Modified_Flag_INFO ) string ( SUBSTRING "${Git_Modified_INFO}" 1 2 Git_Modified_Flag_INFO )
set( Git_Modified_Status "Dirty" ) set ( Git_Modified_Status "Dirty" )
endif () endif ()
#| List of modified files
execute_process ( COMMAND ${GIT_EXECUTABLE} diff-index --name-only HEAD --
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
OUTPUT_VARIABLE Git_Modified_Files
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
string ( REGEX REPLACE "\n" "\\\\r\\\\n\\\\t" Git_Modified_Files "${Git_Modified_Files}" )
set ( Git_Modified_Files "\\r\\n\\t${Git_Modified_Files}" )
#| Branch #| Branch
execute_process( COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD execute_process( COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
@ -187,7 +197,7 @@ execute_process( COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
) )
#| Date #| Date
execute_process( COMMAND ${GIT_EXECUTABLE} show -s --format=%ci execute_process ( COMMAND ${GIT_EXECUTABLE} show -s --format=%ci
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
OUTPUT_VARIABLE Git_Date_INFO OUTPUT_VARIABLE Git_Date_INFO
ERROR_QUIET ERROR_QUIET
@ -195,7 +205,7 @@ execute_process( COMMAND ${GIT_EXECUTABLE} show -s --format=%ci
) )
#| Commit Author and Email #| Commit Author and Email
execute_process( COMMAND ${GIT_EXECUTABLE} show -s --format="%cn <%ce>" execute_process ( COMMAND ${GIT_EXECUTABLE} show -s --format="%cn <%ce>"
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
OUTPUT_VARIABLE Git_Commit_Author OUTPUT_VARIABLE Git_Commit_Author
ERROR_QUIET ERROR_QUIET
@ -203,7 +213,7 @@ execute_process( COMMAND ${GIT_EXECUTABLE} show -s --format="%cn <%ce>"
) )
#| Commit Revision #| Commit Revision
execute_process( COMMAND ${GIT_EXECUTABLE} show -s --format=%H execute_process ( COMMAND ${GIT_EXECUTABLE} show -s --format=%H
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
OUTPUT_VARIABLE Git_Commit_Revision OUTPUT_VARIABLE Git_Commit_Revision
ERROR_QUIET ERROR_QUIET
@ -211,7 +221,7 @@ execute_process( COMMAND ${GIT_EXECUTABLE} show -s --format=%H
) )
#| Origin URL #| Origin URL
execute_process( COMMAND ${GIT_EXECUTABLE} config --get remote.origin.url execute_process ( COMMAND ${GIT_EXECUTABLE} config --get remote.origin.url
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
OUTPUT_VARIABLE Git_Origin_URL OUTPUT_VARIABLE Git_Origin_URL
ERROR_QUIET ERROR_QUIET
@ -219,25 +229,25 @@ execute_process( COMMAND ${GIT_EXECUTABLE} config --get remote.origin.url
) )
#| Build Date #| Build Date
execute_process( COMMAND "date" "+%Y-%m-%d %T %z" execute_process ( COMMAND "date" "+%Y-%m-%d %T %z"
OUTPUT_VARIABLE Build_Date OUTPUT_VARIABLE Build_Date
ERROR_QUIET ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_STRIP_TRAILING_WHITESPACE
) )
#| Last Commit Date #| Last Commit Date
set( GitLastCommitDate "${Git_Modified_Status} ${Git_Branch_INFO} - ${Git_Date_INFO}" ) set ( GitLastCommitDate "${Git_Modified_Status} ${Git_Branch_INFO} - ${Git_Date_INFO}" )
#| Uses CMake variables to include as defines #| Uses CMake variables to include as defines
#| Primarily for USB configuration #| Primarily for USB configuration
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/Lib/_buildvars.h buildvars.h ) configure_file ( ${CMAKE_CURRENT_SOURCE_DIR}/Lib/_buildvars.h buildvars.h )
### ###
# Source Defines # Source Defines
# #
set( SRCS set ( SRCS
${MAIN_SRCS} ${MAIN_SRCS}
${COMPILER_SRCS} ${COMPILER_SRCS}
${Scan_SRCS} ${Scan_SRCS}
@ -247,7 +257,7 @@ set( SRCS
) )
#| Directories to include by default #| Directories to include by default
include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ) include_directories ( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} )
@ -255,20 +265,20 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} )
# ctag Generation # ctag Generation
# #
if( CTAGS_EXECUTABLE ) if ( CTAGS_EXECUTABLE )
# Populate list of directories for ctags to parse # Populate list of directories for ctags to parse
# NOTE: Doesn't support dots in the folder names... # NOTE: Doesn't support dots in the folder names...
foreach( filename ${SRCS} ) foreach ( filename ${SRCS} )
string( REGEX REPLACE "/[a-zA-Z0-9_-]+.c$" "" pathglob ${filename} ) string ( REGEX REPLACE "/[a-zA-Z0-9_-]+.c$" "" pathglob ${filename} )
file( GLOB filenames "${pathglob}/*.c" ) file ( GLOB filenames "${pathglob}/*.c" )
set( CTAG_PATHS ${CTAG_PATHS} ${filenames} ) set ( CTAG_PATHS ${CTAG_PATHS} ${filenames} )
file( GLOB filenames "${pathglob}/*.h" ) file ( GLOB filenames "${pathglob}/*.h" )
set( CTAG_PATHS ${CTAG_PATHS} ${filenames} ) set ( CTAG_PATHS ${CTAG_PATHS} ${filenames} )
endforeach() endforeach ()
# Generate the ctags # Generate the ctags
execute_process( COMMAND ctags ${CTAG_PATHS} execute_process ( COMMAND ctags ${CTAG_PATHS}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
) )
endif() endif ()

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2013-2014 by Jacob Alexander /* Copyright (C) 2013-2015 by Jacob Alexander
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@ -38,6 +38,7 @@
#define CLI_Revision "@Git_Commit_Revision@" #define CLI_Revision "@Git_Commit_Revision@"
#define CLI_Branch "@Git_Branch_INFO@" #define CLI_Branch "@Git_Branch_INFO@"
#define CLI_ModifiedStatus "@Git_Modified_Status@" #define CLI_ModifiedStatus "@Git_Modified_Status@"
#define CLI_ModifiedFiles "@Git_Modified_Files@"
#define CLI_RepoOrigin "@Git_Origin_URL@" #define CLI_RepoOrigin "@Git_Origin_URL@"
#define CLI_CommitDate "@Git_Date_INFO@" #define CLI_CommitDate "@Git_Date_INFO@"
#define CLI_CommitAuthor @Git_Commit_Author@ #define CLI_CommitAuthor @Git_Commit_Author@