Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
TherMod
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
Releases
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ghsc
National Seismic Hazard Model Project
National Crustal Model
TherMod
Commits
876e2804
Commit
876e2804
authored
5 months ago
by
Clayton, Brandon Scott
Browse files
Options
Downloads
Patches
Plain Diff
add script
parent
84d8b31b
No related branches found
No related tags found
1 merge request
!17
Version
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts.py
+31
-2
31 additions, 2 deletions
scripts.py
with
31 additions
and
2 deletions
scripts.py
+
31
−
2
View file @
876e2804
"""
Scripts for Poetry
"""
import
json
import
os
import
re
import
sys
from
subprocess
import
check_call
...
...
@@ -10,6 +12,33 @@ from subprocess import check_call
_project
=
"
thermod
"
def
app_version
():
import
git
version_file
=
open
(
f
"
{
_project
}
/resources/app-version.json
"
,
"
w+
"
)
try
:
repo
=
git
.
Repo
(
"
.
"
)
gitHash
=
repo
.
head
.
commit
.
hexsha
version
=
repo
.
git
.
describe
(
tags
=
True
,
first_parent
=
True
,
always
=
True
)
url
=
os
.
environ
.
get
(
"
CI_PROJECT_URL
"
,
repo
.
remotes
.
origin
.
url
)
if
"
gitlab-ci-token
"
in
url
:
url
=
re
.
sub
(
r
"
gitlab-ci-token\:.*@
"
,
""
,
url
)
version_info
=
dict
(
gitHash
=
gitHash
,
projectName
=
"
ncm-ws
"
,
url
=
url
,
version
=
version
,
)
version_file
.
write
(
json
.
dumps
(
version_info
,
indent
=
2
))
except
Exception
as
error
:
print
(
"
Failed to create version file. Writing blank file.
"
)
version_file
.
write
(
json
.
dumps
(
"
{}
"
))
def
setup
():
# Setup GitHooks
os
.
system
(
"
git config core.hookspath .githooks
"
)
...
...
@@ -41,8 +70,8 @@ def help():
def
format_check
():
# Check code format
check_call
([
"
isort
"
,
"
--check
"
,
"
--diff
"
,
"
.
"
,
"
--skip
"
,
"
.
poetry
"
])
check_call
([
"
black
"
,
"
--check
"
,
"
--diff
"
,
"
.
"
,
"
--exclude
"
,
"
.
poetry
"
])
check_call
([
"
isort
"
,
"
--check
"
,
"
--diff
"
,
"
.
"
,
"
--skip
"
,
"
.
venv
"
])
check_call
([
"
black
"
,
"
--check
"
,
"
--diff
"
,
"
.
"
,
"
--exclude
"
,
"
.
venv
"
])
def
format
():
...
...
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