Florian Zschocke [Thu, 13 Jan 2022 17:19:14 +0000 (18:19 +0100)]
build: Determine release version with simple grep
To determine what the release version is to be, use a simple grep over
the moxie.build file and cut off the `-SNAPSHOT` part. The moxie
tag command doesn't do anything else, either. But the problem is that
when using the moxie tag command on the release branch, where the
version has already been set to a release version, it would create
a second release version, like so: 1.9.2-1.
Florian Zschocke [Thu, 16 Dec 2021 22:46:28 +0000 (23:46 +0100)]
build: Allow for updating an existing draft release
When creating a release draft and uploading assets, provision for the case
that a draft release already exists. In that case, instead of creating a
release, the existing release (changelog) is edited and the assets are
deleted before the new built ones are uploaded.
This commit also introduces the `${gh.repo}` property in build.xml,
so that the Github project could be chosen dynamically. Not really needed,
to be honest, but, yeah, whatever.
Florian Zschocke [Thu, 30 Jan 2020 20:47:12 +0000 (21:47 +0100)]
Build: create macro for creating the release process script
Refactor the creation of the release process script, from
`release.template` into a `macrodef`.
Add a new target `releaseScript`, so that the release script can be
created after the `tagRelease` target was run.
This is helpful if the `tagRelease` target is run by a different,
earlier process than the actual release creation process.
To help with analysis, try to detect if the instance is running inside
a container. Some containers are detected, but this is probably not
exhaustive. At least a Docker container should be detectable.
Report in the runtime manager to the log if a container was detected.
pages: Fix repo-relative reference links in markdown docs
As with explicit links, also for reference links in markdown documents
which point to repository-relative files the links are broken. They do
not take the path to the repository into account.
This fix is related to commit b23269 which fixed issue #1358
for explicit links.
bug: Fix double encoding links in Markdown/Wiki pages
When parsing Markdown or Wiki pages, links get URL encoded. This happened
twice for links to other documents. Once explicitly and once by Wicket
when it creates a `urlFor` the page. That results in multi-byte
characters getting percent escaped, and then the percent character again
getting percent escaped.
The explicit encoding looks like a forgotten left over, so it gets
removed from the code. The Wicket encoding is smarter anyways, knowing
what is path and what is parameter.
Florian Zschocke [Thu, 25 Nov 2021 14:28:18 +0000 (15:28 +0100)]
docs: Update docker URL
Update the URL to the Gitblit docker image to point to the
`gitblit/gitblit` repository, which I now consider the official
Docker repository.
Also link to the Docker images on the main page.
Tom [Wed, 23 Nov 2016 17:30:48 +0000 (18:30 +0100)]
Fix NPE
Although it seems strange to have a RefModel with a referenced object
but a null Ref, Gitblit uses such RefModels for instance in
JGitUtils.getNotesOnCommit().
Be careful to do something sensible when that Ref is null.
Tom [Wed, 26 Oct 2016 20:49:56 +0000 (22:49 +0200)]
Issue #1011: do not serialize JGit commit objects
JGit commit objects are a recursive data structure; they have links to
their parent commits. Serializing a JGit commit will try to recursively
serialize all reachable ancestors as faras they have been loaded. If
that ancestor chain is too long, a StackOverflowError is thrown during
Wicket's page serialization if a page has a reference to sucha JGit
commit.
Fixed by making sure that pages o not contain references to JGit
commits. Use the (existing) wrapper object RepositoryCommit instead.
* RepositoryCommit has a transient reference to the JGit commit and
reads the commit from the repository upon de-serialization.
* RefModel is a similar case (JGit tags/branches may also have links
to the commits they point to). Solved a bit differently by making it
a pure data object by transferring the interesting data from the JGit
object in the constructor.
* Change DataViews instantiated with RevCommit to use RepositoryCommit
instead.
* Change inner anonymous DataViews to ensure they do not have a
synthesized field referencing the "allRefs" map. Such a synthesized
field would also get serialized, and then serialize JGit commits
again.
Finally, remove non-transient logger instances in Wicket classes. Those
might lead to NotSerializableException.
These StackOverflowErrors have been reported in several places since
2014:
Florian Zschocke [Sun, 24 Oct 2021 15:55:36 +0000 (17:55 +0200)]
raw: URL encode the links to raw view of files
So far links to raw view were not encoded. The browser did some encoding
of spaces on its own, which the servlet would unescape, since it uses
the `HttpServletRequest.getPathInfo` method. That decodes the path
before returning it.
A problem arises when a bracket is in the file (or folder) name. The
brackets are the characters that are not allowed in the path, according
to the `URI.parse` method. (Which is a bit harsh, because brackets
actually are only reserved for the host part since IPv6.) That means
that the decoding fails when a bracket character is encountered.
This went unnoticed since the failed decoding will return the path
as it got it. But once there is a space in the file name, which the
browser helpfully encoded for us, the failed decoding will now leave the
encoded space in there. And that will result in a path that does not
exist, e.g. `file%20[a]`.
To be on the safe side, we simply encode the path in the links that we
generate, so that it complies with the rules that are used in `getPathInfo`.
Florian Zschocke [Sat, 23 Oct 2021 22:44:18 +0000 (00:44 +0200)]
TimeUtils: Change daysAgo to calculate difference in calendar days
The `daysAgo` method seemed to want to normalize on a calendar day? I
can't really tell what it was trying to do, but the problem is that it
does not take into account any time shift due to time zones so it never
really worked outside of GMT.
So instead a new `calendarDaysAgo` method is added (because I am unsure
on what the `daysAgo` method is trying to do. It can probably be removed).
The new method cleanly calculates difference in calendar days because it
normalizes the two given time stamps on the same time zone.
The `timeAgo` method now used the new method. This fixes #1248.
Florian Zschocke [Sat, 23 Oct 2021 21:41:25 +0000 (23:41 +0200)]
TimeUtils: Move unit test to same package as TimeUtils is
For some reason the `TimeUtilsTest` class is, like almost all tests, in
the `com.gitblit.tests` package. But this way all methods in classes
which we might predominately need for tests have to be public.
So move the unit test class `TimeUtilsTest` to the same package as the
class it is testing, i.e. `com.gitblit.utils.TimeUtils`.
This way we ca set the new added methods which get the current time
passed in to be at least not public.
Florian Zschocke [Sat, 23 Oct 2021 21:20:47 +0000 (23:20 +0200)]
TimeUtils: Increase testability and add tests
Add tests for `timeAgo` to analyse issue #1248.
The tests are dependent on when they run as they time functions use the
current date and time. To make them testable in a reproducible way, we
need the ability to pass in what we think is "now". So add overloaded
methods that take a `now` parameter so that we can pass in the current
time.
Florian Zschocke [Thu, 21 Oct 2021 20:03:12 +0000 (22:03 +0200)]
Property bundle: Fix incorrect property keys
Some property keys had typos.
There is a `gb.ticketStatus` and a `gb.ticketState`. Neither is used
anywhere in the code, but only the former is defined in the default file.
So only use `gb.ticketStatus`.
Florian Zschocke [Thu, 21 Oct 2021 19:02:11 +0000 (21:02 +0200)]
fix: Remove duplicate property keys from properties files
Some property keys were duplicated, mostly `status`, `permission` and
`comment`.
The problem with `gb.comment` is, that it is used in two different
locations in two different meanings. One as a verb, the second as a
noun. Which makes no difference in English, but other languages.
The solution is that the second key is renamed to `gb.sshKeyComment`.
The code is adjusted accordingly.
Florian Zschocke [Wed, 20 Oct 2021 19:05:02 +0000 (21:05 +0200)]
Add a unit test to check if the resource bundle can be loaded
To prevent that we have a resource file in a resource bundle broken and
not loading undiscovered for years, add a unit test that will load the
resource properties file for each of the languages.
In order to check if the file was loaded and the bundle mechanism
didn't fall back on the default, a new property key is added to each
language file, solely for the purpose to be checked in the unit test.
Fix output of migrate-/reindex-tickets bash scripts
Fix the output of the help texts in the reindex-tickets and
reindex-tickets bash scripts.
For one the double quotes are unnecessary and get printed out, too.
Secondly, an empty line needs a `echo.`. A simple `echo` will prin the
state of the echo setting, i.e. `Echo is enabled (1)` or something similar.
Use SETLOCAL in batch scripts to restrict the visibility of variables
that are set in the script to the script execution. Otherwise the variables
will also be set in the calling shell. That is not a problem when a script
is executed by double clicking it in Windows Explorer. But now that the
scripts are changed so that they can be called on the command line from
other folders, they should also no clutter the calling environment.
Zwixx [Wed, 26 May 2021 15:05:26 +0000 (17:05 +0200)]
Use full path to Gitblit directory in batch scripts
In order to call the Windows batch scripts on the command line
from a different folder, the path to the files in the Gitblit
directory needs to be explicitly stated in the Java command.
Otherwise the JAR files or data directory are not found as they
would be searched in the current directory.
The last fix for the stored config merged from Curly060 used Java8-isms.
In order to be able to include this fix in the next release, which will
be for 1.9, I have converted this to be compatible with Java 7.
Also, a file header was added to place it under APL.
raw: Fix raw links to branches with a slash in their name
When a branch has a slash in the name, the raw servlet was not able
to find the path under that branch. This is due to the replacement of
the forward slash character for URLs. It was not taken into account
when comparing the branch name later.
This fixes #1290 and its duplicates #1234 and #813.
raw: Fix getPath with trailing slash that was escaped
While this may be an unlikely scenario, let's still prevent this.
When a link was created for a path that ends in a trailing slash,
that trailing slash would be replaced with the `forwardSlashCharacter`.
But in getPath that final slash would be transformed back *after* the
check to chop off trailing slashes. This is now switched so that such a
trailing slash is also chopped off.
raw: Refactor RawServlet:getBranch and :getPath parameters
Refactor the `getBranch` and `getPath` methods to take a String as
second parameter, which is the already sanitised path info. Don't get
the path info from a passed in request anymore.
The methods are only ever called from within `processRequest`, which
already does some checks on the path info, like removing a leading
slash character. So no need to do that every time again the methods
and passing a request for that.
raw: Strip leading and trailing slash from repo and path names for link
When creating a link for raw display, a trailing slash is stripped from
the end of the base URL. Also do this for the repository, as well as
stripping leading slashes from the repository and the path values.
Florian Zschocke [Thu, 29 Oct 2020 11:41:20 +0000 (12:41 +0100)]
Fix 1150: Use external link instead of internal wiki link for tickets_setup
The `tickets_overview` page links to the `tickets_setup` page using a
wiki style internal link: `[[tickets setup]]`. Whatever library is
interpreting that is creating a link under the assumption that the
resulting page will be called `tickets-setup.html`. But that is not the
convention used by Moxie, which will use the source file name and thus
create a file called `tickets_setup.html`.
I was not able to find out which of the many libraries included is the
one that parses this file and creates the link. Messy.
There are two solutions. One is to configure the Moxie site build to
generate the file as `tickets-setup.html`. But this would break any
links to that page that might exist somewhere on the Interweb. So I
opted for the other option, which is to not use wiki syntax for the
reference to the local page but normal markdown syntax. This is not
a wiki, afterall.
Florian Zschocke [Thu, 22 Oct 2020 18:43:45 +0000 (20:43 +0200)]
build: Activate JaCoCo explicitly for Ant build
When building with Ant, instead of Moxie, JaCoCo is not included in the
classpath. So explicitly initialise the full `jacocoant.jar` from the
`.moxie` repository.
For this we had to switch the dependency to use the `nodeps` jar which
includes all dependencies.
While most systems will not need the class path passed to the JVM with
the `-cp` parameter to be in quotes, apparently some exist where that
will not work without the quotes, e.g. FreeBSD.
So always use quotes for the class path in all scripts.
Delete password from memory in AuthenticationManager
Zero out the password to remove it from memory after use.
This is only a first step, implementing it for one method:
`AuthenticationManager.authenticate(String, char[], String)`.
The upgrade of a MD5 stored password hash to a PBKDF password hash
destroys the stored password. The has check zeroes out the password that
is tested, so that the new hash is built over the zeroed out value.
This fix prevents that an also adds a check to the test.
The Eclipse maven repositories changed to only allow HTTPS and not
serve HTTP anymore. HTTP will redirect to HTTPS, which moxie does
not handle well and fails.
So the registered Eclipse repositories are changed to 'https://'
transport.
Florian Zschocke [Thu, 30 Jan 2020 20:42:13 +0000 (21:42 +0100)]
Build: Store release version information in file.
If requested, by setting a file name in the `versionInfo`
property, store release version and tag in a file, for
other scripts and programs to pick up.
Florian Zschocke [Tue, 28 Jan 2020 12:53:39 +0000 (13:53 +0100)]
Add Maven Central to registeredRepositories
Moxie does have these defined by default, but with transport HTTP.
Since January 2020, Maven Central only accepts HTTPS, no HTTP
anymore. So we add them here explicitly, with `https://`.
We add it to the `build.moxie` file, instead of keeping it in a
local `settings.moxie`, so that a CI server can immediately use it.