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
44a28838
Commit
44a28838
authored
Sep 04, 2012
by
Anastasis Andronidis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fault handling for YAML file and gitdir value.
parent
6c8171f6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
4 deletions
+10
-4
lib/ansible/utils.py
+10
-4
No files found.
lib/ansible/utils.py
View file @
44a28838
...
@@ -323,13 +323,19 @@ def _gitinfo():
...
@@ -323,13 +323,19 @@ def _gitinfo():
''' returns a string containing git branch, commit id and commit date '''
''' returns a string containing git branch, commit id and commit date '''
result
=
None
result
=
None
repo_path
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'..'
,
'..'
,
'.git'
)
repo_path
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'..'
,
'..'
,
'.git'
)
''' Check if the .git is a file. If it is a file, it means that we are in a submodule structure. '''
if
os
.
path
.
exists
(
repo_path
):
if
os
.
path
.
exists
(
repo_path
):
''' Check if the .git is a file. If it is a file, it means that we are in a submodule structure. '''
''' Check if the .git is a file. If it is a file, it means that we are in a submodule structure. '''
if
os
.
path
.
isfile
(
repo_path
):
if
os
.
path
.
isfile
(
repo_path
):
repo_path
=
repo_path
.
split
(
'.git'
)[
0
]
try
:
central_gitdir
=
yaml
.
load
(
open
(
repo_path
))[
'gitdir'
]
.
split
(
'.git'
)[
0
]
central_gitdir
=
yaml
.
load
(
open
(
repo_path
))
.
get
(
'gitdir'
)
.
split
(
'.git'
)[
0
]
''' There is a posibility the .git file to have an absolute path. '''
repo_path
=
repo_path
.
split
(
'.git'
)[
0
]
repo_path
=
os
.
path
.
join
(
repo_path
,
os
.
path
.
relpath
(
central_gitdir
),
'.git'
)
''' There is a posibility the .git file to have an absolute path. '''
repo_path
=
os
.
path
.
join
(
repo_path
,
os
.
path
.
relpath
(
central_gitdir
),
'.git'
)
except
IOError
:
exit
(
"Could not load .git file."
)
except
AttributeError
:
exit
(
"There is no gitdir attribute in .git file."
)
f
=
open
(
os
.
path
.
join
(
repo_path
,
"HEAD"
))
f
=
open
(
os
.
path
.
join
(
repo_path
,
"HEAD"
))
branch
=
f
.
readline
()
.
split
(
'/'
)[
-
1
]
.
rstrip
(
"
\n
"
)
branch
=
f
.
readline
()
.
split
(
'/'
)[
-
1
]
.
rstrip
(
"
\n
"
)
f
.
close
()
f
.
close
()
...
...
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