Skip to content
GitLab
Explorer
Connexion
S'inscrire
Navigation principale
Rechercher ou aller à…
Projet
S
stats-facil
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Wiki
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Extraits de code
Compilation
Pipelines
Jobs
Planifications de pipeline
Artéfacts
Déploiement
Releases
Registre de paquets
Registre de conteneur
Registre de modèles
Opération
Environnements
Modules Terraform
Surveillance
Incidents
Analyse
Données d'analyse des chaînes de valeur
Analyse des contributeurs
Données d'analyse CI/CD
Données d'analyse du dépôt
Expériences du modèle
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté
Contribuer à GitLab
Donner votre avis
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
facil
stats-facil
Validations
05c81d95
Valider
05c81d95
rédigé
11 years ago
par
Thomas Steur
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
testing git commit command
parent
548cb829
Aucune branche associée trouvée
Branches contenant la validation
Aucune étiquette associée trouvée
Étiquettes contenant la validation
Aucune requête de fusion associée trouvée
Modifications
1
Masquer les modifications d'espaces
En ligne
Côte à côte
Affichage de
1 fichier modifié
plugins/CoreConsole/GitCommit.php
+30
-13
30 ajouts, 13 suppressions
plugins/CoreConsole/GitCommit.php
avec
30 ajouts
et
13 suppressions
plugins/CoreConsole/GitCommit.php
+
30
−
13
Voir le fichier @
05c81d95
...
@@ -34,13 +34,13 @@ class GitCommit extends Command
...
@@ -34,13 +34,13 @@ class GitCommit extends Command
$commitMessage
=
$input
->
getOption
(
'message'
);
$commitMessage
=
$input
->
getOption
(
'message'
);
if
(
empty
(
$commitMessage
))
{
if
(
empty
(
$commitMessage
))
{
$output
->
writeln
(
'No message specified'
);
$output
->
writeln
(
'No message specified
. Use option -m or --message.
'
);
return
;
return
;
}
}
if
(
!
$this
->
has
Unpushed
Commit
s
())
{
if
(
!
$this
->
has
ChangesToBe
Commit
ted
())
{
$dialog
=
$this
->
getHelperSet
()
->
get
(
'dialog'
);
$dialog
=
$this
->
getHelperSet
()
->
get
(
'dialog'
);
$question
=
'<question>
No unpushed commits
, do you just want to converge submodules?</question>'
;
$question
=
'<question>
There are no changes to be commited in the super repo
, do you just want to
commit and
converge submodules?</question>'
;
if
(
!
$dialog
->
askConfirmation
(
$output
,
$question
,
false
))
{
if
(
!
$dialog
->
askConfirmation
(
$output
,
$question
,
false
))
{
$output
->
writeln
(
'<info>Cool, nothing done. Stage files using "git add" and try again.</info>'
);
$output
->
writeln
(
'<info>Cool, nothing done. Stage files using "git add" and try again.</info>'
);
return
;
return
;
...
@@ -54,9 +54,8 @@ class GitCommit extends Command
...
@@ -54,9 +54,8 @@ class GitCommit extends Command
continue
;
continue
;
}
}
$cmd
=
sprintf
(
'cd %s/%s && git status --porcelain'
,
PIWIK_DOCUMENT_ROOT
,
$submodule
);
$status
=
$this
->
getStatusOfSubmodule
(
$submodule
);
$status
=
trim
(
shell_exec
(
$cmd
));
if
(
false
!==
strpos
(
$status
,
'?? '
))
{
if
(
false
!==
strpos
(
$status
,
'??'
))
{
$output
->
writeln
(
sprintf
(
'%s has untracked changes, will ignore. Status: %s'
,
$submodule
,
$status
));
$output
->
writeln
(
sprintf
(
'%s has untracked changes, will ignore. Status: %s'
,
$submodule
,
$status
));
continue
;
continue
;
}
}
...
@@ -70,7 +69,7 @@ class GitCommit extends Command
...
@@ -70,7 +69,7 @@ class GitCommit extends Command
$this
->
passthru
(
$cmd
,
$output
);
$this
->
passthru
(
$cmd
,
$output
);
}
}
if
(
$this
->
has
Unpushed
Commit
s
())
{
if
(
$this
->
has
ChangesToBe
Commit
ted
())
{
$cmd
=
sprintf
(
'cd %s && git commit -m "%s"'
,
PIWIK_DOCUMENT_ROOT
,
$commitMessage
);
$cmd
=
sprintf
(
'cd %s && git commit -m "%s"'
,
PIWIK_DOCUMENT_ROOT
,
$commitMessage
);
$this
->
passthru
(
$cmd
,
$output
);
$this
->
passthru
(
$cmd
,
$output
);
}
}
...
@@ -84,7 +83,7 @@ class GitCommit extends Command
...
@@ -84,7 +83,7 @@ class GitCommit extends Command
$this
->
passthru
(
$cmd
,
$output
);
$this
->
passthru
(
$cmd
,
$output
);
}
}
if
(
$this
->
has
Unpushed
Commit
s
())
{
if
(
$this
->
has
ChangesToBe
Commit
ted
())
{
$cmd
=
sprintf
(
'cd %s && git commit -m "Converged submodules"'
,
PIWIK_DOCUMENT_ROOT
);
$cmd
=
sprintf
(
'cd %s && git commit -m "Converged submodules"'
,
PIWIK_DOCUMENT_ROOT
);
$this
->
passthru
(
$cmd
,
$output
);
$this
->
passthru
(
$cmd
,
$output
);
}
}
...
@@ -96,13 +95,23 @@ class GitCommit extends Command
...
@@ -96,13 +95,23 @@ class GitCommit extends Command
passthru
(
$cmd
);
passthru
(
$cmd
);
}
}
private
function
has
Unpushed
Commit
s
()
private
function
has
ChangesToBe
Commit
ted
()
{
{
$cmd
=
sprintf
(
'cd %s && git
log @{u}..
'
,
PIWIK_DOCUMENT_ROOT
);
$cmd
=
sprintf
(
'cd %s && git
status --porcelain
'
,
PIWIK_DOCUMENT_ROOT
);
$
hasUnpushedCommits
=
shell_exec
(
$cmd
);
$
result
=
shell_exec
(
$cmd
);
$
hasUnpushedCommits
=
trim
(
$hasUnpushedCommits
);
$
result
=
trim
(
$result
);
return
!
empty
(
$hasUnpushedCommits
);
if
(
false
!==
strpos
(
$result
,
'M '
))
{
// stages
return
true
;
}
if
(
false
!==
strpos
(
$result
,
'MM '
))
{
// staged and modified
return
true
;
}
return
false
;
}
}
/**
/**
...
@@ -116,4 +125,12 @@ class GitCommit extends Command
...
@@ -116,4 +125,12 @@ class GitCommit extends Command
return
$submodules
;
return
$submodules
;
}
}
protected
function
getStatusOfSubmodule
(
$submodule
)
{
$cmd
=
sprintf
(
'cd %s/%s && git status --porcelain'
,
PIWIK_DOCUMENT_ROOT
,
$submodule
);
$status
=
trim
(
shell_exec
(
$cmd
));
return
$status
;
}
}
}
\ No newline at end of file
Ce diff est replié.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter