Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(hooks): update pre-commit hook #76

Merged
merged 2 commits into from
Jan 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

## Automated Testing Status on Travis-CI

### Version 6.0.3 patch-getmfexes — build 50
[![Build Status](https://travis-ci.org/MODFLOW-USGS/modflow6.svg?branch=patch-getmfexes)](https://travis-ci.org/MODFLOW-USGS/modflow6)
### Version 6.0.3 develop — build 38
[![Build Status](https://travis-ci.org/MODFLOW-USGS/modflow6.svg?branch=develop)](https://travis-ci.org/MODFLOW-USGS/modflow6)

## Introduction

Expand All @@ -31,8 +31,7 @@ MODFLOW 6 is the latest core version of MODFLOW. It synthesizes many of the capa

#### ***Software/Code citation for MODFLOW 6:***

[Langevin, C.D., Hughes, J.D., Banta, E.R., Provost, A.M., Niswonger, R.G., and Panday, Sorab, 2019, MODFLOW 6 Modular Hydrologic Model version 6.0.3 — patch-getmfexes: U.S. Geological Survey Software Release, 07 January 2019, https://doi.org/10.5066/F76Q1VQV](https://doi.org/10.5066/F76Q1VQV)

[Langevin, C.D., Hughes, J.D., Banta, E.R., Provost, A.M., Niswonger, R.G., and Panday, Sorab, 2019, MODFLOW 6 Modular Hydrologic Model version 6.0.3 — develop: U.S. Geological Survey Software Release, 07 January 2019, https://doi.org/10.5066/F76Q1VQV](https://doi.org/10.5066/F76Q1VQV)

## Instructions for building definition files for new packages

Expand Down
38 changes: 19 additions & 19 deletions code.json
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
[
{
"status": "Release Candidate",
"status": "Release Candidate",
"languages": [
"Fortran2008"
],
"repositoryURL": "https://code.usgs.gov/usgs/modflow/modflow6.git",
"disclaimerURL": "https://code.usgs.gov/usgs/modflow/modflow6/blob/master/DISCLAIMER.md",
],
"repositoryURL": "https://code.usgs.gov/usgs/modflow/modflow6.git",
"disclaimerURL": "https://code.usgs.gov/usgs/modflow/modflow6/blob/master/DISCLAIMER.md",
"tags": [
"MODFLOW",
"MODFLOW",
"groundwater model"
],
"vcs": "git",
"name": "modflow6",
"downloadURL": "https://code.usgs.gov/usgs/modflow/modflow6/archive/master.zip",
],
"vcs": "git",
"name": "modflow6",
"downloadURL": "https://code.usgs.gov/usgs/modflow/modflow6/archive/master.zip",
"contact": {
"name": "Christian D. Langevin",
"name": "Christian D. Langevin",
"email": "langevin@usgs.gov"
},
"laborHours": -1,
"version": "6.0.3.50",
},
"laborHours": -1,
"version": "6.0.3.38",
"date": {
"metadataLastUpdated": "2019-01-07"
},
"organization": "U.S. Geological Survey",
},
"organization": "U.S. Geological Survey",
"permissions": {
"licenses": [
{
"URL": "https://code.usgs.gov/usgs/modflow/modflow6/blob/master/LICENSE.md",
"URL": "https://code.usgs.gov/usgs/modflow/modflow6/blob/master/LICENSE.md",
"name": "Public Domain, CC0-1.0"
}
],
],
"usageType": "openSource"
},
"homepageURL": "https://code.usgs.gov/usgs/modflow/modflow6/",
},
"homepageURL": "https://code.usgs.gov/usgs/modflow/modflow6/",
"description": "MODFLOW is the USGS's modular hydrologic model. MODFLOW is considered an international standard for simulating and predicting groundwater conditions and groundwater/surface-water interactions."
}
]
2 changes: 1 addition & 1 deletion doc/version.tex
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
\newcommand{\modflowversion}{mf6.0.3.50}
\newcommand{\modflowversion}{mf6.0.3.38}
\newcommand{\modflowdate}{January 07, 2019}
\newcommand{\currentmodflowversion}{Version \modflowversion---\modflowdate}
97 changes: 89 additions & 8 deletions pre-commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from hook_files import paths, files

prod = 'MODFLOW 6'
repo = 'MODFLOW-USGS/modflow6.git'

approved = '''Disclaimer
----------
Expand Down Expand Up @@ -102,6 +103,14 @@ def get_disclaimerfmt(branch):


def update_version():
"""
Update the version number

Returns
-------
None

"""
try:
vmajor = 0
vminor = 0
Expand Down Expand Up @@ -218,19 +227,90 @@ def add_updated_files():
print('Could not add updated files')
sys.exit(1)

def get_branch():
def is_fork():
"""
Determine if repository is a fork of the main repository

Returns
-------
fork : bool
Boolean indicating if repository is a fork of the main repository. If
remote named 'origin' is does not contain the main repository path then
it is assumed that the repository is a fork of the main repository.


"""
fork = True
try:
# determine current buildstat branch
b = subprocess.Popen(("git", "status"),
b = subprocess.Popen(("git", "remote", "--verbose"),
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT).communicate()[0]
if isinstance(b, bytes):
b = b.decode('utf-8')

# determine current buildstat branch
# determine if repository origin is the main repository
for line in b.splitlines():
if 'On branch' in line:
branch = line.replace('On branch ', '').rstrip()
if 'origin' in line.lower():
if repo in line:
fork = False
except:
pass

return fork

def readme_lines():
"""
Read all lines in README.md

Returns
-------
lines : list of strings
List containing all lines in README.md with line termination character
removed.

"""
with open(files[2], 'r') as file:
lines = [line.rstrip() for line in file]
return lines

def get_branch():
"""
Get the branch name

Returns
-------
branch : str
Branch name. branch is None if README.md cannot be parsed, if a fork of
the main repository, or if git status does not return a string that can
be parsed.

"""
fork = is_fork()
try:
if fork:
# read README.md into memory
lines = readme_lines()

# ### Version 6.0.3 develop —
for line in lines:
if '### Version' in line and ' —' in line:
line = line.replace('### Version ', '')
line = line.replace(' —', '')
t = line.split()
branch = t[1]
else:
# determine current buildstat branch
b = subprocess.Popen(("git", "status"),
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT).communicate()[0]
if isinstance(b, bytes):
b = b.decode('utf-8')

# determine current buildstat branch
for line in b.splitlines():
if 'On branch' in line:
branch = line.replace('On branch ', '').rstrip()
except:
branch = None

Expand All @@ -240,7 +320,9 @@ def get_branch():
def update_mf6_version(vmajor, vminor, vmicro, vbuild):
branch = get_branch()
if branch is None:
print('Cannot update MODFLOW 6 version - could not determine current branch')
msg = 'Cannot update MODFLOW 6 version - ' + \
'could not determine current branch'
print(msg)
return

# create version
Expand Down Expand Up @@ -300,8 +382,7 @@ def update_readme_markdown(vmajor, vminor, vmicro, vbuild):
disclaimer = get_disclaimer(branch)

# read README.md into memory
with open(files[2], 'r') as file:
lines = [line.rstrip() for line in file]
lines = readme_lines()

# rewrite README.md
terminate = False
Expand Down
2 changes: 1 addition & 1 deletion src/Utilities/version.f90
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module VersionModule
public
! -- modflow 6 version
integer(I4B), parameter :: IDEVELOPMODE = 1
character(len=40), parameter :: VERSION = '6.0.3.50 01/07/2019'
character(len=40), parameter :: VERSION = '6.0.3.38 01/07/2019'
character(len=10), parameter :: MFVNAM = ' 6'
character(len=*), parameter :: MFTITLE = &
'U.S. GEOLOGICAL SURVEY MODULAR HYDROLOGIC MODEL'
Expand Down
6 changes: 3 additions & 3 deletions version.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# MODFLOW 6 version file automatically created using...pre-commit.py
# created on...January 07, 2019 14:05:16
# created on...January 07, 2019 15:41:48

# add some comments on how this version file
# should be manually updated and used

major = 6
minor = 0
micro = 3
build = 50
commit = 151
build = 38
commit = 139