aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib
Commit message (Collapse)AuthorAgeFilesLines
* AddCommand: implement --all/--no-allThomas Wolf2025-02-261-2/+14
| | | | | | | | | | | | | | | | | | | Command-line git stages deletions if file paths are given. (i.e., --all is implied.) File paths are also optional if --update or --all (or --no-all) are given. Add a setter and getter for an "all" flag on AddCommand. Check consistency with the "update" flag in call(). Make file paths optional (imply a "." path) if update is set or if setAll() had been called. If file paths are given, set the all flag. Stage deletions if update is set, or if the "all" flag is set. Add the C git command-line options for the "all" flag to jgit.pgm.Add. Bug: jgit-122 Change-Id: Iedddedcaa2d7a2e75162454ea047f34ec1cf3660
* Config: add getters for primitive types without default valueMatthias Sohn2025-02-061-0/+41
| | | | | | which return null if the option is not configured. Change-Id: I0d444b396458f49712e35ef32427dc45ee3f8ec8
* Deprecate Repository#getReflogReader methodsMatthias Sohn2025-01-271-9/+10
| | | | | | instead use Repository.getRefDatabase().getReflogReader(). Change-Id: I5e66a512c12e11d0ec3275fffde4adb8483430f2
* Add RefDatabase#getReflogReader methodsMatthias Sohn2025-01-271-0/+5
| | | | | | | | | | | | to fix broken abstraction in FileRepository#getReflogReader(String). How to get a ReflogReader depends on the chosen RefDatabase implementation, hence the #getReflogReader methods should be there. This also fixes a bug in FileRepository#getReflogReader(Ref) which didn't work if FileReftableDatabase was used as RefDatabase since it always returned the implementation only suitable for RefDirectory. Change-Id: I0859990f9390ab96596b6c344966c687dfbbf167
* ReflogConfigTest: use java.time instead of java.util.Date APIMatthias Sohn2024-12-291-8/+11
| | | | Change-Id: I00c63c928ad64a447ad101e01508d917de26bd71
* PersonIdent: Use java.time instead of older Date and millisecondsIvan Frade2024-11-191-2/+4
| | | | | | | | | | | | | | | | | From errorprone: Date has a bad API that leads to bugs; prefer java.time.Instant or LocalDate. Replace the long with milliseconds and int with minutes offset with an Instant and a ZoneOffset. Create new constructors and deprecate variants with Date, milliseconds and minute offsets. When comparing instances of PersonIdent truncate the timestamp precision to 1 second since git commit timestamps are persisted with 1 second precision [1]. [1] https://git-scm.com/docs/git-commit#Documentation/git-commit.txt-Gitinternalformat Change-Id: Id4ba1f108e1ba0bfcdd87ba37c67e2d3cc7d254f
* ObjectId: Add method to read an ObjectId from a ByteBufferIvan Frade2024-08-291-0/+13
| | | | | | | | | Some storages return data in a convenient ByteBuffer wrapper, but there is no straigh-forward method to read ObjectIds from it. Add ObjectId#fromRaw(ByteBuffer) to read object ids from byte buffers. Change-Id: Ia3b244005e4d9a613294f5ad9dab3b8e7bc3d7df
* Lib: Fix ssh value for gpg.format throwing an IllegalArgumentExceptiongranny2024-07-301-0/+10
| | | | | | Git version 2.34 and later supports signing commits and tags with SSH keys. This means gpg.format now supports "ssh" as a value. Change-Id: Iee1e5a68a816bec149a17a73a6916d2884a54163
* [errorprone] Fix pattern BadImportMatthias Sohn2024-04-291-2/+1
| | | | | | See https://errorprone.info/bugpattern/BadImport Change-Id: I24e5a7a4a64d8b3cf2cc3d394090ce90e849f9f9
* [errorprone] Fix pattern CatchFailMatthias Sohn2024-04-291-1/+1
| | | | | | See https://errorprone.info/bugpattern/CatchFail Change-Id: If1c637a420c4e669a5bdbe4abcefc5c3a2b3a43b
* [errorprone] Fix pattern see UnusedVariableMatthias Sohn2024-04-291-6/+4
| | | | | | See https://errorprone.info/bugpattern/UnusedVariable Change-Id: I75d7602af31ed7d3264d2beab2d159cfbf29e7cb
* [errorprone] Fix error pattern JdkObsoleteMatthias Sohn2024-04-291-5/+4
| | | | | | See https://errorprone.info/bugpattern/JdkObsolete Change-Id: Id105e2695eb64523bd217f507bf95f909bc6b348
* Explain why RacyGitTests may be flaky in some environmentsMatthias Sohn2024-04-201-0/+16
| | | | Change-Id: I5bbd04754f5f29299a7b9a58a3717e3f615199d0
* BitmapIndex: Add interface to track bitmaps found (or not)Ivan Frade2023-11-211-0/+85
| | | | | | | | | | | | We want to know what objects had bitmaps in the walk of the request. We can check their position in the history and evaluate our bitmap selection algorithm. Introduce a listener interface to the BitmapIndex to report which getBitmap() calls returned a bitmap (or not) and a method to the bitmap index to set the listener. Change-Id: Iac8fcc1539ddd2dd450e8a1cf5a5b1089679c378
* Config.removeSection() telling whether it changed the configThomas Wolf2023-10-141-2/+38
| | | | | | | | | | | Add a variant of unsetSection() that returns whether it did indeed change the config. This can be used in to skip saving the config if it was not changed. Also fix the iteration over the entries: lastWasMatch was never reset, and thus all empty lines after a match would be removed. Change-Id: Iea9e84aa74b1e4bb3c89efe3936fa3a8a09532e5 Signed-off-by: Thomas Wolf <twolf@apache.org>
* Fix some tests in ConfigTestMatthias Sohn2023-08-291-4/+12
| | | | | | | Some of the ConfigTest tests created a FileRepositoryBuilder but didn't use it to actually create a FileRepository. Change-Id: I1a4b27891daee1b235a71e7bbf2a7588b9d11a53
* Default for global (user) git ignore fileThomas Wolf2023-06-191-3/+7
| | | | | | | | | | | | | | | | | | | | C git has a default for git config core.excludesfile: "Its default value is $XDG_CONFIG_HOME/git/ignore. If $XDG_CONFIG_HOME is either not set or empty, $HOME/.config/git/ignore is used instead." [1] Implement this in the WorkingTreeIterator$RootIgnoreNode. To make this testable, mock the "user.home" directory for all JGit tests, otherwise tests might pick up a real user's git ignore file. Also ensure that JGit code always reads "user.home" via the SystemReader. Add tests for both locations. [1] https://git-scm.com/docs/gitignore#_description Bug: 436127 Change-Id: Ie510259320286c3c13a6464a37da1bd9ca1e373a Signed-off-by: Thomas Wolf <twolf@apache.org>
* Parse pull.rebase=preserve as alias for pull.rebase=mergesMatthias Sohn2023-04-221-1/+44
| | | | | | | This ensures backwards compatibility to the old config value which was removed in git 2.34 which JGit followed in Ic07ff954e2. Change-Id: I2b4e27fd71898b6e0e227e406c40682bd9786cd4
* BatchingProgressMonitor: expose time spent per taskMatthias Sohn2023-02-271-0/+5
| | | | | | | | | | | | | | | | | | | Display elapsed time per task if enabled via ProgressMonitor#showDuration or if system property or environment variable GIT_TRACE_PERFORMANCE is set to "true". If both the system property and the environment variable are set the system property takes precedence. E.g. using jgit CLI: $ GIT_TRACE_PERFORMANCE=true jgit clone https://foo.bar/foobar Cloning into 'foobar'... remote: Counting objects: 1 [0.002s] remote: Finding sources: 100% (15531/15531) [0.006s] Receiving objects: 100% (169737/169737) [13.045s] Resolving deltas: 100% (67579/67579) [1.842s] Change-Id: I4d624e7858b286aeddbe7d4e557589986d73659e
* Merge branch 'stable-6.4'Matthias Sohn2023-02-011-0/+83
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-6.4: Shortcut during git fetch for avoiding looping through all local refs FetchCommand: fix fetchSubmodules to work on a Ref to a blob Silence API warnings introduced by I466dcde6 Allow the exclusions of refs prefixes from bitmap PackWriterBitmapPreparer: do not include annotated tags in bitmap BatchingProgressMonitor: avoid int overflow when computing percentage Speedup GC listing objects referenced from reflogs FileSnapshotTest: Add more MISSING_FILE coverage Change-Id: Id0ebfbd85eb815716383b9495eb7dd1f54cf4d74
| * Merge branch 'stable-6.1' into stable-6.2Matthias Sohn2023-02-011-0/+83
| |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-6.1: Shortcut during git fetch for avoiding looping through all local refs FetchCommand: fix fetchSubmodules to work on a Ref to a blob Silence API warnings introduced by I466dcde6 Allow the exclusions of refs prefixes from bitmap PackWriterBitmapPreparer: do not include annotated tags in bitmap BatchingProgressMonitor: avoid int overflow when computing percentage Speedup GC listing objects referenced from reflogs FileSnapshotTest: Add more MISSING_FILE coverage Change-Id: Iff2fba026b49463016015b2fae1a42cf76ee2dbb
| | * Merge branch 'stable-6.0' into stable-6.1Matthias Sohn2023-02-011-0/+83
| | |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-6.0: Shortcut during git fetch for avoiding looping through all local refs FetchCommand: fix fetchSubmodules to work on a Ref to a blob Silence API warnings introduced by I466dcde6 Allow the exclusions of refs prefixes from bitmap PackWriterBitmapPreparer: do not include annotated tags in bitmap BatchingProgressMonitor: avoid int overflow when computing percentage Speedup GC listing objects referenced from reflogs FileSnapshotTest: Add more MISSING_FILE coverage Change-Id: Ib5055f2f3b8a313c178d6f6c7c5630285ad5a726
| | | * Merge branch 'stable-5.13' into stable-6.0Matthias Sohn2023-02-011-0/+83
| | | |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-5.13: Shortcut during git fetch for avoiding looping through all local refs FetchCommand: fix fetchSubmodules to work on a Ref to a blob Silence API warnings introduced by I466dcde6 Allow the exclusions of refs prefixes from bitmap PackWriterBitmapPreparer: do not include annotated tags in bitmap BatchingProgressMonitor: avoid int overflow when computing percentage Speedup GC listing objects referenced from reflogs FileSnapshotTest: Add more MISSING_FILE coverage Change-Id: I58ad4c210a5e7e5a1ba6b22315b04211c8909950
| | | | * BatchingProgressMonitor: avoid int overflow when computing percentageMatthias Sohn2023-01-311-0/+83
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When cloning huge repositories I observed percentage of object counts turning negative. This happened if lastWork * 100 exceeded Integer.MAX_VALUE. Change-Id: Ic5f5cf5a911a91338267aace4daba4b873ab3900
* | | | | CommitGraph: add core.commitGraph configkylezhao2022-12-161-0/+14
|/ / / / | | | | | | | | | | | | | | | | Change-Id: I3b5e735ebafba09ca18fd83da479c7950fa3ea8d Signed-off-by: kylezhao <kylezhao@tencent.com>
* / / / CommitConfig: add support for core.commentCharThomas Wolf2022-03-261-0/+79
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | Provide access to the core.commentChar git config, and provide a utility method to determine an unused comment character if the setting is "auto". Bug: 579325 Change-Id: I1ec7e4deffea6ac5929a8538a624d73bb59e4ecc Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* | | Describe: add support for core.abbrev config optionMatthias Sohn2022-03-021-0/+128
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If core.abbrev is unset or "auto" estimate abbreviation length like C git does: - Estimate repository's object count by only considering packed objects, round up to next power of 2 - With the order of 2^len objects, we expect a collision at 2^(len/2). But we also care about hex chars, not bits, and there are 4 bits per hex. So all together we need to divide by 2; but we also want to round odd numbers up, hence adding one before dividing. - For small repos use at least 7 hexdigits - If object database fails to determine object count use 7 hexdigits as fallback If it is set to "no" do not abbreviate object-ids. Otherwise set it to the configured value capped to the range between 4 and length of an unabbreviated object-id. Change-Id: I425f9724b69813dbb57872466bf2d2e1d6dc72c6
* | | Remove odd prefix of PersonIdent test classMatthias Sohn2022-03-021-1/+1
| | | | | | | | | | | | Change-Id: I05ede49902527c435691fb2c0f0d4da7ba077b7a
* | | PersonIdent: Add ctors that accept Instant in addition to DateDavid Ostrovsky2022-03-021-0/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | Error Prone is flagging Date-API as obsolete and recommends to migrate to Instant and LocalDate. Given that more JGit users starting to migrate to new Time API, offer ctors that accept Instant type and also add new getter that returns when attribute as Instant type. Change-Id: I64a36bf40f191495c6889c1dff314ede06848880
* | | [test] Fix ConfigTest for WindowsThomas Wolf2022-02-011-4/+7
| | | | | | | | | | | | | | | | | | | | | | | | Escape paths when writing them to a config file to ensure they work with backslashes and unusual characters. Bug: 550111 Change-Id: Iedc5c0f2c0c02ac6cadf43cdae0f0d19578aed91 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* | | [test] Fix CommitTemplateConfigTest for WindowsThomas Wolf2022-02-011-3/+2
| | | | | | | | | | | | | | | | | | | | | Ensure that this test works on Windows. Bug: 550111 Change-Id: Ib3ca803f4d9521a5f2a0e1344bfbc0d2beccc9cc Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* | | Provide git config commit.cleanupThomas Wolf2022-01-311-0/+179
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add an enumeration for the possible values, and a method to resolve the "default" value. Give CommitConfig a static method to process a text according to a given clean-up mode and comment character. (The core.commentChar is not yet handled by JGit; it's hard-coded as #.) Bug: 553065 Change-Id: If6e384522275f73b713fbc29ffcaa1753c239dea Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* | | [test] Fix closing of test repositoriesNail Samatov2022-01-301-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix tests failing on Windows because Repository instance is created but not closed on tear down. Fix repositories closed twice, except in tests that test this behavior explicitly. Name the temporary directories the tests run in after the test method; that makes it easier to figure out in which tests repositories are closed twice if it should occur again in the future. Bug: 550111 Change-Id: I9398b58f0f36d2c29236d2a9a8599117d9083980 Signed-off-by: Nail Samatov <sanail@yandex.ru> Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* | | [test] DirCacheCheckoutTest: fix test expectation for eol=nativeThomas Wolf2022-01-301-5/+6
|/ / | | | | | | | | | | | | | | | | With eol=native, we expect LF on Unixes, and CR-LF on Windows. One test didn't account for this and always expected LF, and thus failed on Windows. Bug: 550111 Change-Id: I69354ac691c464d1b6003812ddb4510c5ab5e77a Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* | [bazel] Skip ConfigTest#testCommitTemplatePathInHomeDirecoryMatthias Sohn2022-01-182-26/+61
| | | | | | | | | | | | | | | | | | | | | | | | | | Move this test to another class and skip it when running tests with bazel since the bazel test runner does not allow to create files in the home directory. FS#userHome retrieves the home directory on the first call and caches it for subsequent calls to avoid overhead in case path translation is required (currently on cygwin). This prevents that the test can mock the home directory using MockSystemReader like SshTestHarness does. Change-Id: I6a22f37f4a19eb4b4935509eae508a23e56db7aa
* | Support commit.template config propertyJulian Ruppel2021-11-221-7/+44
| | | | | | | | | | | | | | | | | | | | | | Fixes an issue that commit template file could not be found if it has a relative path instead of absolute path. Relative path is probably common if git config --local is used. Bug: 446355 Change-Id: I8ddf2be672647be825fd9c01af82809d31bb8356
* | Fix checkout of files with mixed line endings on text=auto eol=crlfThomas Wolf2021-10-271-0/+28
|/ | | | | | | | | | | | | | Add tests for files having been checked in with mixed LF and CR-LF line endings, and then being checked out with text or text=auto and eol=lf or eol=crlf. These test cases were missing, and thus commit efd1cc05 missed that AutoCRLFOutputStream needs the same detection as AutoLFOutputStream. Fix AutoCRLFOutputStream to not convert line endings if the blob in the repository contains CR-LF. Bug: 575393 Change-Id: Id0c7ae772e282097e95fddcd3f1f9d82aae31e43 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* Support commit.template config propertyJulian Ruppel2021-07-211-0/+103
| | | | | | | | | | Adds functionality to read the git commit.template property. The template content is read either via a default encoding or, if present, via encoding specified by i18n.commitEncoding property. Bug: 446355 Change-Id: I0c45db98e324ddff26a7e0262835f259d6528a86 Signed-off-by: Julian Ruppel <julian.ruppel@sap.com>
* Add getsRefsByPrefixWithSkips (excluding prefixes) to ReftableDatabaseGal Paikin2021-01-271-0/+59
| | | | | | | | | | | | | | | | | | | | | | | We sometimes want to get all the refs except specific prefixes, similarly to getRefsByPrefix that gets all the refs of a specific prefix. We now create a new method that gets all refs matching a prefix except a set of specific prefixes. One use-case is for Gerrit to be able to get all the refs except refs/changes; in Gerrit we often have lots of refs/changes, but very little other refs. Currently, to get all the refs except refs/changes we need to get all the refs and then filter the refs/changes, which is very inefficient. With this method, we can simply skip the unneeded prefix so that we don't have to go over all the elements. RefDirectory still uses the inefficient implementation, since there isn't a simple way to use Refcursor to achieve the efficient implementation (as done in ReftableDatabase). Signed-off-by: Gal Paikin <paiking@google.com> Change-Id: I8c5db581acdeb6698e3d3a2abde8da32f70c854c
* Fix NPE in DirCacheCheckoutThomas Wolf2020-12-301-9/+0
| | | | | | | | | | | If a file exists in head, merge, and the working tree, but not in the index, and we're doing a force checkout, the checkout must be an "update", not a "keep". This is a follow-up on If3a9b9e60064459d187c7db04eb4471a72c6cece. Bug: 569962 Change-Id: I59a7ac41898ddc1dd90e86b09b621a41fdf45667 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* Merge "Added check for null on DirCacheEntry in checkoutEntry method"Christian Halstrick2020-12-301-0/+9
|\
| * Added check for null on DirCacheEntry in checkoutEntry methodTudor Matrescu2020-12-031-0/+9
| | | | | | | | | | | | | | | | | | | | Observed the error when trying to force checkout from a branch that had no changes on it. When the 'keep()' method from 'DirCacheCheckout' method was called the 'DirCacheEntry e' was null and was passed like this to the 'checkoutEntry()' method where the 'getObjectId()' is being called on the 'e' object Change-Id: If3a9b9e60064459d187c7db04eb4471a72c6cece
* | Enable GpgSigner to also sign tagsThomas Wolf2020-12-072-4/+177
|/ | | | | | | | | | | | | | Factor out a common ObjectBuilder as super class of CommitBuilder and TagBuilder, and make the GpgSigner work on ObjectBuilder. In order not to break API, add the new method for signing an ObjectBuilder in a new interface GpgObjectSigner. The signature for a tag is just tacked onto the end of the tag message. The message of a signed tag must end in LF. Bug: 386908 Change-Id: I5e021e3c927f4051825cd7355b129113b949455e Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* Keep line endings for text files committed with CR/LF on text=autoThomas Wolf2020-08-171-32/+85
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Git never converts line endings if the version in the repository is a text file with CR/LF and text=auto. See [1]: "When the file has been committed with CRLF, no conversion is done." Because the sentence just before is about converting line endings on check-in, I had understood that in commit 60cf85a [2] to mean that no conversion on check-in was to be done. However, as bug 565048 and a code inspection of the C git code showed it really means no conversion is done on check-in *or check-out*. If the text attribute is not set but core.autocrlf = true, this is the same as text=auto eol=crlf. C git does not convert on check-out even on text=auto eol=lf if the index version is a text file with CR/LF. For check-in, one has to look at the intended target, which is done in WorkingTreeIterator since commit 60cf85a. For check-out, it can be done by looking at the source and can thus be done in the AutoLFOutputStream. Additionally, provide a constructor for AutoLFInputStream to do the same; for cases where the equivalent of a check-out is done via an input stream obtained from a blob. (EGit does that in its GitBlobStorage for the Eclipse compare framework; it's more efficient than using a TemporaryBuffer and DirCacheCheckout.getContent(), and it avoids the need for a temporary file.) Adapt existing tests, and add new checkout and merge tests to verify the resulting files have the correct line endings. EGit's GitBlobStorage will need to call the new version of EolStreamTypeUtil.wrapInputStream(). [1] https://git-scm.com/docs/gitattributes#Documentation/gitattributes.txt-Settostringvalueauto [2] https://git.eclipse.org/r/c/jgit/jgit/+/127324 Bug: 565048 Change-Id: If1282ef43e2abd00263541bd10a01fe1f5c619fc Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* Fix writing GPG signatures with trailing newlineThomas Wolf2020-07-081-37/+53
| | | | | | | Make sure we don't produce a spurious empty line at the end. Bug: 564428 Change-Id: Ib991d93fbd052baca65d32a7842f07f9ddeb8130 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* Decouple BouncyCastle from JGit CoreMatthias Sohn2020-06-011-134/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | Motivation: BouncyCastle serves as 'default' implementation of the GPG Signer. If a client application does not use it there is no need to pull in this dependency, especially since BouncyCastle is a large library. Move the classes depending on BouncyCastle to an OSGi fragment extending the org.eclipse.jgit bundle. They are moved to a distinct internal package in order to avoid split packages. This doesn't break public API since these classes were already in an internal package before this change. Add a new feature org.eclipse.jgit.gpg.bc to enable installation. With that users can now decide if they want to install it. Attempts to sign a commit if org.eclipse.jgit.gpg.bc isn't available will result in ServiceUnavailableException being thrown. Bug: 559106 Change-Id: I42fd6c00002e17aa9a7be96ae434b538ea86ccf8 Also-by: Michael Dardis <git@md-5.net> Signed-off-by: Michael Dardis <git@md-5.net> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com> Signed-off-by: David Ostrovsky <david@ostrovsky.org>
* Merge branch 'stable-5.6'Matthias Sohn2020-02-221-1/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | * stable-5.6: Revert "Prepend hostname to subsection used to store file timestamp resolution" SimilarityRenameDetector: Fix inconsistent indentation Use indexOf(char) and lastIndexOf(char) rather than String versions Reorder modifiers to follow Java Language Specification GitmoduleEntry: Remove redundant import of class from same package Remove redundant "static" qualifier from enum declarations Change-Id: Ibb66bef7e8373f81e3e653c9843d986243446d68 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
| * Remove redundant "static" qualifier from enum declarationsDavid Pursehouse2020-02-191-1/+1
| | | | | | | | | | | | | | Nested enum types are implicitly static. Change-Id: Id3d7886087494fb67bc0d080b4a3491fb4baac19 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* | Replace ExpectedException which was deprecated in junit 4.13Matthias Sohn2020-01-242-52/+38
| | | | | | | | | | Change-Id: I64b0c057dd0a12aef2f3d56fa0c8a10e3b23fffd Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | Replace deprecated junit assertion methods with hamcrestMatthias Sohn2020-01-221-1/+1
| | | | | | | | Change-Id: Icebe8071eeefbc13d3bdbc231c568209cdc26195 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
then \ echo "Gitea requires Node.js $(MIN_NODE_VERSION_STR) or greater and npm to build. You can get it at https://nodejs.org/en/download/"; \ exit 1; \ fi .PHONY: clean-all clean-all: clean rm -rf $(WEBPACK_DEST_ENTRIES) node_modules .PHONY: clean clean: rm -rf $(EXECUTABLE) $(DIST) $(BINDATA_DEST) $(BINDATA_HASH) \ integrations*.test \ e2e*.test \ tests/integration/gitea-integration-* \ tests/integration/indexers-* \ tests/mysql.ini tests/pgsql.ini tests/mssql.ini man/ \ tests/e2e/gitea-e2e-*/ \ tests/e2e/indexers-*/ \ tests/e2e/reports/ tests/e2e/test-artifacts/ tests/e2e/test-snapshots/ .PHONY: fmt fmt: GOFUMPT_PACKAGE=$(GOFUMPT_PACKAGE) $(GO) run build/code-batch-process.go gitea-fmt -w '{file-list}' $(eval TEMPLATES := $(shell find templates -type f -name '*.tmpl')) @# strip whitespace after '{{' or '(' and before '}}' or ')' unless there is only @# whitespace before it @$(SED_INPLACE) \ -e 's/{{[ ]\{1,\}/{{/g' -e '/^[ ]\{1,\}}}/! s/[ ]\{1,\}}}/}}/g' \ -e 's/([ ]\{1,\}/(/g' -e '/^[ ]\{1,\})/! s/[ ]\{1,\})/)/g' \ $(TEMPLATES) .PHONY: fmt-check fmt-check: fmt @diff=$$(git diff --color=always $(GO_SOURCES) templates $(WEB_DIRS)); \ if [ -n "$$diff" ]; then \ echo "Please run 'make fmt' and commit the result:"; \ echo "$${diff}"; \ exit 1; \ fi .PHONY: $(TAGS_EVIDENCE) $(TAGS_EVIDENCE): @mkdir -p $(MAKE_EVIDENCE_DIR) @echo "$(TAGS)" > $(TAGS_EVIDENCE) ifneq "$(TAGS)" "$(shell cat $(TAGS_EVIDENCE) 2>/dev/null)" TAGS_PREREQ := $(TAGS_EVIDENCE) endif .PHONY: generate-swagger generate-swagger: $(SWAGGER_SPEC) $(SWAGGER_SPEC): $(GO_SOURCES_NO_BINDATA) $(GO) run $(SWAGGER_PACKAGE) generate spec -x "$(SWAGGER_EXCLUDE)" -o './$(SWAGGER_SPEC)' $(SED_INPLACE) '$(SWAGGER_SPEC_S_TMPL)' './$(SWAGGER_SPEC)' $(SED_INPLACE) $(SWAGGER_NEWLINE_COMMAND) './$(SWAGGER_SPEC)' .PHONY: swagger-check swagger-check: generate-swagger @diff=$$(git diff --color=always '$(SWAGGER_SPEC)'); \ if [ -n "$$diff" ]; then \ echo "Please run 'make generate-swagger' and commit the result:"; \ echo "$${diff}"; \ exit 1; \ fi .PHONY: swagger-validate swagger-validate: $(SED_INPLACE) '$(SWAGGER_SPEC_S_JSON)' './$(SWAGGER_SPEC)' $(GO) run $(SWAGGER_PACKAGE) validate './$(SWAGGER_SPEC)' $(SED_INPLACE) '$(SWAGGER_SPEC_S_TMPL)' './$(SWAGGER_SPEC)' .PHONY: checks checks: checks-frontend checks-backend .PHONY: checks-frontend checks-frontend: lockfile-check svg-check .PHONY: checks-backend checks-backend: tidy-check swagger-check fmt-check swagger-validate security-check .PHONY: lint lint: lint-frontend lint-backend lint-spell .PHONY: lint-fix lint-fix: lint-frontend-fix lint-backend-fix lint-spell-fix .PHONY: lint-frontend lint-frontend: lint-js lint-css .PHONY: lint-frontend-fix lint-frontend-fix: lint-js-fix lint-css-fix .PHONY: lint-backend lint-backend: lint-go lint-go-vet lint-editorconfig .PHONY: lint-backend-fix lint-backend-fix: lint-go-fix lint-go-vet lint-editorconfig .PHONY: lint-js lint-js: node_modules npx eslint --color --max-warnings=0 --ext js,vue web_src/js build *.config.js tests/e2e .PHONY: lint-js-fix lint-js-fix: node_modules npx eslint --color --max-warnings=0 --ext js,vue web_src/js build *.config.js tests/e2e --fix .PHONY: lint-css lint-css: node_modules npx stylelint --color --max-warnings=0 web_src/css web_src/js/components/*.vue .PHONY: lint-css-fix lint-css-fix: node_modules npx stylelint --color --max-warnings=0 web_src/css web_src/js/components/*.vue --fix .PHONY: lint-swagger lint-swagger: node_modules npx spectral lint -q -F hint $(SWAGGER_SPEC) .PHONY: lint-md lint-md: node_modules npx markdownlint docs *.md .PHONY: lint-spell lint-spell: @go run $(MISSPELL_PACKAGE) -error $(SPELLCHECK_FILES) .PHONY: lint-spell-fix lint-spell-fix: @go run $(MISSPELL_PACKAGE) -w $(SPELLCHECK_FILES) .PHONY: lint-go lint-go: $(GO) run $(GOLANGCI_LINT_PACKAGE) run .PHONY: lint-go-fix lint-go-fix: $(GO) run $(GOLANGCI_LINT_PACKAGE) run --fix # workaround step for the lint-go-windows CI task because 'go run' can not # have distinct GOOS/GOARCH for its build and run steps .PHONY: lint-go-windows lint-go-windows: @GOOS= GOARCH= $(GO) install $(GOLANGCI_LINT_PACKAGE) golangci-lint run .PHONY: lint-go-vet lint-go-vet: @echo "Running go vet..." @GOOS= GOARCH= $(GO) build code.gitea.io/gitea-vet @$(GO) vet -vettool=gitea-vet $(GO_PACKAGES) .PHONY: lint-editorconfig lint-editorconfig: $(GO) run $(EDITORCONFIG_CHECKER_PACKAGE) templates .github/workflows .PHONY: lint-actions lint-actions: $(GO) run $(ACTIONLINT_PACKAGE) .PHONY: lint-templates lint-templates: .venv @poetry run djlint $(shell find templates -type f -iname '*.tmpl') .PHONY: lint-yaml lint-yaml: .venv @poetry run yamllint . .PHONY: watch watch: @bash build/watch.sh .PHONY: watch-frontend watch-frontend: node-check node_modules @rm -rf $(WEBPACK_DEST_ENTRIES) NODE_ENV=development npx webpack --watch --progress .PHONY: watch-backend watch-backend: go-check GITEA_RUN_MODE=dev $(GO) run $(AIR_PACKAGE) -c .air.toml .PHONY: test test: test-frontend test-backend .PHONY: test-backend test-backend: @echo "Running go test with $(GOTESTFLAGS) -tags '$(TEST_TAGS)'..." @$(GO) test $(GOTESTFLAGS) -tags='$(TEST_TAGS)' $(GO_TEST_PACKAGES) .PHONY: test-frontend test-frontend: node_modules npx vitest .PHONY: test-check test-check: @echo "Running test-check..."; @diff=$$(git status -s); \ if [ -n "$$diff" ]; then \ echo "make test-backend has changed files in the source tree:"; \ echo "$${diff}"; \ echo "You should change the tests to create these files in a temporary directory."; \ echo "Do not simply add these files to .gitignore"; \ exit 1; \ fi .PHONY: test\#% test\#%: @echo "Running go test with -tags '$(TEST_TAGS)'..." @$(GO) test $(GOTESTFLAGS) -tags='$(TEST_TAGS)' -run $(subst .,/,$*) $(GO_TEST_PACKAGES) .PHONY: coverage coverage: grep '^\(mode: .*\)\|\(.*:[0-9]\+\.[0-9]\+,[0-9]\+\.[0-9]\+ [0-9]\+ [0-9]\+\)$$' coverage.out > coverage-bodged.out grep '^\(mode: .*\)\|\(.*:[0-9]\+\.[0-9]\+,[0-9]\+\.[0-9]\+ [0-9]\+ [0-9]\+\)$$' integration.coverage.out > integration.coverage-bodged.out $(GO) run build/gocovmerge.go integration.coverage-bodged.out coverage-bodged.out > coverage.all .PHONY: unit-test-coverage unit-test-coverage: @echo "Running unit-test-coverage $(GOTESTFLAGS) -tags '$(TEST_TAGS)'..." @$(GO) test $(GOTESTFLAGS) -timeout=20m -tags='$(TEST_TAGS)' -cover -coverprofile coverage.out $(GO_TEST_PACKAGES) && echo "\n==>\033[32m Ok\033[m\n" || exit 1 .PHONY: tidy tidy: $(eval MIN_GO_VERSION := $(shell grep -Eo '^go\s+[0-9]+\.[0-9.]+' go.mod | cut -d' ' -f2)) $(GO) mod tidy -compat=$(MIN_GO_VERSION) @$(MAKE) --no-print-directory $(GO_LICENSE_FILE) vendor: go.mod go.sum $(GO) mod vendor @touch vendor .PHONY: tidy-check tidy-check: tidy @diff=$$(git diff --color=always go.mod go.sum $(GO_LICENSE_FILE)); \ if [ -n "$$diff" ]; then \ echo "Please run 'make tidy' and commit the result:"; \ echo "$${diff}"; \ exit 1; \ fi .PHONY: go-licenses go-licenses: $(GO_LICENSE_FILE) $(GO_LICENSE_FILE): go.mod go.sum -$(GO) run $(GO_LICENSES_PACKAGE) save . --force --save_path=$(GO_LICENSE_TMP_DIR) 2>/dev/null $(GO) run build/generate-go-licenses.go $(GO_LICENSE_TMP_DIR) $(GO_LICENSE_FILE) @rm -rf $(GO_LICENSE_TMP_DIR) generate-ini-sqlite: sed -e 's|{{REPO_TEST_DIR}}|${REPO_TEST_DIR}|g' \ -e 's|{{TEST_LOGGER}}|$(or $(TEST_LOGGER),test$(COMMA)file)|g' \ -e 's|{{TEST_TYPE}}|$(or $(TEST_TYPE),integration)|g' \ tests/sqlite.ini.tmpl > tests/sqlite.ini .PHONY: test-sqlite test-sqlite: integrations.sqlite.test generate-ini-sqlite GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/sqlite.ini ./integrations.sqlite.test .PHONY: test-sqlite\#% test-sqlite\#%: integrations.sqlite.test generate-ini-sqlite GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/sqlite.ini ./integrations.sqlite.test -test.run $(subst .,/,$*) .PHONY: test-sqlite-migration test-sqlite-migration: migrations.sqlite.test migrations.individual.sqlite.test generate-ini-mysql: sed -e 's|{{TEST_MYSQL_HOST}}|${TEST_MYSQL_HOST}|g' \ -e 's|{{TEST_MYSQL_DBNAME}}|${TEST_MYSQL_DBNAME}|g' \ -e 's|{{TEST_MYSQL_USERNAME}}|${TEST_MYSQL_USERNAME}|g' \ -e 's|{{TEST_MYSQL_PASSWORD}}|${TEST_MYSQL_PASSWORD}|g' \ -e 's|{{REPO_TEST_DIR}}|${REPO_TEST_DIR}|g' \ -e 's|{{TEST_LOGGER}}|$(or $(TEST_LOGGER),test$(COMMA)file)|g' \ -e 's|{{TEST_TYPE}}|$(or $(TEST_TYPE),integration)|g' \ tests/mysql.ini.tmpl > tests/mysql.ini .PHONY: test-mysql test-mysql: integrations.mysql.test generate-ini-mysql GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mysql.ini ./integrations.mysql.test .PHONY: test-mysql\#% test-mysql\#%: integrations.mysql.test generate-ini-mysql GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mysql.ini ./integrations.mysql.test -test.run $(subst .,/,$*) .PHONY: test-mysql-migration test-mysql-migration: migrations.mysql.test migrations.individual.mysql.test generate-ini-pgsql: sed -e 's|{{TEST_PGSQL_HOST}}|${TEST_PGSQL_HOST}|g' \ -e 's|{{TEST_PGSQL_DBNAME}}|${TEST_PGSQL_DBNAME}|g' \ -e 's|{{TEST_PGSQL_USERNAME}}|${TEST_PGSQL_USERNAME}|g' \ -e 's|{{TEST_PGSQL_PASSWORD}}|${TEST_PGSQL_PASSWORD}|g' \ -e 's|{{TEST_PGSQL_SCHEMA}}|${TEST_PGSQL_SCHEMA}|g' \ -e 's|{{REPO_TEST_DIR}}|${REPO_TEST_DIR}|g' \ -e 's|{{TEST_LOGGER}}|$(or $(TEST_LOGGER),test$(COMMA)file)|g' \ -e 's|{{TEST_TYPE}}|$(or $(TEST_TYPE),integration)|g' \ tests/pgsql.ini.tmpl > tests/pgsql.ini .PHONY: test-pgsql test-pgsql: integrations.pgsql.test generate-ini-pgsql GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/pgsql.ini ./integrations.pgsql.test .PHONY: test-pgsql\#% test-pgsql\#%: integrations.pgsql.test generate-ini-pgsql GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/pgsql.ini ./integrations.pgsql.test -test.run $(subst .,/,$*) .PHONY: test-pgsql-migration test-pgsql-migration: migrations.pgsql.test migrations.individual.pgsql.test generate-ini-mssql: sed -e 's|{{TEST_MSSQL_HOST}}|${TEST_MSSQL_HOST}|g' \ -e 's|{{TEST_MSSQL_DBNAME}}|${TEST_MSSQL_DBNAME}|g' \ -e 's|{{TEST_MSSQL_USERNAME}}|${TEST_MSSQL_USERNAME}|g' \ -e 's|{{TEST_MSSQL_PASSWORD}}|${TEST_MSSQL_PASSWORD}|g' \ -e 's|{{REPO_TEST_DIR}}|${REPO_TEST_DIR}|g' \ -e 's|{{TEST_LOGGER}}|$(or $(TEST_LOGGER),test$(COMMA)file)|g' \ -e 's|{{TEST_TYPE}}|$(or $(TEST_TYPE),integration)|g' \ tests/mssql.ini.tmpl > tests/mssql.ini .PHONY: test-mssql test-mssql: integrations.mssql.test generate-ini-mssql GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mssql.ini ./integrations.mssql.test .PHONY: test-mssql\#% test-mssql\#%: integrations.mssql.test generate-ini-mssql GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mssql.ini ./integrations.mssql.test -test.run $(subst .,/,$*) .PHONY: test-mssql-migration test-mssql-migration: migrations.mssql.test migrations.individual.mssql.test .PHONY: playwright playwright: deps-frontend npx playwright install $(PLAYWRIGHT_FLAGS) .PHONY: test-e2e% test-e2e%: TEST_TYPE ?= e2e # Clear display env variable. Otherwise, chromium tests can fail. DISPLAY= .PHONY: test-e2e test-e2e: test-e2e-sqlite .PHONY: test-e2e-sqlite test-e2e-sqlite: playwright e2e.sqlite.test generate-ini-sqlite GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/sqlite.ini ./e2e.sqlite.test .PHONY: test-e2e-sqlite\#% test-e2e-sqlite\#%: playwright e2e.sqlite.test generate-ini-sqlite GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/sqlite.ini ./e2e.sqlite.test -test.run TestE2e/$* .PHONY: test-e2e-mysql test-e2e-mysql: playwright e2e.mysql.test generate-ini-mysql GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mysql.ini ./e2e.mysql.test .PHONY: test-e2e-mysql\#% test-e2e-mysql\#%: playwright e2e.mysql.test generate-ini-mysql GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mysql.ini ./e2e.mysql.test -test.run TestE2e/$* .PHONY: test-e2e-pgsql test-e2e-pgsql: playwright e2e.pgsql.test generate-ini-pgsql GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/pgsql.ini ./e2e.pgsql.test .PHONY: test-e2e-pgsql\#% test-e2e-pgsql\#%: playwright e2e.pgsql.test generate-ini-pgsql GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/pgsql.ini ./e2e.pgsql.test -test.run TestE2e/$* .PHONY: test-e2e-mssql test-e2e-mssql: playwright e2e.mssql.test generate-ini-mssql GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mssql.ini ./e2e.mssql.test .PHONY: test-e2e-mssql\#% test-e2e-mssql\#%: playwright e2e.mssql.test generate-ini-mssql GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mssql.ini ./e2e.mssql.test -test.run TestE2e/$* .PHONY: bench-sqlite bench-sqlite: integrations.sqlite.test generate-ini-sqlite GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/sqlite.ini ./integrations.sqlite.test -test.cpuprofile=cpu.out -test.run DontRunTests -test.bench . .PHONY: bench-mysql bench-mysql: integrations.mysql.test generate-ini-mysql GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mysql.ini ./integrations.mysql.test -test.cpuprofile=cpu.out -test.run DontRunTests -test.bench . .PHONY: bench-mssql bench-mssql: integrations.mssql.test generate-ini-mssql GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mssql.ini ./integrations.mssql.test -test.cpuprofile=cpu.out -test.run DontRunTests -test.bench . .PHONY: bench-pgsql bench-pgsql: integrations.pgsql.test generate-ini-pgsql GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/pgsql.ini ./integrations.pgsql.test -test.cpuprofile=cpu.out -test.run DontRunTests -test.bench . .PHONY: integration-test-coverage integration-test-coverage: integrations.cover.test generate-ini-mysql GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mysql.ini ./integrations.cover.test -test.coverprofile=integration.coverage.out .PHONY: integration-test-coverage-sqlite integration-test-coverage-sqlite: integrations.cover.sqlite.test generate-ini-sqlite GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/sqlite.ini ./integrations.cover.sqlite.test -test.coverprofile=integration.coverage.out integrations.mysql.test: git-check $(GO_SOURCES) $(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/integration -o integrations.mysql.test integrations.pgsql.test: git-check $(GO_SOURCES) $(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/integration -o integrations.pgsql.test integrations.mssql.test: git-check $(GO_SOURCES) $(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/integration -o integrations.mssql.test integrations.sqlite.test: git-check $(GO_SOURCES) $(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/integration -o integrations.sqlite.test -tags '$(TEST_TAGS)' integrations.cover.test: git-check $(GO_SOURCES) $(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/integration -coverpkg $(shell echo $(GO_TEST_PACKAGES) | tr ' ' ',') -o integrations.cover.test integrations.cover.sqlite.test: git-check $(GO_SOURCES) $(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/integration -coverpkg $(shell echo $(GO_TEST_PACKAGES) | tr ' ' ',') -o integrations.cover.sqlite.test -tags '$(TEST_TAGS)' .PHONY: migrations.mysql.test migrations.mysql.test: $(GO_SOURCES) generate-ini-mysql $(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/integration/migration-test -o migrations.mysql.test GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mysql.ini ./migrations.mysql.test .PHONY: migrations.pgsql.test migrations.pgsql.test: $(GO_SOURCES) generate-ini-pgsql $(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/integration/migration-test -o migrations.pgsql.test GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/pgsql.ini ./migrations.pgsql.test .PHONY: migrations.mssql.test migrations.mssql.test: $(GO_SOURCES) generate-ini-mssql $(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/integration/migration-test -o migrations.mssql.test GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mssql.ini ./migrations.mssql.test .PHONY: migrations.sqlite.test migrations.sqlite.test: $(GO_SOURCES) generate-ini-sqlite $(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/integration/migration-test -o migrations.sqlite.test -tags '$(TEST_TAGS)' GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/sqlite.ini ./migrations.sqlite.test .PHONY: migrations.individual.mysql.test migrations.individual.mysql.test: $(GO_SOURCES) for pkg in $(shell $(GO) list code.gitea.io/gitea/models/migrations/...); do \ GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mysql.ini $(GO) test $(GOTESTFLAGS) -tags '$(TEST_TAGS)' $$pkg; \ done .PHONY: migrations.individual.sqlite.test\#% migrations.individual.sqlite.test\#%: $(GO_SOURCES) generate-ini-sqlite GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/sqlite.ini $(GO) test $(GOTESTFLAGS) -tags '$(TEST_TAGS)' code.gitea.io/gitea/models/migrations/$* .PHONY: migrations.individual.pgsql.test migrations.individual.pgsql.test: $(GO_SOURCES) for pkg in $(shell $(GO) list code.gitea.io/gitea/models/migrations/...); do \ GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/pgsql.ini $(GO) test $(GOTESTFLAGS) -tags '$(TEST_TAGS)' $$pkg; \ done .PHONY: migrations.individual.pgsql.test\#% migrations.individual.pgsql.test\#%: $(GO_SOURCES) generate-ini-pgsql GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/pgsql.ini $(GO) test $(GOTESTFLAGS) -tags '$(TEST_TAGS)' code.gitea.io/gitea/models/migrations/$* .PHONY: migrations.individual.mssql.test migrations.individual.mssql.test: $(GO_SOURCES) generate-ini-mssql for pkg in $(shell $(GO) list code.gitea.io/gitea/models/migrations/...); do \ GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mssql.ini $(GO) test $(GOTESTFLAGS) -tags '$(TEST_TAGS)' $$pkg -test.failfast; \ done .PHONY: migrations.individual.mssql.test\#% migrations.individual.mssql.test\#%: $(GO_SOURCES) generate-ini-mssql GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mssql.ini $(GO) test $(GOTESTFLAGS) -tags '$(TEST_TAGS)' code.gitea.io/gitea/models/migrations/$* .PHONY: migrations.individual.sqlite.test migrations.individual.sqlite.test: $(GO_SOURCES) generate-ini-sqlite for pkg in $(shell $(GO) list code.gitea.io/gitea/models/migrations/...); do \ GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/sqlite.ini $(GO) test $(GOTESTFLAGS) -tags '$(TEST_TAGS)' $$pkg; \ done .PHONY: migrations.individual.sqlite.test\#% migrations.individual.sqlite.test\#%: $(GO_SOURCES) generate-ini-sqlite GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/sqlite.ini $(GO) test $(GOTESTFLAGS) -tags '$(TEST_TAGS)' code.gitea.io/gitea/models/migrations/$* e2e.mysql.test: $(GO_SOURCES) $(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/e2e -o e2e.mysql.test e2e.pgsql.test: $(GO_SOURCES) $(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/e2e -o e2e.pgsql.test e2e.mssql.test: $(GO_SOURCES) $(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/e2e -o e2e.mssql.test e2e.sqlite.test: $(GO_SOURCES) $(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/e2e -o e2e.sqlite.test -tags '$(TEST_TAGS)' .PHONY: check check: test .PHONY: install $(TAGS_PREREQ) install: $(wildcard *.go) CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) install -v -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)' .PHONY: build build: frontend backend .PHONY: frontend frontend: $(WEBPACK_DEST) .PHONY: backend backend: go-check generate-backend $(EXECUTABLE) # We generate the backend before the frontend in case we in future we want to generate things in the frontend from generated files in backend .PHONY: generate generate: generate-backend .PHONY: generate-backend generate-backend: $(TAGS_PREREQ) generate-go .PHONY: generate-go generate-go: $(TAGS_PREREQ) @echo "Running go generate..." @CC= GOOS= GOARCH= $(GO) generate -tags '$(TAGS)' $(GO_PACKAGES) .PHONY: security-check security-check: go run $(GOVULNCHECK_PACKAGE) ./... $(EXECUTABLE): $(GO_SOURCES) $(TAGS_PREREQ) CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) build $(GOFLAGS) $(EXTRA_GOFLAGS) -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)' -o $@ .PHONY: release release: frontend generate release-windows release-linux release-darwin release-freebsd release-copy release-compress vendor release-sources release-docs release-check $(DIST_DIRS): mkdir -p $(DIST_DIRS) .PHONY: release-windows release-windows: | $(DIST_DIRS) CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) run $(XGO_PACKAGE) -go $(XGO_VERSION) -buildmode exe -dest $(DIST)/binaries -tags 'osusergo $(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets 'windows/*' -out gitea-$(VERSION) . ifeq (,$(findstring gogit,$(TAGS))) CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) run $(XGO_PACKAGE) -go $(XGO_VERSION) -buildmode exe -dest $(DIST)/binaries -tags 'osusergo gogit $(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets 'windows/*' -out gitea-$(VERSION)-gogit . endif .PHONY: release-linux release-linux: | $(DIST_DIRS) CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) run $(XGO_PACKAGE) -go $(XGO_VERSION) -dest $(DIST)/binaries -tags 'netgo osusergo $(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets '$(LINUX_ARCHS)' -out gitea-$(VERSION) . .PHONY: release-darwin release-darwin: | $(DIST_DIRS) CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) run $(XGO_PACKAGE) -go $(XGO_VERSION) -dest $(DIST)/binaries -tags 'netgo osusergo $(TAGS)' -ldflags '$(LDFLAGS)' -targets 'darwin-10.12/amd64,darwin-10.12/arm64' -out gitea-$(VERSION) . .PHONY: release-freebsd release-freebsd: | $(DIST_DIRS) CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) run $(XGO_PACKAGE) -go $(XGO_VERSION) -dest $(DIST)/binaries -tags 'netgo osusergo $(TAGS)' -ldflags '$(LDFLAGS)' -targets 'freebsd/amd64' -out gitea-$(VERSION) . .PHONY: release-copy release-copy: | $(DIST_DIRS) cd $(DIST); for file in `find . -type f -name "*"`; do cp $${file} ./release/; done; .PHONY: release-check release-check: | $(DIST_DIRS) cd $(DIST)/release/; for file in `find . -type f -name "*"`; do echo "checksumming $${file}" && $(SHASUM) `echo $${file} | sed 's/^..//'` > $${file}.sha256; done; .PHONY: release-compress release-compress: | $(DIST_DIRS) cd $(DIST)/release/; for file in `find . -type f -name "*"`; do echo "compressing $${file}" && $(GO) run $(GXZ_PACKAGE) -k -9 $${file}; done; .PHONY: release-sources release-sources: | $(DIST_DIRS) echo $(VERSION) > $(STORED_VERSION_FILE) # bsdtar needs a ^ to prevent matching subdirectories $(eval EXCL := --exclude=$(shell tar --help | grep -q bsdtar && echo "^")./) # use transform to a add a release-folder prefix; in bsdtar the transform parameter equivalent is -s $(eval TRANSFORM := $(shell tar --help | grep -q bsdtar && echo "-s '/^./gitea-src-$(VERSION)/'" || echo "--transform 's|^./|gitea-src-$(VERSION)/|'")) tar $(addprefix $(EXCL),$(TAR_EXCLUDES)) $(TRANSFORM) -czf $(DIST)/release/gitea-src-$(VERSION).tar.gz . rm -f $(STORED_VERSION_FILE) .PHONY: release-docs release-docs: | $(DIST_DIRS) docs tar -czf $(DIST)/release/gitea-docs-$(VERSION).tar.gz -C ./docs . .PHONY: docs docs: cd docs; bash scripts/trans-copy.sh; .PHONY: deps deps: deps-frontend deps-backend deps-tools deps-py .PHONY: deps-py deps-py: .venv .PHONY: deps-frontend deps-frontend: node_modules .PHONY: deps-backend deps-backend: $(GO) mod download .PHONY: deps-tools deps-tools: $(GO) install $(AIR_PACKAGE) $(GO) install $(EDITORCONFIG_CHECKER_PACKAGE) $(GO) install $(GOFUMPT_PACKAGE) $(GO) install $(GOLANGCI_LINT_PACKAGE) $(GO) install $(GXZ_PACKAGE) $(GO) install $(MISSPELL_PACKAGE) $(GO) install $(SWAGGER_PACKAGE) $(GO) install $(XGO_PACKAGE) $(GO) install $(GO_LICENSES_PACKAGE) $(GO) install $(GOVULNCHECK_PACKAGE) $(GO) install $(ACTIONLINT_PACKAGE) node_modules: package-lock.json npm install --no-save @touch node_modules .venv: poetry.lock poetry install --no-root @touch .venv .PHONY: update update: update-js update-py .PHONY: update-js update-js: node-check | node_modules npx updates -u -f package.json rm -rf node_modules package-lock.json npm install --package-lock @touch node_modules .PHONY: update-py update-py: node-check | node_modules npx updates -u -f pyproject.toml rm -rf .venv poetry.lock poetry install --no-root @touch .venv .PHONY: fomantic fomantic: rm -rf $(FOMANTIC_WORK_DIR)/build cd $(FOMANTIC_WORK_DIR) && npm install --no-save cp -f $(FOMANTIC_WORK_DIR)/theme.config.less $(FOMANTIC_WORK_DIR)/node_modules/fomantic-ui/src/theme.config cp -rf $(FOMANTIC_WORK_DIR)/_site $(FOMANTIC_WORK_DIR)/node_modules/fomantic-ui/src/ cd $(FOMANTIC_WORK_DIR) && npx gulp -f node_modules/fomantic-ui/gulpfile.js build # fomantic uses "touchstart" as click event for some browsers, it's not ideal, so we force fomantic to always use "click" as click event $(SED_INPLACE) -e 's/clickEvent[ \t]*=/clickEvent = "click", unstableClickEvent =/g' $(FOMANTIC_WORK_DIR)/build/semantic.js $(SED_INPLACE) -e 's/\r//g' $(FOMANTIC_WORK_DIR)/build/semantic.css $(FOMANTIC_WORK_DIR)/build/semantic.js rm -f $(FOMANTIC_WORK_DIR)/build/*.min.* .PHONY: webpack webpack: $(WEBPACK_DEST) $(WEBPACK_DEST): $(WEBPACK_SOURCES) $(WEBPACK_CONFIGS) package-lock.json @$(MAKE) -s node-check node_modules rm -rf $(WEBPACK_DEST_ENTRIES) npx webpack @touch $(WEBPACK_DEST) .PHONY: svg svg: node-check | node_modules rm -rf $(SVG_DEST_DIR) node build/generate-svg.js .PHONY: svg-check svg-check: svg @git add $(SVG_DEST_DIR) @diff=$$(git diff --color=always --cached $(SVG_DEST_DIR)); \ if [ -n "$$diff" ]; then \ echo "Please run 'make svg' and 'git add $(SVG_DEST_DIR)' and commit the result:"; \ echo "$${diff}"; \ exit 1; \ fi .PHONY: lockfile-check lockfile-check: npm install --package-lock-only @diff=$$(git diff --color=always package-lock.json); \ if [ -n "$$diff" ]; then \ echo "package-lock.json is inconsistent with package.json"; \ echo "Please run 'npm install --package-lock-only' and commit the result:"; \ echo "$${diff}"; \ exit 1; \ fi .PHONY: update-translations update-translations: mkdir -p ./translations cd ./translations && curl -L https://crowdin.com/download/project/gitea.zip > gitea.zip && unzip gitea.zip rm ./translations/gitea.zip $(SED_INPLACE) -e 's/="/=/g' -e 's/"$$//g' ./translations/*.ini $(SED_INPLACE) -e 's/\\"/"/g' ./translations/*.ini mv ./translations/*.ini ./options/locale/ rmdir ./translations .PHONY: generate-license generate-license: $(GO) run build/generate-licenses.go .PHONY: generate-gitignore generate-gitignore: $(GO) run build/generate-gitignores.go .PHONY: generate-images generate-images: | node_modules npm install --no-save fabric@6.0.0-beta19 imagemin-zopfli@7 node build/generate-images.js $(TAGS) .PHONY: generate-manpage generate-manpage: @[ -f gitea ] || make backend @mkdir -p man/man1/ man/man5 @./gitea docs --man > man/man1/gitea.1 @gzip -9 man/man1/gitea.1 && echo man/man1/gitea.1.gz created @#TODO A small script that formats config-cheat-sheet.en-us.md nicely for use as a config man page .PHONY: docker docker: docker build --disable-content-trust=false -t $(DOCKER_REF) . # support also build args docker build --build-arg GITEA_VERSION=v1.2.3 --build-arg TAGS="bindata sqlite sqlite_unlock_notify" . # This endif closes the if at the top of the file endif # Disable parallel execution because it would break some targets that don't # specify exact dependencies like 'backend' which does currently not depend # on 'frontend' to enable Node.js-less builds from source tarballs. .NOTPARALLEL: