Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CADET-RDM
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IBG-1
ModSim
CADET
CADET-RDM
Commits
7c8ac579
Commit
7c8ac579
authored
1 year ago
by
Ronald Jäpel
Browse files
Options
Downloads
Patches
Plain Diff
Refactor user input
parent
0051efec
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
cadetrdm/initialize_repo.py
+5
-5
5 additions, 5 deletions
cadetrdm/initialize_repo.py
cadetrdm/io_utils.py
+8
-0
8 additions, 0 deletions
cadetrdm/io_utils.py
cadetrdm/repositories.py
+7
-6
7 additions, 6 deletions
cadetrdm/repositories.py
with
20 additions
and
11 deletions
cadetrdm/initialize_repo.py
+
5
−
5
View file @
7c8ac579
...
...
@@ -12,7 +12,7 @@ except ImportError:
import
cadetrdm
from
cadetrdm.repositories
import
ProjectRepo
,
OutputRepo
from
cadetrdm.web_utils
import
ssh_url_to_http_url
from
cadetrdm.io_utils
import
write_lines_to_file
,
is_tool
from
cadetrdm.io_utils
import
write_lines_to_file
,
is_tool
,
wait_for_user
def
init_lfs
(
lfs_filetypes
:
list
,
path
:
str
=
None
):
...
...
@@ -130,10 +130,10 @@ def initialize_git(folder="."):
try
:
repo
=
git
.
Repo
(
"
.
"
)
proceed
=
input
(
f
'
The target directory already contains a git repo.
\n
'
f
'
Please back up or push all changes to the repo before continuing.
'
f
'
Proceed?
Y/n
\n
'
)
if
not
(
proceed
.
lower
()
==
"
y
"
or
proceed
==
""
)
:
proceed
=
wait_for_user
(
'
The target directory already contains a git repo.
\n
'
'
Please back up or push all changes to the repo before continuing.
\n
'
'
Proceed?
'
)
if
not
proceed
:
raise
KeyboardInterrupt
except
git
.
exc
.
InvalidGitRepositoryError
:
os
.
system
(
f
"
git init
"
)
...
...
This diff is collapsed.
Click to expand it.
cadetrdm/io_utils.py
+
8
−
0
View file @
7c8ac579
...
...
@@ -70,3 +70,11 @@ def delete_path(filename):
shutil
.
rmtree
(
absolute_path
,
onerror
=
remove_readonly
)
else
:
os
.
remove
(
absolute_path
)
def
wait_for_user
(
message
):
proceed
=
input
(
message
+
"
Y/n
\n
"
)
if
proceed
.
lower
()
==
"
y
"
or
proceed
==
""
:
return
True
else
:
return
False
This diff is collapsed.
Click to expand it.
cadetrdm/repositories.py
+
7
−
6
View file @
7c8ac579
...
...
@@ -14,7 +14,8 @@ from urllib.request import urlretrieve
from
tabulate
import
tabulate
import
pandas
as
pd
from
cadetrdm.io_utils
import
recursive_chmod
,
write_lines_to_file
from
cadetrdm.io_utils
import
recursive_chmod
,
write_lines_to_file
,
wait_for_user
from
cadetrdm.jupyter_functionality
import
Notebook
from
cadetrdm.version
import
version
as
cadetrdm_version
try
:
...
...
@@ -371,11 +372,11 @@ class BaseRepo:
self
.
add
(
"
.
"
)
def
reset_hard_to_head
(
self
):
proceed
=
input
(
f
'
The output directory contains the following uncommitted changes:
\n
'
f
'
{
self
.
untracked_files
+
self
.
changed_files
}
\n
'
f
'
These will be lost if you continue
\n
'
f
'
Proceed?
Y/n
\n
'
)
if
not
(
proceed
.
lower
()
==
"
y
"
or
proceed
==
""
)
:
proceed
=
wait_for_user
(
f
'
The output directory contains the following uncommitted changes:
\n
'
f
'
{
self
.
untracked_files
+
self
.
changed_files
}
\n
'
f
'
These will be lost if you continue
\n
'
f
'
Proceed?
'
)
if
not
proceed
:
raise
KeyboardInterrupt
# reset all tracked files to previous commit, -q silences output
self
.
_git
.
reset
(
"
-q
"
,
"
--hard
"
,
"
HEAD
"
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment