summaryrefslogtreecommitdiff
path: root/update-submodule
blob: 3bd04b7a43087eb2f46bb306c211e48b646c89c2 (plain)
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
#!/bin/bash

url="$1"
pkgSrcDir="${url%% *}"
url="${url#${path} }"
submoduleDir="${url%% *}"
url="${url#${path} }"
path="${url%% *}"
url="${url#${path} }"

if [ -n "$(ls -A "${path}")" ]; then
  git -C "${pkgSrcDir}" submodule update 2>/dev/null || true
  exit
fi
mkdir -p "${path}"
if [ -n "${submoduleDir}" ]; then
  upstream="${submoduleDir}/${path}"
  if [ ! -d "${upstream}" ]; then
    git clone -q "${url}" "${upstream}"
  fi
else
  upstream="${pkgSrcDir}/${path}"
fi
git -C "${upstream}" pull -q --ff-only
git clone -q "${upstream}" "${path}"