forked from ESCOMP/CTSM
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Squashed '.lib/git-fleximod/' content from commit 69a5dc5
git-subtree-dir: .lib/git-fleximod git-subtree-split: 69a5dc5
- Loading branch information
0 parents
commit 412e86c
Showing
21 changed files
with
2,134 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
name: pre-commit | ||
on: | ||
pull_request: | ||
push: | ||
branches: [main] | ||
|
||
jobs: | ||
pre-commit: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-python@v3 | ||
- uses: pre-commit/[email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
exclude: ^utils/.*$ | ||
|
||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.0.1 | ||
hooks: | ||
- id: end-of-file-fixer | ||
- id: trailing-whitespace | ||
- repo: https://github.com/psf/black | ||
rev: 22.3.0 | ||
hooks: | ||
- id: black | ||
- repo: https://github.com/PyCQA/pylint | ||
rev: v2.11.1 | ||
hooks: | ||
- id: pylint | ||
args: | ||
- --disable=I,C,R,logging-not-lazy,wildcard-import,unused-wildcard-import,fixme,broad-except,bare-except,eval-used,exec-used,global-statement,logging-format-interpolation,no-name-in-module,arguments-renamed,unspecified-encoding,protected-access,import-error,no-member |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Copyright 2024 National Center for Atmospheric Sciences (NCAR) | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
“Software”), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
# git-fleximod | ||
|
||
Flexible Submodule Management for Git | ||
|
||
## Overview | ||
|
||
Git-fleximod is a Python-based tool that extends Git's submodule capabilities, offering additional features for managing submodules in a more flexible and efficient way. | ||
|
||
## Installation | ||
|
||
#TODO Install using pip: | ||
# pip install git-fleximod | ||
If you choose to locate git-fleximod in your path you can access it via command: git fleximod | ||
|
||
## Usage | ||
|
||
Basic Usage: | ||
git fleximod <command> [options] | ||
Available Commands: | ||
checkout: Checkout submodules according to git submodule hash configuration. | ||
status: Display the status of submodules. | ||
update: Update submodules to the tag indicated in .gitmodules variable fxtag. | ||
test: Make sure that fxtags and submodule hashes are consistant, | ||
make sure that official urls (as defined by fxurl) are set | ||
make sure that fxtags are defined for all submodules | ||
Additional Options: | ||
See git fleximod --help for more details. | ||
|
||
## Supported .gitmodules Variables | ||
|
||
fxtag: Specify a specific tag or branch to checkout for a submodule. | ||
fxrequired: Mark a submodule's checkout behavior, with allowed values: | ||
- T:T: Top-level and required (checked out only when this is the Toplevel module). | ||
- T:F: Top-level and optional (checked out with --optional flag if this is the Toplevel module). | ||
- I:T: Internal and required (always checked out). | ||
- I:F: Internal and optional (checked out with --optional flag). | ||
fxsparse: Enable sparse checkout for a submodule, pointing to a file containing sparse checkout paths. | ||
fxurl: This is the url used in the test subcommand to assure that protected branches do not point to forks | ||
|
||
## Sparse Checkouts | ||
|
||
To enable sparse checkout for a submodule, set the fxsparse variable | ||
in the .gitmodules file to the path of a file containing the desired | ||
sparse checkout paths. Git-fleximod will automatically configure | ||
sparse checkout based on this file when applicable commands are run. | ||
See [git-sparse-checkout](https://git-scm.com/docs/git-sparse-checkout#_internalsfull_pattern_set) | ||
for details on the format of this file. | ||
|
||
## Tests | ||
|
||
The git fleximod test action is designed to be used by, for example, github workflows | ||
to assure that protected branches are consistant with respect to submodule hashes and fleximod fxtags | ||
|
||
## Examples | ||
|
||
Here are some common usage examples: | ||
|
||
Checkout submodules, including optional ones: | ||
```bash | ||
git fleximod checkout --optional | ||
``` | ||
|
||
Updating a specific submodule to the fxtag indicated in .gitmodules: | ||
|
||
```bash | ||
git fleximod update submodule-name | ||
``` | ||
Example .gitmodules entry: | ||
```ini, toml | ||
[submodule "cosp2"] | ||
path = src/physics/cosp2/src | ||
url = https://github.com/CFMIP/COSPv2.0 | ||
fxsparse = ../.cosp_sparse_checkout | ||
fxtag = v2.1.4cesm | ||
``` | ||
Explanation: | ||
|
||
This entry indicates that the submodule named cosp2 at tag v2.1.4cesm | ||
should be checked out into the directory src/physics/cosp2/src | ||
relative to the .gitmodules directory. It should be checked out from | ||
the URL https://github.com/CFMIP/COSPv2.0 and use sparse checkout as | ||
described in the file ../.cosp_sparse_checkout relative to the path | ||
directory. | ||
|
||
Additional example: | ||
```ini, toml | ||
[submodule "cime"] | ||
path = cime | ||
url = https://github.com/jedwards4b/cime | ||
fxrequired = T:T | ||
fxtag = cime6.0.198_rme01 | ||
``` | ||
|
||
Explanation: | ||
|
||
This entry indicates that the submodule cime should be checked out | ||
into a directory named cime at tag cime6.0.198_rme01 from the URL | ||
https://github.com/jedwards4b/cime. This should only be done if | ||
the .gitmodules file is at the top level of the repository clone. | ||
|
||
## Contributing | ||
|
||
We welcome contributions! Please see the CONTRIBUTING.md file for guidelines. | ||
|
||
## License | ||
|
||
Git-fleximod is released under the MIT License. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Minimal makefile for Sphinx documentation | ||
# | ||
|
||
# You can set these variables from the command line, and also | ||
# from the environment for the first two. | ||
SPHINXOPTS ?= | ||
SPHINXBUILD ?= sphinx-build | ||
SOURCEDIR = . | ||
BUILDDIR = _build | ||
|
||
# Put it first so that "make" without argument is like "make help". | ||
help: | ||
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) | ||
|
||
.PHONY: help Makefile | ||
|
||
# Catch-all target: route all unknown targets to Sphinx using the new | ||
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). | ||
%: Makefile | ||
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Configuration file for the Sphinx documentation builder. | ||
# | ||
# For the full list of built-in configuration values, see the documentation: | ||
# https://www.sphinx-doc.org/en/master/usage/configuration.html | ||
|
||
# -- Project information ----------------------------------------------------- | ||
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information | ||
|
||
project = "git-fleximod" | ||
author = "Jim Edwards <[email protected]>" | ||
release = "0.4.0" | ||
|
||
# -- General configuration --------------------------------------------------- | ||
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration | ||
|
||
extensions = ["sphinx_argparse_cli"] | ||
|
||
templates_path = ["_templates"] | ||
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] | ||
|
||
|
||
# -- Options for HTML output ------------------------------------------------- | ||
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output | ||
|
||
html_theme = "alabaster" | ||
html_static_path = ["_static"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
.. git-fleximod documentation master file, created by | ||
sphinx-quickstart on Sat Feb 3 12:02:22 2024. | ||
You can adapt this file completely to your liking, but it should at least | ||
contain the root `toctree` directive. | ||
Welcome to git-fleximod's documentation! | ||
======================================== | ||
|
||
.. toctree:: | ||
:maxdepth: 2 | ||
:caption: Contents: | ||
.. module:: sphinxcontrib.autoprogram | ||
.. sphinx_argparse_cli:: | ||
:module: git_fleximod.cli | ||
:func: get_parser | ||
:prog: git-fleximod | ||
|
||
|
||
Indices and tables | ||
================== | ||
|
||
* :ref:`genindex` | ||
* :ref:`modindex` | ||
* :ref:`search` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
@ECHO OFF | ||
|
||
pushd %~dp0 | ||
|
||
REM Command file for Sphinx documentation | ||
|
||
if "%SPHINXBUILD%" == "" ( | ||
set SPHINXBUILD=sphinx-build | ||
) | ||
set SOURCEDIR=. | ||
set BUILDDIR=_build | ||
|
||
%SPHINXBUILD% >NUL 2>NUL | ||
if errorlevel 9009 ( | ||
echo. | ||
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx | ||
echo.installed, then set the SPHINXBUILD environment variable to point | ||
echo.to the full path of the 'sphinx-build' executable. Alternatively you | ||
echo.may add the Sphinx directory to PATH. | ||
echo. | ||
echo.If you don't have Sphinx installed, grab it from | ||
echo.https://www.sphinx-doc.org/ | ||
exit /b 1 | ||
) | ||
|
||
if "%1" == "" goto help | ||
|
||
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% | ||
goto end | ||
|
||
:help | ||
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% | ||
|
||
:end | ||
popd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/env python | ||
# updates git-fleximod in an ESCOMP model | ||
# this script should be run from the model root directory, it expects | ||
# git-fleximod to already be installed with the script in bin | ||
# and the classes in lib/python/site-packages | ||
import sys | ||
import shutil | ||
import os | ||
|
||
from glob import iglob | ||
|
||
fleximod_root = sys.argv[1] | ||
fleximod_path = os.path.join(fleximod_root,"src","git-fleximod") | ||
if os.path.isfile(fleximod_path): | ||
with open(fleximod_path,"r") as f: | ||
fleximod = f.readlines() | ||
with open(os.path.join(".","bin","git-fleximod"),"w") as f: | ||
for line in fleximod: | ||
f.write(line) | ||
if "import argparse" in line: | ||
f.write('\nsys.path.append(os.path.join(os.path.dirname(__file__),"..","lib","python","site-packages"))\n\n') | ||
|
||
for file in iglob(os.path.join(fleximod_root, "src", "fleximod", "*.py")): | ||
shutil.copy(file, | ||
os.path.join("lib","python","site-packages","fleximod",os.path.basename(file))) |
Empty file.
Oops, something went wrong.