Skip to content

Commit 1f10043

Browse files
authored
Merge pull request #27 from WCRP-CMIP/copier
Fixing the utils init links
2 parents 01c3f2a + 84264b0 commit 1f10043

File tree

89 files changed

+7333
-6166
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+7333
-6166
lines changed

MANIFEST.in

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
include README.md
2+
include cmipld/prefix_mappings.json
3+
recursive-include cmipld/scripts *
4+
recursive-exclude cmipld/scripts *.pyc
5+
recursive-exclude cmipld/scripts __pycache__

bin/cmipld-help

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#!/bin/bash
2+
# cmipld-help - Show help for all CMIP-LD commands
3+
#
4+
# Usage: cmipld-help [command]
5+
#
6+
# Description:
7+
# Shows help information for all CMIP-LD commands or specific command details.
8+
9+
if [[ "$1" == "-h" ]] || [[ "$1" == "--help" ]]; then
10+
echo "cmipld-help - Show help for all CMIP-LD commands"
11+
echo ""
12+
echo "Usage: cmipld-help [command]"
13+
echo ""
14+
echo "Description:"
15+
echo " Shows help information for all CMIP-LD commands or specific command details."
16+
echo ""
17+
echo "Arguments:"
18+
echo " command Specific command to get help for (optional)"
19+
exit 0
20+
fi
21+
22+
if [[ -n "$1" ]]; then
23+
# Show help for specific command
24+
command -v "$1" >/dev/null 2>&1 && "$1" --help || echo "Command '$1' not found."
25+
exit 0
26+
fi
27+
28+
echo "CMIP-LD Command Line Tools"
29+
echo "=========================="
30+
echo ""
31+
32+
echo "Core Commands:"
33+
echo " ld2graph Create graph.jsonld from directory of JSON-LD files"
34+
echo " cmipld Main CMIP-LD browser interface"
35+
echo ""
36+
37+
echo "Generation & Updates:"
38+
echo " update_ctx Update JSON-LD context files"
39+
echo " update_all Run full update process (contexts + graphs)"
40+
echo " generate_summary Generate repository summary"
41+
echo " update_readme Update README files"
42+
echo " create_readme Create README files"
43+
echo ""
44+
45+
echo "Validation:"
46+
echo " validjsonld Validate JSON-LD files in directory"
47+
echo " validate_json Validate JSON-LD files"
48+
echo ""
49+
50+
echo "Development:"
51+
echo " dev Quick git development workflow"
52+
echo " new_issue Generate new GitHub issue"
53+
echo " coauthor_file Add co-author to git commit for specific file"
54+
echo ""
55+
56+
echo "Cleanup:"
57+
echo " rmbak Remove .bak files recursively"
58+
echo " rmgraph Remove graph.json files recursively"
59+
echo ""
60+
61+
echo "Usage:"
62+
echo " <command> --help Show detailed help for any command"
63+
echo " cmipld-help <cmd> Show help for specific command"
64+
echo ""
65+
66+
echo "Examples:"
67+
echo " ld2graph src-data/experiment/"
68+
echo " validjsonld"
69+
echo " update_all"
70+
echo " dev"

