Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
H
Hdlmake
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
15
Issues
15
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
Hdlmake
Commits
2d07933d
Commit
2d07933d
authored
Jun 09, 2017
by
Javier D. Garcia-Lasheras
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Temporarly enable the Git submodules feature as a default
parent
055a91aa
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
68 additions
and
2 deletions
+68
-2
git.py
hdlmake/fetch/git.py
+54
-2
content.py
hdlmake/module/content.py
+14
-0
No files found.
hdlmake/fetch/git.py
View file @
2d07933d
...
@@ -25,6 +25,7 @@ from __future__ import absolute_import
...
@@ -25,6 +25,7 @@ from __future__ import absolute_import
import
os
import
os
from
hdlmake.util
import
path
as
path_utils
from
hdlmake.util
import
path
as
path_utils
from
hdlmake.util
import
shell
from
hdlmake.util
import
shell
from
subprocess
import
PIPE
,
Popen
import
logging
import
logging
from
.fetcher
import
Fetcher
from
.fetcher
import
Fetcher
...
@@ -38,9 +39,16 @@ class Git(Fetcher):
...
@@ -38,9 +39,16 @@ class Git(Fetcher):
pass
pass
@
staticmethod
@
staticmethod
def
get_git_toplevel
():
def
get_git_toplevel
(
module
):
"""Get the top level for the Git repository"""
"""Get the top level for the Git repository"""
return
shell
.
run
(
"git rev-parse --show-toplevel"
)
cur_dir
=
os
.
getcwd
()
try
:
os
.
chdir
(
path_utils
.
rel2abs
(
module
.
path
))
if
not
os
.
path
.
exists
(
".gitmodules"
):
return
None
return
shell
.
run
(
"git rev-parse --show-toplevel"
)
finally
:
os
.
chdir
(
cur_dir
)
@
staticmethod
@
staticmethod
def
get_submodule_commit
(
submodule_dir
):
def
get_submodule_commit
(
submodule_dir
):
...
@@ -94,3 +102,47 @@ class Git(Fetcher):
...
@@ -94,3 +102,47 @@ class Git(Fetcher):
"""Get the revision number for the Git repository at path"""
"""Get the revision number for the Git repository at path"""
git_cmd
=
'git log -1 --format="
%
H" | cut -c1-32'
git_cmd
=
'git log -1 --format="
%
H" | cut -c1-32'
return
Fetcher
.
check_id
(
path
,
git_cmd
)
return
Fetcher
.
check_id
(
path
,
git_cmd
)
@
staticmethod
def
get_git_submodules
(
module
):
"""Get a dictionary containing the git submodules
that are listed in the module's path"""
submodule_dir
=
path_utils
.
rel2abs
(
module
.
path
)
if
module
.
isfetched
==
False
:
logging
.
debug
(
"Cannot check submodules, module
%
s is not fetched"
,
submodule_dir
)
return
{}
logging
.
debug
(
"Checking git submodules in
%
s"
,
submodule_dir
)
cur_dir
=
os
.
getcwd
()
try
:
os
.
chdir
(
submodule_dir
)
if
not
os
.
path
.
exists
(
".gitmodules"
):
return
{}
config_submodules
=
{}
config_content
=
Popen
(
"git config -f .gitmodules --list"
,
stdout
=
PIPE
,
stdin
=
PIPE
,
close_fds
=
not
shell
.
check_windows
(),
shell
=
True
)
config_lines
=
[
line
.
strip
()
for
line
in
config_content
.
stdout
.
readlines
()]
config_submodule_lines
=
[
line
for
line
in
config_lines
if
line
.
startswith
(
"submodule"
)]
for
line
in
config_submodule_lines
:
line_split
=
line
.
split
(
"="
)
lhs
=
line_split
[
0
]
rhs
=
line_split
[
1
]
lhs_split
=
lhs
.
split
(
"."
)
module_name
=
'.'
.
join
(
lhs_split
[
1
:
-
1
])
if
module_name
not
in
config_submodules
:
config_submodules
[
module_name
]
=
{}
config_submodules
[
module_name
][
lhs_split
[
-
1
]]
=
rhs
if
len
(
list
(
config_submodules
))
>
0
:
logging
.
info
(
"Found git submodules in
%
s:
%
s"
,
module
.
path
,
str
(
config_submodules
))
finally
:
os
.
chdir
(
cur_dir
)
return
config_submodules
hdlmake/module/content.py
View file @
2d07933d
...
@@ -135,6 +135,20 @@ class ModuleContent(ModuleCore):
...
@@ -135,6 +135,20 @@ class ModuleContent(ModuleCore):
else
:
else
:
self
.
git
=
[]
self
.
git
=
[]
def
process_git_submodules
(
self
):
"""Get the submodules if found in the Manifest path"""
git_submodule_dict
=
fetch
.
Git
.
get_git_submodules
(
self
)
git_toplevel
=
fetch
.
Git
.
get_git_toplevel
(
self
)
for
submodule_key
in
git_submodule_dict
.
keys
():
url
=
git_submodule_dict
[
submodule_key
][
"url"
]
path
=
git_submodule_dict
[
submodule_key
][
"path"
]
path
=
os
.
path
.
join
(
git_toplevel
,
path
)
fetchto
=
os
.
path
.
sep
.
join
(
path
.
split
(
os
.
path
.
sep
)[:
-
1
])
self
.
git
.
append
(
self
.
pool
.
new_module
(
parent
=
self
,
url
=
url
,
fetchto
=
fetchto
,
source
=
fetch
.
GIT
))
def
_process_manifest_makefiles
(
self
):
def
_process_manifest_makefiles
(
self
):
"""Get the extra makefiles defined in the HDLMake module"""
"""Get the extra makefiles defined in the HDLMake module"""
# Included Makefiles
# Included Makefiles
...
...
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