Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
justinfreeman (Agileware)
Core
Commits
d68421a7
Commit
d68421a7
authored
11 years ago
by
totten
Browse files
Options
Downloads
Patches
Plain Diff
gitify - Setup both "origin" and "upstream" remotes (optionally)
parent
1fe0e278
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bin/gitify
+48
-13
48 additions, 13 deletions
bin/gitify
with
48 additions
and
13 deletions
bin/gitify
+
48
−
13
View file @
d68421a7
...
...
@@ -4,6 +4,7 @@
#### Helpers ####
###########################################
## usage: do_gitify <repo-url> <existing-dir> [git-checkout-options]
function
do_gitify
()
{
REPO
=
"
$1
"
...
...
@@ -32,6 +33,7 @@ function do_gitify() {
rm
-rf
"
$TMP
"
}
###########################################
## add hook shims to a repo
## usage: do_hookify <canonical-repo-name> <repo-path> <relative-hook-path>
function
do_hookify
()
{
...
...
@@ -56,6 +58,21 @@ TMPL
fi
}
###########################################
## Create or update the URL of a git remote
## usage: git_set_remote <local-repo-path> <remote-name> <remote-url>
function
git_set_remote
()
{
REPODIR
=
"
$1
"
REMOTE_NAME
=
"
$2
"
REMOTE_URL
=
"
$3
"
echo
"[[Set remote (
$REMOTE_NAME
=>
$REMOTE_URL
within
$REPODIR
)]]"
pushd
"
$REPODIR
"
>>
/dev/null
git remote set-url
"
$REMOTE_NAME
"
"
$REMOTE_URL
"
>
/dev/null 2>&1
||
git remote add
"
$REMOTE_NAME
"
"
$REMOTE_URL
"
popd
>>
/dev/null
}
###########################################
## usage: do_svnify <repo-url> <existing-dir>
function
do_svnify
()
{
REPO
=
"
$1
"
...
...
@@ -74,6 +91,7 @@ function do_svnify() {
svn co
"
$REPO
"
"
$TGT
"
}
###########################################
## usage: do_gencode <civicrm-path>
function
do_gencode
()
{
pushd
"
$1
/xml"
>
/dev/null
...
...
@@ -86,10 +104,19 @@ function do_gencode() {
popd
>
/dev/null
}
###########################################
## config_repo <repo-name> <local-path> <default-branch> <git-scripts-path>
## 1 2 3 4
function
config_repo
()
{
do_gitify
"
${
GIT_BASE_URL
}
/
${
1
}
.git"
"
$2
"
-b
"
$3
"
do_gitify
"
${
UPSTREAM_
GIT_BASE_URL
}
/
${
1
}
.git"
"
$2
"
-b
"
$3
"
do_hookify
"
$1
"
"
$2
"
"
$4
"
## doesn't work with http -- git ls-remote "git://github.com/civicrm/civicrm-drupalz.git" HEAD --exit-code &>- ; echo $?
if
[
-n
"
$FORK_GIT_BASE_URL
"
]
;
then
git_set_remote
"
$2
"
upstream
"
${
UPSTREAM_GIT_BASE_URL
}
/
${
1
}
.git"
git_set_remote
"
$2
"
origin
"
${
FORK_GIT_BASE_URL
}
/
${
1
}
.git"
else
git_set_remote
"
$2
"
origin
"
${
UPSTREAM_GIT_BASE_URL
}
/
${
1
}
.git"
fi
}
function
check_dep
()
{
...
...
@@ -102,28 +129,33 @@ function check_dep() {
fi
}
#### Main: Parse arguments ####
###########################################
#### Main: Parse arguments
set
-e
CIVICRM_CMS
=
""
GIT_BASE_URL
=
""
CIVICRM_ROOT
=
""
CIVICRM_L10N
=
""
CIVICRM_GIT_HOOKS
=
""
CIVICRM_BRANCH
=
"master"
FORK_GIT_BASE_URL
=
""
UPSTREAM_GIT_BASE_URL
=
"https://github.com/civicrm"
while
[
-n
"
$1
"
]
;
do
if
[
"
$1
"
==
"--l10n"
]
;
then
CIVICRM_L10N
=
"
$1
"
elif
[
"
$1
"
==
"--hooks"
]
;
then
CIVICRM_GIT_HOOKS
=
"
$1
"
elif
[
"
$1
"
==
"--upstream"
]
;
then
shift
UPSTREAM_GIT_BASE_URL
=
"
$1
"
elif
[
"
$1
"
==
"--fork"
]
;
then
shift
FORK_GIT_BASE_URL
=
"
$1
"
elif
[
-z
"
$CIVICRM_CMS
"
]
;
then
## First arg
CIVICRM_CMS
=
"
$1
"
elif
[
-z
"
$GIT_BASE_URL
"
]
;
then
## Second arg
GIT_BASE_URL
=
"
$1
"
elif
[
-z
"
$CIVICRM_ROOT
"
]
;
then
## Third arg
CIVICRM_ROOT
=
"
$1
"
...
...
@@ -134,12 +166,14 @@ while [ -n "$1" ]; do
shift
done
if
[
-z
"
$CIVICRM_ROOT
"
-o
!
-d
"
$CIVICRM_ROOT
"
-o
-z
"
$GIT_BASE_URL
"
-o
-z
"
$CIVICRM_CMS
"
]
;
then
if
[
-z
"
$CIVICRM_ROOT
"
-o
!
-d
"
$CIVICRM_ROOT
"
-o
-z
"
$
UPSTREAM_
GIT_BASE_URL
"
-o
-z
"
$CIVICRM_CMS
"
]
;
then
echo
"Convert a directory into a set of CiviCRM git clones"
echo
"usage:
$0
<Drupal|Drupal6|Joomla|WordPress|all>
<git-base-url>
<existing-civicrm-root> [--l10n] [--hooks]"
echo
"usage:
$0
<Drupal|Drupal6|Joomla|WordPress|all> <existing-civicrm-root>
[--fork <base-url>] [--upstream <base-url>]
[--l10n] [--hooks]"
echo
" <cms-name>: one of: Drupal|Drupal6|Joomla|WordPress|all"
echo
" <git-base-url>: a base URL shared by the desiried git repos (e.g. git://github.com/civicrm)"
echo
" <existing-civicrm-root>: the main directory containing CiviCRM"
echo
" --upstream <base-url>: specify the base URL for upstream repositories"
echo
" --fork <base-url>: specify the base URL for your personal fork repositories"
echo
" --l10n: optionally fetch localization data; currently requires svn"
echo
" --hooks: optionally install recommended git hooks; the hooks are mostly"
echo
" tested with git CLI under Linux and OSX; they haven't been"
...
...
@@ -148,17 +182,18 @@ if [ -z "$CIVICRM_ROOT" -o ! -d "$CIVICRM_ROOT" -o -z "$GIT_BASE_URL" -o -z "$CI
echo
"Note: If pointing to a pre-existing directory, your local changes may be replaced by"
echo
"the pristine code from git/svn. If you've made changes, then make sure there's a backup!"
echo
""
echo
"example:
$0
Drupal
git://github.com/civicrm
/var/www/drupal7/sites/all/modules/civicrm"
echo
" (checkout core code plus Drupal 7.x integration code
using Git's read-only protocol
)"
echo
"example:
$0
Drupal /var/www/drupal7/sites/all/modules/civicrm"
echo
" (checkout core code plus Drupal 7.x integration code)"
echo
""
echo
"example:
$0
Drupal6
https://github.com/civicrm
/var/www/drupal6/sites/all/modules/civicrm"
echo
" (checkout core code plus Drupal 6.x integration code
using read-only HTTP protocol
)"
echo
"example:
$0
Drupal6 /var/www/drupal6/sites/all/modules/civicrm"
echo
" (checkout core code plus Drupal 6.x integration code)"
echo
""
echo
"example:
$0
all git@github.com:civicrm
~/src/civicrm
l10n"
echo
"example:
$0
all
~/src/civicrm --upstream
git@github.com:civicrm
--
l10n"
echo
" (checkout core code plus Drupal 7.x, Joomla, and WordPress integration code and l10n using SSH)"
exit
1
fi
###########################################
#### Main: Update git repo metadata ####
check_dep
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment