Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
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
edx
edx-platform
Commits
7d861245
Commit
7d861245
authored
Jan 22, 2014
by
Carson Gee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add additional logging for importing course from git
parent
e6345868
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
4 deletions
+27
-4
lms/djangoapps/dashboard/git_import.py
+9
-4
lms/djangoapps/dashboard/management/commands/tests/test_git_add_course.py
+18
-0
No files found.
lms/djangoapps/dashboard/git_import.py
View file @
7d861245
...
...
@@ -97,23 +97,28 @@ def add_repo(repo, rdir_in):
cwd
=
os
.
path
.
abspath
(
cwd
)
try
:
ret_git
=
cmd_log
(
cmd
,
cwd
=
cwd
)
except
subprocess
.
CalledProcessError
:
except
subprocess
.
CalledProcessError
as
ex
:
log
.
exception
(
'Error running git pull:
%
r'
,
ex
.
output
)
raise
GitImportError
(
GitImportError
.
CANNOT_PULL
)
# get commit id
cmd
=
[
'git'
,
'log'
,
'-1'
,
'--format=
%
H'
,
]
try
:
commit_id
=
cmd_log
(
cmd
,
cwd
=
rdirp
)
except
subprocess
.
CalledProcessError
:
except
subprocess
.
CalledProcessError
as
ex
:
log
.
exception
(
'Unable to get git log:
%
r'
,
ex
.
output
)
raise
GitImportError
(
GitImportError
.
BAD_REPO
)
ret_git
+=
'
\n
Commit ID: {0}'
.
format
(
commit_id
)
# get branch
cmd
=
[
'git'
,
'
rev-parse'
,
'--abbrev-ref
'
,
'HEAD'
,
]
cmd
=
[
'git'
,
'
symbolic-ref'
,
'--short
'
,
'HEAD'
,
]
try
:
branch
=
cmd_log
(
cmd
,
cwd
=
rdirp
)
except
subprocess
.
CalledProcessError
:
except
subprocess
.
CalledProcessError
as
ex
:
# I can't discover a way to excercise this, but git is complex
# so still logging and raising here in case.
log
.
exception
(
'Unable to determine branch:
%
r'
,
ex
.
output
)
raise
GitImportError
(
GitImportError
.
BAD_REPO
)
ret_git
+=
'{0}Branch: {1}'
.
format
(
'
\n
'
,
branch
)
...
...
lms/djangoapps/dashboard/management/commands/tests/test_git_add_course.py
View file @
7d861245
...
...
@@ -102,3 +102,21 @@ class TestGitAddCourse(ModuleStoreTestCase):
with
self
.
assertRaisesRegexp
(
GitImportError
,
GitImportError
.
BAD_REPO
):
git_import
.
add_repo
(
'file://{0}'
.
format
(
bare_repo
),
None
)
def
test_detached_repo
(
self
):
"""
Test repo that is in detached head state.
"""
repo_dir
=
getattr
(
settings
,
'GIT_REPO_DIR'
)
# Test successful import from command
try
:
os
.
mkdir
(
repo_dir
)
except
OSError
:
pass
self
.
addCleanup
(
shutil
.
rmtree
,
repo_dir
)
git_import
.
add_repo
(
self
.
TEST_REPO
,
repo_dir
/
'edx4edx_lite'
)
subprocess
.
check_output
([
'git'
,
'checkout'
,
'HEAD~2'
,
],
stderr
=
subprocess
.
STDOUT
,
cwd
=
repo_dir
/
'edx4edx_lite'
)
with
self
.
assertRaisesRegexp
(
GitImportError
,
GitImportError
.
CANNOT_PULL
):
git_import
.
add_repo
(
self
.
TEST_REPO
,
repo_dir
/
'edx4edx_lite'
)
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