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
ed7a57c8
Commit
ed7a57c8
authored
Aug 09, 2016
by
Javier D. Garcia-Lasheras
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix some minor issues at fetch.git
parent
d7a148e3
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
12 deletions
+9
-12
git.py
hdlmake/fetch/git.py
+9
-12
No files found.
hdlmake/fetch/git.py
View file @
ed7a57c8
...
...
@@ -19,6 +19,8 @@
# You should have received a copy of the GNU General Public License
# along with Hdlmake. If not, see <http://www.gnu.org/licenses/>.
"""Module providing the stuff for handling Git repositories"""
import
os
from
hdlmake.util
import
path
import
logging
...
...
@@ -31,11 +33,15 @@ from .fetcher import Fetcher
class
Git
(
Fetcher
):
"""This class provides the Git fetcher instances, that are
used to fetch and handle Git repositories"""
def
__init__
(
self
):
pass
@
staticmethod
def
get_git_toplevel
(
module
):
"""Get the top level for the Git repository"""
cur_dir
=
module
.
pool
.
top_module
.
path
try
:
os
.
chdir
(
path
.
rel2abs
(
module
.
path
))
...
...
@@ -51,29 +57,24 @@ class Git(Fetcher):
os
.
chdir
(
cur_dir
)
def
fetch
(
self
,
module
):
"""Get the code from the remote Git repository"""
fetchto
=
module
.
fetchto
()
if
module
.
source
!=
GIT
:
raise
ValueError
(
"This backend should get git modules only."
)
if
not
os
.
path
.
exists
(
fetchto
):
os
.
mkdir
(
fetchto
)
cur_dir
=
module
.
pool
.
top_module
.
path
if
module
.
branch
is
None
:
module
.
branch
=
"master"
basename
=
path
.
url_basename
(
module
.
url
)
mod_path
=
os
.
path
.
join
(
fetchto
,
basename
)
logging
.
info
(
"Fetching git module:
%
s"
%
mod_path
)
if
basename
.
endswith
(
".git"
):
basename
=
basename
[:
-
4
]
# remove trailing .git
if
module
.
isfetched
:
update_only
=
True
else
:
update_only
=
False
if
update_only
:
logging
.
info
(
"Updating module
%
s"
%
mod_path
)
cmd
=
"(cd {0} && git checkout {1})"
...
...
@@ -82,13 +83,10 @@ class Git(Fetcher):
logging
.
info
(
"Cloning module
%
s"
%
mod_path
)
cmd
=
"(cd {0} && git clone -b {2} {1})"
cmd
=
cmd
.
format
(
fetchto
,
module
.
url
,
module
.
branch
)
success
=
True
logging
.
debug
(
"Running
%
s"
%
cmd
)
if
os
.
system
(
cmd
)
!=
0
:
success
=
False
if
module
.
revision
is
not
None
and
success
is
True
:
logging
.
debug
(
"cd
%
s"
%
mod_path
)
os
.
chdir
(
mod_path
)
...
...
@@ -97,13 +95,13 @@ class Git(Fetcher):
if
os
.
system
(
cmd
)
!=
0
:
success
=
False
os
.
chdir
(
cur_dir
)
module
.
isfetched
=
True
module
.
path
=
mod_path
return
success
@
staticmethod
def
check_commit_id
(
path
):
def
check_id
(
path
):
"""Get the commit id for the Git repository at path"""
cur_dir
=
os
.
getcwd
()
commit
=
None
stderr
=
TemporaryFile
()
...
...
@@ -122,7 +120,6 @@ class Git(Fetcher):
logging
.
debug
(
"git error message (in
%
s):
%
s"
%
(
path
,
'
\n
'
.
join
(
errmsg
)))
try
:
commit
=
git_out
.
stdout
.
readlines
()[
0
]
.
strip
()
except
IndexError
:
...
...
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