File tree Expand file tree Collapse file tree 1 file changed +12
-13
lines changed
Expand file tree Collapse file tree 1 file changed +12
-13
lines changed Original file line number Diff line number Diff line change 88 * If not specified, will get current git HEAD branch as default branch to deploy.
99 */
1010set ('branch ' , function () {
11- try {
12- $ branch = runLocally ('git rev-parse --abbrev-ref HEAD ' );
13- } catch (\Throwable $ e ) {
14- $ branch = null ;
15- }
16-
1711 if (input ()->hasOption ('branch ' ) && !empty (input ()->getOption ('branch ' ))) {
18- $ branch = input ()->getOption ('branch ' );
12+ return input ()->getOption ('branch ' );
1913 }
20-
21- return $ branch ;
14+ return null ;
2215});
2316
2417/**
3023 $ branch = get ('branch ' );
3124 $ git = get ('bin/git ' );
3225
33- $ at = '' ;
26+ $ at = 'HEAD ' ;
3427 if (!empty ($ branch )) {
3528 $ at = $ branch ;
3629 }
6255 }
6356 }
6457
65- // Clone the repository to a bare repo.
6658 $ bare = parse ('{{deploy_path}}/.dep/repo ' );
59+
60+ start:
61+ // Clone the repository to a bare repo.
6762 run ("[ -d $ bare ] || mkdir -p $ bare " );
6863 run ("[ -f $ bare/HEAD ] || $ git clone --mirror $ repository $ bare 2>&1 " );
6964
7065 cd ($ bare );
7166
72- // If remote url changed, update it in `.git/repo` as well.
73- run ("[[ $( $ git remote get-url origin) == ' $ repository' ]] || $ git remote set-url origin $ repository " );
67+ // If remote url changed, drop `.git/repo` and reinstall.
68+ if (run ("$ git remote get-url origin " ) !== $ repository ) {
69+ cd ('{{deploy_path}} ' );
70+ run ("rm -rf $ bare " );
71+ goto start;
72+ }
7473
7574 // Copy to release_path.
7675 run ("$ git remote update 2>&1 " );
You can’t perform that action at this time.
0 commit comments