bin/coauthor_file

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
#!/bin/bash
2+
# coauthor_file - Add co-author to git commit for specific file
3+
#
4+
# Usage: coauthor_file <file> <co-author-email>
5+
#
6+
# Description:
7+
# Adds a co-author to the last git commit that modified the specified file.
8+
# Uses interactive rebase to amend the commit message with co-author information.
9+
#
10+
# Arguments:
11+
# file File to find the last commit for
12+
# co-author-email Email address of the co-author to add
13+
#
14+
# Examples:
15+
# coauthor_file src/main.py [email protected]
16+
# coauthor_file README.md [email protected]
17+
18+
# Show help if requested
19+
if [[ "$1" == "-h" ]] || [[ "$1" == "--help" ]] || [[ $# -ne 2 ]]; then
20+
echo "coauthor_file - Add co-author to git commit for specific file"
21+
echo ""
22+
echo "Usage: coauthor_file <file> <co-author-email>"
23+
echo ""
24+
echo "Description:"
25+
echo " Adds a co-author to the last git commit that modified the specified file."
26+
echo " Uses interactive rebase to amend the commit message with co-author information."
27+
echo ""
28+
echo "Arguments:"
29+
echo " file File to find the last commit for"
30+
echo " co-author-email Email address of the co-author to add"
31+
echo ""
32+
echo "Examples:"
33+
echo " coauthor_file src/main.py [email protected]"
34+
echo " coauthor_file README.md [email protected]"
35+
echo ""
36+
echo "Warning:"
37+
echo " This command rewrites git history. Use with caution, especially on shared repositories."
38+
echo ""
39+
echo "Requirements:"
40+
echo " - git command"
41+
echo " - Must be in a git repository"
42+
echo " - File must exist in git history"
43+
if [[ $# -ne 2 ]]; then
44+
exit 1
45+
fi
46+
exit 0
47+
fi
48+
49+
FILE="$1"
50+
COAUTHOR_EMAIL="$2"
51+
52+
echo "Finding last commit for file: $FILE" >&2
53+
54+
# Get the last commit hash that modified the file
55+
LAST_COMMIT=$(git log -n 1 --pretty=format:%H -- "$FILE")
56+
57+
if [ -z "$LAST_COMMIT" ]; then
58+
echo "Error: No commits found for file: $FILE" >&2
59+
exit 1
60+
fi
61+
62+
echo "Last commit: $LAST_COMMIT" >&2
63+
64+
# Get the author's name from the email
65+
COAUTHOR_NAME=$(git log --format='%aN <%aE>' | grep "$COAUTHOR_EMAIL" | head -n 1 | sed -E 's/ <.*>//')
66+
67+
if [ -z "$COAUTHOR_NAME" ]; then
68+
echo "Error: Could not determine author name for email: $COAUTHOR_EMAIL" >&2
69+
echo "Make sure the email address has been used in previous commits." >&2
70+
exit 1
71+
fi
72+
73+
echo "Co-author: $COAUTHOR_NAME <$COAUTHOR_EMAIL>" >&2
74+
75+
# Start an interactive rebase to modify the commit
76+
echo "Starting interactive rebase..." >&2
77+
git rebase -i "${LAST_COMMIT}^" <<EOF
78+
pick $LAST_COMMIT
79+
EOF
80+
81+
# Amend the commit to add the co-author
82+
echo "Adding co-author to commit..." >&2
83+
git commit --amend -m "$(git log -1 --pretty=%B)
84+
85+
Co-authored-by: $COAUTHOR_NAME <$COAUTHOR_EMAIL>"
86+
87+
# Continue the rebase process
88+
echo "Continuing rebase..." >&2
89+
git rebase --continue
90+
91+
# Push changes (force required)
92+
echo "Force pushing changes..." >&2
93+
git push --force
94+
95+
echo "✓ Co-author added successfully!" >&2

bin/dev

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/bin/bash
2+
# dev - Quick git development workflow
3+
#
4+
# Usage: dev
5+
#
6+
# Description:
7+
# Performs a quick development workflow: pull latest changes, add all files,
8+
# commit with a generic 'development' message, and push to remote.
9+
#
10+
# Examples:
11+
# dev
12+
13+
# Show help if requested
14+
if [[ "$1" == "-h" ]] || [[ "$1" == "--help" ]]; then
15+
echo "dev - Quick git development workflow"
16+
echo ""
17+
echo "Usage: dev"
18+
echo ""
19+
echo "Description:"
20+
echo " Performs a quick development workflow: pull latest changes, add all files,"
21+
echo " commit with a generic 'development' message, and push to remote."
22+
echo ""
23+
echo "Examples:"
24+
echo " dev"
25+
echo ""
26+
echo "Warning:"
27+
echo " This command makes automatic commits. Use with caution in production repositories."
28+
echo ""
29+
echo "Requirements:"
30+
echo " - git command"
31+
echo " - Must be in a git repository"
32+
echo " - Remote repository must be configured"
33+
exit 0
34+
fi
35+
36+
echo "Starting development workflow..." >&2
37+
38+
echo "Pulling latest changes..." >&2
39+
git pull
40+
41+
echo "Adding all changes..." >&2
42+
git add -A
43+
44+
echo "Committing with 'development' message..." >&2
45+
git commit -m 'development'
46+
47+
echo "Pushing to remote..." >&2
48+
git push
49+
50+
echo "Current directory: $(pwd)" >&2
51+
echo "Development workflow complete!" >&2

0 commit comments

Comments
 (0)