Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
Imldeployment
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
IML Open Source
Imldeployment
Commits
2f776352
Commit
2f776352
authored
4 years ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Plain Diff
Merge branch 'task4364-branchname-chars' into 'master'
task#4364 - support branches with slashes See merge request
!2
parents
dbbcb1ee
0375b818
Branches
Branches containing commit
No related tags found
1 merge request
!2
task#4364 - support branches with slashes
Pipeline
#218
passed
4 years ago
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
.gitignore
+1
-0
1 addition, 0 deletions
.gitignore
public_html/deployment/classes/vcs.git.class.php
+22
-15
22 additions, 15 deletions
public_html/deployment/classes/vcs.git.class.php
with
23 additions
and
15 deletions
.gitignore
+
1
−
0
View file @
2f776352
...
@@ -27,4 +27,5 @@ nbproject
...
@@ -27,4 +27,5 @@ nbproject
/public_html/vendor/medoo/
/public_html/vendor/medoo/
/config/_inc_projects_config.php
/config/_inc_projects_config.php
/config/inc_projects_config.php
/config/inc_projects_config.php
/config/inc_user2roles.php
/.vscode/
/.vscode/
\ No newline at end of file
This diff is collapsed.
Click to expand it.
public_html/deployment/classes/vcs.git.class.php
+
22
−
15
View file @
2f776352
...
@@ -102,6 +102,11 @@ class vcs implements iVcs {
...
@@ -102,6 +102,11 @@ class vcs implements iVcs {
return
$this
->
_aCfg
=
$aRepoConfig
;
return
$this
->
_aCfg
=
$aRepoConfig
;
}
}
/**
* set directory für current branch of a project below tempdir
* In it the branch will be initialized
* @return type
*/
private
function
_setTempdir
()
{
private
function
_setTempdir
()
{
$this
->
_sTempDir
=
$this
->
_aCfg
[
"url"
];
$this
->
_sTempDir
=
$this
->
_aCfg
[
"url"
];
$this
->
_sTempDir
=
preg_replace
(
'/[\@\.\:\/]/'
,
'_'
,
$this
->
_sTempDir
);
$this
->
_sTempDir
=
preg_replace
(
'/[\@\.\:\/]/'
,
'_'
,
$this
->
_sTempDir
);
...
@@ -213,7 +218,7 @@ class vcs implements iVcs {
...
@@ -213,7 +218,7 @@ class vcs implements iVcs {
* @return array
* @return array
*/
*/
private
function
_fetchRemoteBranches
(
$bForceNoCache
=
false
)
{
private
function
_fetchRemoteBranches
(
$bForceNoCache
=
false
)
{
$this
->
log
(
__FUNCTION__
.
" start"
);
$this
->
log
(
__FUNCTION__
.
"
(bForceNoCache = "
.
(
$bForceNoCache
?
'true'
:
'false'
)
.
")
start"
);
$aReturn
=
array
();
$aReturn
=
array
();
if
(
!
$this
->
getUrl
())
{
if
(
!
$this
->
getUrl
())
{
...
@@ -227,8 +232,10 @@ class vcs implements iVcs {
...
@@ -227,8 +232,10 @@ class vcs implements iVcs {
// list of cached branch keys
// list of cached branch keys
if
(
$oCache
->
isExpired
()
||
$bForceNoCache
)
{
if
(
$oCache
->
isExpired
()
||
$bForceNoCache
)
{
$sWorkdir
=
dirname
(
$this
->
_sTempDir
)
.
'/fetchRemoteBranches/'
;
$sWorkdir
=
dirname
(
$this
->
_sTempDir
)
.
'/fetchRemoteBranches/'
;
$this
->
log
(
__FUNCTION__
.
" - sWorkdir =
$sWorkdir
"
);
$sGitCmd
=
'export GIT_SSH="'
.
$this
->
_sWrapper
.
'" ; export PKEY="'
.
$this
->
_sKeyfile
.
'" ; '
;
$sGitCmd
=
'export GIT_SSH="'
.
$this
->
_sWrapper
.
'" ; export PKEY="'
.
$this
->
_sKeyfile
.
'" ; '
;
if
(
!
file_exists
(
$sWorkdir
.
".git"
))
{
if
(
!
is_dir
(
$sWorkdir
.
".git"
))
{
$sGitCmd
.
=
'mkdir -p "'
.
$sWorkdir
.
'" && cd "'
.
$sWorkdir
.
'" && '
;
$sGitCmd
.
=
'mkdir -p "'
.
$sWorkdir
.
'" && cd "'
.
$sWorkdir
.
'" && '
;
$sGitCmd
.
=
'git init >/dev/null && '
;
$sGitCmd
.
=
'git init >/dev/null && '
;
$sGitCmd
.
=
'git remote add origin "'
.
$this
->
getUrl
()
.
'" 2>&1 && '
;
$sGitCmd
.
=
'git remote add origin "'
.
$this
->
getUrl
()
.
'" 2>&1 && '
;
...
@@ -236,9 +243,9 @@ class vcs implements iVcs {
...
@@ -236,9 +243,9 @@ class vcs implements iVcs {
$sGitCmd
.
=
'cd "'
.
$sWorkdir
.
'" 2>&1 && '
;
$sGitCmd
.
=
'cd "'
.
$sWorkdir
.
'" 2>&1 && '
;
}
}
$sGitCmd
.
=
'git ls-remote --heads --tags origin 2>&1 ;'
;
$sGitCmd
.
=
'git ls-remote --heads --tags origin 2>&1 ;'
;
$this
->
log
(
__FUNCTION__
.
" start command
$sGitCmd
"
);
$this
->
log
(
__FUNCTION__
.
" start command
<code>
$sGitCmd
</code>
"
);
exec
(
$sGitCmd
,
$aOutput
,
$iRc
);
exec
(
$sGitCmd
,
$aOutput
,
$iRc
);
$this
->
log
(
__FUNCTION__
.
" e
n
d with rc=
$iRc
"
,
(
$iRc
==
0
?
'info'
:
'error'
));
$this
->
log
(
__FUNCTION__
.
"
command end
ed with rc=
$iRc
"
.
'<pre>'
.
implode
(
"
\n
"
,
$aOutput
)
.
'</pre>'
,
(
$iRc
==
0
?
'info'
:
'error'
));
if
(
$iRc
==
0
)
{
if
(
$iRc
==
0
)
{
// use cache that getCommitmessageByBranch can access it
// use cache that getCommitmessageByBranch can access it
...
@@ -257,14 +264,14 @@ class vcs implements iVcs {
...
@@ -257,14 +264,14 @@ class vcs implements iVcs {
$this
->
log
(
__FUNCTION__
.
' loop over output of git ls-remote <pre>'
.
print_r
(
$sBranchLine
,
1
)
.
'</pre>'
);
$this
->
log
(
__FUNCTION__
.
' loop over output of git ls-remote <pre>'
.
print_r
(
$sBranchLine
,
1
)
.
'</pre>'
);
$aTmp
=
explode
(
"
\t
"
,
$sBranchLine
);
$aTmp
=
explode
(
"
\t
"
,
$sBranchLine
);
$
a
Branch
=
explode
(
"/"
,
$aTmp
[
1
]);
$
s
Branch
Path
=
preg_replace
(
'#^refs/#'
,
''
,
$aTmp
[
1
]);
$sBranch
=
array_pop
(
$aBranch
);
// remove "refs"
$sBranch
=
preg_replace
(
'#^[a-z]*\/#'
,
''
,
$sBranchPath
);
// skip dereferences
// skip dereferences
// http://stackoverflow.com/questions/15472107/when-listing-git-ls-remote-why-theres-after-the-tag-name
// http://stackoverflow.com/questions/15472107/when-listing-git-ls-remote-why-theres-after-the-tag-name
if
(
!
preg_match
(
'/\^\{\}$/'
,
$sBranch
))
{
if
(
!
preg_match
(
'/\^\{\}$/'
,
$sBranch
))
{
$sRevision
=
$aTmp
[
0
];
$sRevision
=
$aTmp
[
0
];
$sType
=
array_pop
(
$a
Branch
);
$sType
=
preg_replace
(
'#/.*$#'
,
''
,
$s
Branch
Path
);
$sName
=
(
$sType
==
"heads"
)
?
"origin/"
.
$sBranch
:
$sBranch
;
$sName
=
(
$sType
==
"heads"
)
?
"origin/"
.
$sBranch
:
$sBranch
;
$sBranchKey
=
$sName
;
$sBranchKey
=
$sName
;
...
@@ -419,11 +426,11 @@ class vcs implements iVcs {
...
@@ -419,11 +426,11 @@ class vcs implements iVcs {
}
}
$sGitCmd
.
=
'git log -1 "'
.
$this
->
_sCurrentBranch
.
'" 2>&1 ; '
;
// 0.0 s
$sGitCmd
.
=
'git log -1 "'
.
$this
->
_sCurrentBranch
.
'" 2>&1 ; '
;
// 0.0 s
$this
->
log
(
__FUNCTION__
.
" start command
$sGitCmd
"
);
$this
->
log
(
__FUNCTION__
.
" start command
<code>
$sGitCmd
</code>
"
);
// $sLoginfo = shell_exec($sGitCmd);
// $sLoginfo = shell_exec($sGitCmd);
exec
(
$sGitCmd
,
$aOutput
,
$iRc
);
exec
(
$sGitCmd
,
$aOutput
,
$iRc
);
$this
->
log
(
__FUNCTION__
.
" command ended with rc=
$iRc
"
.
'<pre>'
.
implode
(
"
\n
"
,
$aOutput
)
.
'</pre>'
,
(
$iRc
==
0
?
'info'
:
'error'
));
$sLoginfo
=
implode
(
"
\n
"
,
$aOutput
);
$sLoginfo
=
implode
(
"
\n
"
,
$aOutput
);
$this
->
log
(
__FUNCTION__
.
" end with rc=
$iRc
<pre>
$sLoginfo
</pre>"
,
(
$iRc
==
0
?
'info'
:
'error'
));
/*
/*
*
*
...
@@ -490,7 +497,7 @@ class vcs implements iVcs {
...
@@ -490,7 +497,7 @@ class vcs implements iVcs {
$sBranchname
=
str_replace
(
"origin/"
,
""
,
$this
->
_sCurrentBranch
);
$sBranchname
=
str_replace
(
"origin/"
,
""
,
$this
->
_sCurrentBranch
);
$sGitCmd
=
'export GIT_SSH="'
.
$this
->
_sWrapper
.
'" ; export PKEY="'
.
$this
->
_sKeyfile
.
'" ; '
;
$sGitCmd
=
'export GIT_SSH="'
.
$this
->
_sWrapper
.
'" ; export PKEY="'
.
$this
->
_sKeyfile
.
'" ; '
;
$
sReturn
=
false
;
$
aOutput
=
false
;
$iRc
=
false
;
$iRc
=
false
;
// this does not checkout tags in git v1.7 - only branches:
// this does not checkout tags in git v1.7 - only branches:
...
@@ -499,18 +506,18 @@ class vcs implements iVcs {
...
@@ -499,18 +506,18 @@ class vcs implements iVcs {
//
//
$sGitCmd
.
=
'echo git clone "'
.
$this
->
getUrl
()
.
'" "'
.
$sWorkDir
.
'" 2>&1 \&\& cd "'
.
$sWorkDir
.
'" \&\& git checkout "'
.
$sBranchname
.
'" ; '
;
$sGitCmd
.
=
'echo git clone "'
.
$this
->
getUrl
()
.
'" "'
.
$sWorkDir
.
'" 2>&1 \&\& cd "'
.
$sWorkDir
.
'" \&\& git checkout "'
.
$sBranchname
.
'" ; '
;
$sGitCmd
.
=
' git clone "'
.
$this
->
getUrl
()
.
'" "'
.
$sWorkDir
.
'" 2>&1 && cd "'
.
$sWorkDir
.
'" && git checkout "'
.
$sBranchname
.
'" 2>&1 '
;
$sGitCmd
.
=
' git clone "'
.
$this
->
getUrl
()
.
'" "'
.
$sWorkDir
.
'" 2>&1 && cd "'
.
$sWorkDir
.
'" && git checkout "'
.
$sBranchname
.
'" 2>&1 '
;
$this
->
log
(
__FUNCTION__
.
" start command
$sGitCmd
"
);
$this
->
log
(
__FUNCTION__
.
" start command
<code>
$sGitCmd
</code>
"
);
// $sReturn = shell_exec($sGitCmd);
// $sReturn = shell_exec($sGitCmd);
exec
(
$sGitCmd
,
$
sReturn
,
$iRc
);
exec
(
$sGitCmd
,
$
aOutput
,
$iRc
);
$this
->
log
(
__FUNCTION__
.
"
end
command
$sGitCmd
"
);
$this
->
log
(
__FUNCTION__
.
" command
ended with rc=
$iRc
"
.
'<pre>'
.
implode
(
"
\n
"
,
$aOutput
)
.
'</pre>'
,
(
$iRc
==
0
?
'info'
:
'error'
)
);
return
implode
(
"
\n
"
,
$
sReturn
)
.
"
\n
rc=
$iRc
"
;
return
implode
(
"
\n
"
,
$
aOutput
)
.
"
\n
rc=
$iRc
"
;
}
}
/**
/**
* return url to vcs sources
* return url to vcs sources
*/
*/
public
function
getUrl
()
{
public
function
getUrl
()
{
$this
->
log
(
__FUNCTION__
.
"
start"
);
$this
->
log
(
__FUNCTION__
.
"
--> "
.
$this
->
_aCfg
[
"url"
]
);
return
$this
->
_aCfg
[
"url"
];
return
$this
->
_aCfg
[
"url"
];
}
}
...
...
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