Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
e654f881
Commit
e654f881
authored
Aug 08, 2012
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #812 from willthames/gitversion
Added commit time information to the --version output
parents
7592a735
208f2b66
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
4 deletions
+8
-4
lib/ansible/utils.py
+8
-4
No files found.
lib/ansible/utils.py
View file @
e654f881
...
...
@@ -28,6 +28,7 @@ from ansible import errors
from
ansible
import
color
from
ansible
import
__version__
import
ansible.constants
as
C
import
time
VERBOSITY
=
0
...
...
@@ -290,16 +291,19 @@ def default(value, function):
return
value
def
_gitinfo
():
''' returns a string containing git branch and commit id
using gitpython if installed and native file operations if not '''
''' returns a string containing git branch, commit id and commit date '''
result
=
None
repo_path
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'..'
,
'..'
,
'.git'
)
if
os
.
path
.
exists
(
repo_path
):
with
open
(
os
.
path
.
join
(
repo_path
,
"HEAD"
))
as
f
:
branch
=
f
.
readline
()
.
split
(
'/'
)[
-
1
]
.
rstrip
(
"
\n
"
)
with
open
(
os
.
path
.
join
(
repo_path
,
"refs"
,
"heads"
,
branch
))
as
f
:
branch_path
=
os
.
path
.
join
(
repo_path
,
"refs"
,
"heads"
,
branch
)
with
open
(
branch_path
)
as
f
:
commit
=
f
.
readline
()[:
10
]
result
=
"({0} {1})"
.
format
(
branch
,
commit
)
date
=
time
.
localtime
(
os
.
stat
(
branch_path
)
.
st_mtime
)
offset
=
time
.
timezone
if
(
time
.
daylight
==
0
)
else
time
.
altzone
result
=
"({0}) [{1}] {2} ({3:+04d})"
.
format
(
branch
,
commit
,
time
.
strftime
(
"
%
Y
%
m
%
d-
%
H
%
M
%
S"
,
date
),
offset
/
-
36
)
return
result
def
version
(
prog
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment