We expose many of these builders to Objective-C, but Swift is unable
to map forward-declarations of those types (@class) back to the real
Swift classes because they're nested within the protos. Since we're
already using fully-qualified names even in Swift (e.g.
"SSKProtoContentBuilder"), nesting isn't worth the trouble it's
causing.
This change:
- Fixes some warnings reported by [Shellcheck][0]. Notably, if your repo
is in a folder with a space (e.g., `/Users/foo/My Code/Signal-iOS`),
this script wouldn't work.
- Adds `set -u` to error when using unbound variables, in case we make a
mistake
- Adds `set -o pipefail` to error if piping fails. Not used by this
script, but I put this line in all my shell script just in case
Tested this when taking 5.37.0 to production and it worked fine.
[0]: https://www.shellcheck.net/
_I recommend reviewing this with whitespace changes disabled._
Signal has renamed its primary branch to `main`. This updates references
to the old name, `master`, to either reference `main` or a specific
commit hash.
I also fixed a couple of small whitespace issues in a file I was
editing.
This script broke in the migration to Python 3 (see
1101db6a29). This change fixes those bugs,
and also:
1. Allows you to supply multiple source directories. Previously, you
could only provide one, which meant that you'd see lots of unused
strings, even though they were used in a different folder.
2. Adds usage instructions with `--help`, thanks to Python's `argparse`
module.
3. Quits with a `1` status code if any unused strings are found.
4. Prints unused strings instead of used ones.
5. Speeds up the script by only searching for keys. Previously, it'd
also look for comments and blank lines in the `Localizable.strings`
file.
6. Speeds up the script by only reading files once, instead of once per
key.
This quiets the following deprecation warning:
./Scripts/reverse_integration_check.py:56: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
tag for tag in unmerged_tags if LooseVersion(tag) > LooseVersion(epoch_tag)
[`distutils.LooseVersion` will be removed in Python 3.12][0], and there
doesn't seem to be an equivalent in the standard library. I implemented
a simple `Version` class to replicate this functionality.
(I also looked into other solutions, such as rewriting the script in
Swift, but this seems like the right solution for now.)
[0]: https://peps.python.org/pep-0632/
This adds `5.23.0.22-beta` to our list of ignored tags, to avoid this error when running the script:
RuntimeError: 💥 Found unmerged tags: ['5.23.0.22-beta']
We saw this error when deploying 5.25.
genstrings warns on non-constant strings being passed to
NSLocalizedString, but that happens precisely when we define
OWSLocalizedString. Skip the two files where we define it (one for
each language).
While here:
- Use find's -exec feature rather than a separate xargs invocation.
- Make the script shellcheck-clean.
In Python 2, `subprocess.check_output` returns a string. In Python 3, it
returns a byte string unless you provide `text=True`.
This makes sure all calls have that option for compatibility.
Also, my editor was auto-formatting these with [Black][0], which I
didn't prevent, so now these files are formatted a little better.
[0]: https://github.com/psf/black
On my machine, the `./precommit.py --all` took 344.15 seconds (more than
5 minutes). This change speeds it up so that it takes less than 10
seconds.
It primarily achieves this by running `swiftlint` twice instead of twice
per file. There are some other smaller changes, too:
- Use a `set` for common operations
- Avoid a needless call to `text.split`
- Use built-in `pathlib.Path().parts` instead of a home-rolled solution
Tested this by running `./precommit.py` with all flags.
Python 3 removed the [`cmp` function][0] which this script relied on.
Calling it was unnecessary, so I removed it (and cleaned up some of the
surrounding code).
Tested this with the `--all`, `--path`, and `--ref` flags.
[0]: https://docs.python.org/2.7/library/functions.html#cmp
Every single message updates a TSThread model, but only a change in a
member's profile name or phone number, or a change to a group's model,
can update the indexing information. Turn 'shouldBeIndexedForFTS' into
a tri-state 'FTSIndexMode' with options 'never', 'manualUpdates', and
'always', and use 'manualUpdates' for TSThreads. Then explicitly
reindex on any of the changes listed above.
- The Pods/ directory always exists even before submodules have been
initialized; check for Pods/.git instead, which may be a file or
a folder depending on how the submodule was set up.
- When cloning for the first time, make sure the remote is called
'private' so that later updates will reference it correctly. Also
run `git submodule absorbgitdirs` so that git stores the submodule
state inside the top-level .git directory.
- For an existing directory, simplify the check for the presence of
a proper 'private' remote.
- Check that we're running from the repository root so we don't get
weird errors or do random clones.
- Make the script Shellcheck-clean.
ASC will assign its own build numbers to our builds independent of what
our plist requests. Right now, we're in a situation where a failed build
has forced our local and ASC variants out-of-sync. This change allows
the version flag to specify a fix to re-sync.