-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.zsh
More file actions
executable file
·55 lines (49 loc) · 1.83 KB
/
setup.zsh
File metadata and controls
executable file
·55 lines (49 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env zsh
# OpenSecOps Foundation Component Git Repository Setup
#
# This script configures the dual-repository workflow used by OpenSecOps Foundation components,
# setting up proper git remotes for both development and publication workflows.
#
# What it configures:
# - 'origin' remote: Points to development repository (e.g., PeterBengtson/Component-DEV)
# - 'OpenSecOps' remote: Points to published repository (OpenSecOps-Org/Component)
#
# The dual-repository pattern enables:
# - Messy development commits in personal repositories
# - Clean release-only history in public OpenSecOps repositories
# - Professional presentation without losing development history
#
# This setup is required before using the ./publish script to create clean releases.
#
# Usage:
# ./setup [component-name] # Component name for published repository
#
# Run this script once when setting up a new Foundation component to enable the
# publishing workflow that maintains clean public repository history.
# Check for uncommitted changes
if ! git diff-index --quiet HEAD --; then
echo "There are uncommitted changes. Please commit or stash them before running this script."
exit 1
fi
# Check for repository name argument
if [ -z "$1" ]; then
echo "Please provide the repository name (e.g., SOAR-releases)."
exit 1
fi
REPO_NAME=$1
# Add OpenSecOps organization repository as a remote (if it doesn't already exist)
if ! git remote | grep -q 'OpenSecOps'; then
git remote add OpenSecOps "https://github.com/OpenSecOps-Org/$REPO_NAME.git"
if [ $? -ne 0 ]; then
echo "Error: Failed to add 'OpenSecOps' remote."
exit 1
fi
else
echo "'OpenSecOps' remote already exists"
fi
# Switch back to the main branch before finishing
git checkout main
if [ $? -ne 0 ]; then
echo "Error: Failed to switch back to 'main' branch."
exit 1
fi