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

Bare repo script #146

Merged
merged 5 commits into from
Mar 1, 2023
Merged
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
50 changes: 50 additions & 0 deletions scripts/new_bare_repo
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/bash
usage()
{
cat << EOF
usage: new_bare_repo <hutch> <repo name>

Script for automating the tedious process of integrating an existing IOC into our git bare repo scheme
Run in the top level of your IOC

Ex. new_bare_repo rix new_device
(Creates a new bare repo in /afs/slac.stanford.edu/g/cd/swe/git/repos/package/epics/ioc/rix/ named "new_device.git")

You also might need to run kinit and aklog before hand!
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of scope for this PR, I'm thinking we might want to add an engineering tools script that checks if kinit/aklog needs to be run (and optionally, runs it). This is doable using the output of the klist command.

Would something like this have been useful when writing this script?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally, I am not even sure when to run kinit or not... It's usually something I only run when I get an error message with git that I can't explain otherwise

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added an issue for this, I might get around to it at some point: #147


EOF
}

if [[ ($1 == "--help") || ($1 == "-h") ]]; then
usage
exit 0

elif [ $# -lt 2 ]; then
echo 'Need to specify the hutch and name of the proposed bare repo' >&2
usage
exit 1

fi

HUTCH=$1
REPO=$2
CWD=$PWD

set -e
if [ ! -d "/afs/slac.stanford.edu/g/cd/swe/git/repos/package/epics/ioc/${HUTCH}/" ]
echo "The directory /afs/slac.stanford.edu/g/cd/swe/git/repos/package/epics/ioc/${HUTCH}/ does not exist!"
wnwright marked this conversation as resolved.
Show resolved Hide resolved
exit 1
elif [ -d "/afs/slac.stanford.edu/g/cd/swe/git/repos/package/epics/ioc/${HUTCH}/${REPO}.git" ]
echo "There already exists a bare repo for this device!"
exit 1
elif [ ${CWD} != *${REPO}* ]
echo "Current working directory does not contain the name of the planned repo, check that you are running this script in the right place"
exit 1
else
git init
ZLLentz marked this conversation as resolved.
Show resolved Hide resolved
cp -u /cds/sw/tools/bin/eco_tools/gitignore.template .gitignore
git add *.cfg Makefile .gitignore
git commit -m "Initial commit"
git-bare-repo /afs/slac.stanford.edu/g/cd/swe/git/repos/package/epics/ioc/${HUTCH}/${REPO}.git
git remote add origin /afs/slac.stanford.edu/g/cd/swe/git/repos/package/epics/ioc/${HUTCH}/${REPO}.git
fi