Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 71d0120

Browse files
authored
Merge pull request #59 from arduino/per1234/submodule-check
Add check for Git submodules in library
2 parents 0824294 + 5ac02e0 commit 71d0120

File tree

6 files changed

+51
-0
lines changed

6 files changed

+51
-0
lines changed

‎check/checkconfigurations/checkconfigurations.go‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,21 @@ var configurations = []Type{
761761
ErrorModes: nil,
762762
CheckFunction: checkfunctions.LibraryPropertiesMisspelledOptionalField,
763763
},
764+
{
765+
ProjectType: projecttype.Library,
766+
Category: "structure",
767+
Subcategory: "",
768+
ID: "",
769+
Brief: "submodule",
770+
Description: "",
771+
MessageTemplate: `Git submodule detected. Library Manager installations and installations from GitHub's "Download ZIP" will only contain an empty folder in place of the submodule.`,
772+
DisableModes: nil,
773+
EnableModes: []checkmode.Type{checkmode.All},
774+
InfoModes: nil,
775+
WarningModes: []checkmode.Type{checkmode.All},
776+
ErrorModes: nil,
777+
CheckFunction: checkfunctions.LibraryHasSubmodule,
778+
},
764779
{
765780
ProjectType: projecttype.Sketch,
766781
Category: "structure",

‎check/checkfunctions/library.go‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -785,6 +785,21 @@ func LibraryPropertiesMisspelledOptionalField() (result checkresult.Type, output
785785
return checkresult.Pass, ""
786786
}
787787

788+
// LibraryHasSubmodule checks whether the library contains a Git submodule.
789+
func LibraryHasSubmodule() (result checkresult.Type, output string) {
790+
dotGitmodulesPath := checkdata.ProjectPath().Join(".gitmodules")
791+
hasDotGitmodules, err := dotGitmodulesPath.ExistCheck()
792+
if err != nil {
793+
panic(err)
794+
}
795+
796+
if hasDotGitmodules && dotGitmodulesPath.IsNotDir() {
797+
return checkresult.Fail, ""
798+
}
799+
800+
return checkresult.Pass, ""
801+
}
802+
788803
// spellCheckLibraryPropertiesFieldValue returns the value of the provided library.properties field with commonly misspelled words corrected.
789804
func spellCheckLibraryPropertiesFieldValue(fieldName string) (result checkresult.Type, output string) {
790805
if checkdata.LibraryPropertiesLoadError() != nil {

‎check/checkfunctions/library_test.go‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,3 +170,12 @@ func TestLibraryPropertiesPrecompiledFieldEnabledWithFlatLayout(t *testing.T) {
170170

171171
checkCheckFunction(LibraryPropertiesPrecompiledFieldEnabledWithFlatLayout, testTables, t)
172172
}
173+
174+
func TestLibraryHasSubmodule(t *testing.T) {
175+
testTables := []checkFunctionTestTable{
176+
{"Has submodule", "Submodule", checkresult.Fail, ""},
177+
{"No submodule", "Recursive", checkresult.Pass, ""},
178+
}
179+
180+
checkCheckFunction(LibraryHasSubmodule, testTables, t)
181+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "foo"]
2+
path = foo
3+
url = https://example.com/foo.git
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name=Submodule
2+
version=1.0.0
3+
author=Cristian Maglie <c.maglie@example.com>, Pippo Pluto <pippo@example.com>
4+
maintainer=Cristian Maglie <c.maglie@example.com>
5+
sentence=A library that makes coding a web server a breeze.
6+
paragraph=Supports HTTP1.1 and you can do GET and POST.
7+
category=Communication
8+
url=http://example.com/
9+
architectures=avr

‎check/checkfunctions/testdata/libraries/Submodule/src/Submodule.h‎

Whitespace-only changes.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /