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
561c8192
Commit
561c8192
authored
1 year ago
by
Ronald Jäpel
Browse files
Options
Downloads
Patches
Plain Diff
Update class init
parent
af5a0379
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
git_lfs_utils/utils.py
+20
-16
20 additions, 16 deletions
git_lfs_utils/utils.py
with
20 additions
and
16 deletions
git_lfs_utils/utils.py
+
20
−
16
View file @
561c8192
...
...
@@ -10,6 +10,26 @@ def update_package_list():
class
GitRepo
(
git
.
Repo
):
def
__init__
(
self
,
repository_path
=
None
,
*
args
,
**
kwargs
):
if
repository_path
is
None
:
starting_path
=
os
.
getcwd
()
path
=
starting_path
else
:
starting_path
=
repository_path
path
=
repository_path
repository_found
=
False
while
repository_found
is
False
:
# step upwards in path until a git repo is found or root is reached
try
:
super
().
__init__
(
path
,
*
args
,
**
kwargs
)
repository_found
=
True
except
git
.
exc
.
InvalidGitRepositoryError
:
# Step upwards in the path once
path
,
directory
=
os
.
path
.
split
(
path
)
if
len
(
directory
)
==
0
:
# This means that root was reached without finding a git repo.
raise
ValueError
(
f
"
Path
{
starting_path
}
does not contain a git repository.
"
)
def
add_all_files
(
self
):
if
len
(
self
.
untracked_files
)
>
0
:
untracked_files
=
"
\n
"
.
join
([
"
-
"
+
file
for
file
in
self
.
untracked_files
])
...
...
@@ -43,19 +63,3 @@ class GitRepo(git.Repo):
def
print_status
(
self
):
print
(
self
.
git
.
status
())
def
get_git_repo
():
cwd
=
os
.
getcwd
()
path
=
cwd
repository
=
None
while
repository
is
None
:
# step upwards in path until a git repo is found or root is reached
try
:
repository
=
GitRepo
(
path
)
except
git
.
exc
.
InvalidGitRepositoryError
:
base
,
directory
=
os
.
path
.
split
(
path
)
if
len
(
directory
)
==
0
:
raise
ValueError
(
f
"
Path
{
cwd
}
does not contain a git repository.
"
)
path
=
base
return
repository
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