1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-09 00:12:40 +01:00
Commit graph

2114 commits

Author SHA1 Message Date
Joshua Spence
2db40f9953 Various translation improvements
Summary: Depends on D14070.

Test Plan: Eyeball it.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D14072
2015-11-02 21:31:04 +11:00
Joshua Spence
d12bcdc683 Remove some unused methods from ArcanistLinter
Summary: These methods are unused.

Test Plan: N/A

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D14065
2015-11-02 21:23:01 +11:00
epriestley
baf5eb8a87 Explicitly provide "--ff" when performing squash merges in "arc land" under Git
Summary: Ref T3855. See discussion leading up to T3855#142304.

Test Plan: See T3855#142304.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T3855

Differential Revision: https://secure.phabricator.com/D14365
2015-10-28 17:13:15 -07:00
epriestley
c844669326 After pushing at the end of "arc land", cascade the origin through all local tracking branches
Summary:
Fixes T9661. Users can construct arbitrarily long chains from the remote, like:

  (remote) origin/master -> (local) cascade-a -> (local) cascade-b -> (local) cascade-c -> (local) cascade-d

When a user lands "cascade-d" onto "origin/master", we should pull A, B and C if they aren't ahead of the remote.

If a user lands "cascade-d" onto itself, we should pull A, B, and C if they aren't ahead of the remote, then reset D to the remote.

We also find this chain if the last component of it is connected by the local branch having the same name as the remote branch (typical for "master") instead of an actual connection through tracking brnaches.

Test Plan: See comment below.

Reviewers: chad

Reviewed By: chad

Subscribers: edibiase

Maniphest Tasks: T9661

Differential Revision: https://secure.phabricator.com/D14361
2015-10-28 14:01:35 -07:00
epriestley
2a2fd6e338 Pull git upstream-path logic into a separate class
Summary:
Ref T9661. I need to reuse this to fix the complex workflow described in T9661 where we need to follow multiple paths to the upstream and cascade updates across them.

Pull the logic into a separate class to make this easier and less copy/pastey.

This shouldn't change any behavior.

Test Plan: Ran `arc land --preview` from detached head, remote-tracking branch, non-tracking branch, local-tracking branch. Selection of target/remote seemed correct in all cases.

Reviewers: chad

Reviewed By: chad

Subscribers: edibiase

Maniphest Tasks: T9661

Differential Revision: https://secure.phabricator.com/D14360
2015-10-28 13:19:30 -07:00
epriestley
411a4f4a39 Fix a check when deciding to destroy the local branch after "arc land"
Summary: Fixes T9660. The behavior for this check wasn't quite right -- we want to check the "source ref" (what we're landing) against the "target onto" (the branch we're landing it onto).

Test Plan:
  - Landed from `master` (tracking origin/master). No delete.
  - Landed from `feature1` (tracking local/master). Delete.
  - Landed from `feature2` (tracking origin/master). Delete.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T9660

Differential Revision: https://secure.phabricator.com/D14358
2015-10-28 10:10:41 -07:00
epriestley
aa5c023fe8 Make rules for guessing onto/remote more powerful and more explicit in arc land
Summary:
Fixes T9543. Fixes T9658. Ref T3855.

Major functional change is that you can have a sequence of branches like:

  origin/master -> notmaster -> feature1

...where they track each other, but you named your local master something else. Currently, we resolve only one level of upstreams, so we try to land onto "notmaster" in this case, which is wrong.

Instead, keep resolving upstreams until we either hit a cycle, don't have another upstream to look at, or find someting in a remote. In this case we'll eventually find "origin/master" and select "origin" as the remote and "master" as the target.

Other minor changes:

  - Make this selection process explicit.
  - Make the help 3000x longer.

Also fix a bug where we could incorrectly try to tell Differential to update awith `--preview`.

Test Plan:
  - Landed from a tag.
  - Landed from a tracking branch.
  - Landed from an nth-degree tracking branch.
  - Tried to land from a local branch with a cycle in upstreams.
  - Landed with --remote and --onto.
  - Read `arc help land`.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T9658, T3855, T9543

Differential Revision: https://secure.phabricator.com/D14357
2015-10-28 09:37:17 -07:00
epriestley
a03c6079bb Make "arc land" great again
Summary:
Ref T3855. Fixes T9537. Fixes T8620. Fixes T4333.

This declares bankruptcy and replaces the entire `arc land` workflow under Git. These are the notable changes:

  - (T3855) You can now land from a branch to itself.
  - (T3855) We now try to restore the original state very aggressively after any failure, instead of dumping you into the middle of a mess.
  - (T9537) You can now land without a local branch.
  - ([not actually] T9543) We'll now ignore the local branch if it just happens to be named the same thing as the remote branch but doesn't actually track it.
  - (T8620) You can now land from a detached HEAD.
  - (T4333) We now preserve the author and author date of whatever you land.

This may need some followup work. In particular:

  - The signal handler (that tries to put you in a better place if you ^C in the middle of things) causes ^C to work awkwardly in prompts. This might not be worth it.
  - Errors/instructions on push/merge issues might need work.
  - I dropped support for `--delete-remote` and `--update-with-blah-blah` because I think these flags aren't worth their complexity.
  - I've simplified the update/merge algorithm a bit. It may need some complexity added back in.
  - I probably missed a few things because this covers like 200 unique, creative workflows.
  - Users might need more guidance on the workflows that drop them in the middle of nowhere if they manage to reach them more often than I think.

Test Plan:
  - Used `arc land` to land like at least 15,000 different kinds of changes.
  - Landed normally.
  - Landed from a branch onto itself.
  - Landed from a detached head.
  - Landed nothing.
  - Landed with no local branch.
  - Landed onto made-up branches.
  - Landed with bad targets.
  - ^C'd things in the middle.

Reviewers: chad

Reviewed By: chad

Subscribers: tycho.tatitscheff

Maniphest Tasks: T3855, T4333, T8620, T9537, T9543

Differential Revision: https://secure.phabricator.com/D14356
2015-10-28 07:04:57 -07:00
Michael Krasnow
3308da5f8f Fix T9635 by initializing the property
Summary: Fix T9635 by properly initializing a property

Test Plan: run arc unit

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley

Maniphest Tasks: T9635

Differential Revision: https://secure.phabricator.com/D14340
2015-10-26 09:48:31 -07:00
epriestley
dfde57ff81 Improve two error handling behaviors in arc upgrade
Summary:
Fixes T9222. Two issues here:

  - First, we currently continue on error. Throw instead. I just swapped us from "phutil_passthru()" to "execx()" since I don't think printing out the "pulling from remote..." status messages is very important, and this makes it easier to raise a useful exception.
  - Second, if you have a dirty working copy we currently may try to do some sort of silly stuff which won't work, like prompt you to amend changes. Instead, do a slightly lower-level check and just bail.

Test Plan:
  - Ran `arc upgrade` with a dirty working copy and got a tailored, useful error.
  - Ran `arc upgrade` with an artificially bad `git pull` command, got a failure with a specific error message.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T9222

Differential Revision: https://secure.phabricator.com/D14317
2015-10-22 19:55:16 +00:00
Jon Parise
b3ea439f4d External linters can now specify a version requirement.
Summary:
Linters can now use the `version` configuration value to specify the required
version of the external binary. The version number may be prefixed with <, <=,
>, >=, or = to specify the version comparison operator (default: =).

PHP's native `version_compare()` function is used to perform the comparison.

Fixes T4954.

Test Plan: Tested against a sample of external linters.

Reviewers: joshuaspence, epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, joshuaspence

Projects: #lint

Maniphest Tasks: T4954

Differential Revision: https://secure.phabricator.com/D14298
2015-10-21 09:46:20 -07:00
epriestley
e51e1c3d44 Allow Script-and-Regex linter to have optional/empty capturing patterns for char/line
Summary:
See discussion in D13737. If you're using this linter to match messages which //sometimes// have a character, you can get `""` (empty string) matches when the expression doesn't match. We'll complain about these later.

Instead, cast the matches the expected types.

Test Plan: @csilvers confirmed fix, see D13737.

Reviewers: chad, csilvers

Reviewed By: csilvers

Subscribers: spicyj, csilvers

Differential Revision: https://secure.phabricator.com/D14307
2015-10-19 14:35:14 -07:00
Aviv Eyal
6c7def560d Remove ArcanistWorkflow::setWorkingCopy
Summary: Fixes T9583. setWorkingCopy doesn't actually work, so eliminate it.

Test Plan: arc unit --everything

Reviewers: chad, epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin

Maniphest Tasks: T9583

Differential Revision: https://secure.phabricator.com/D14293
2015-10-16 09:53:01 -07:00
epriestley
172c930630 Pass author config to git with "-c x=y" instead of "--author"
Summary: See D14232. That didn't actually work. It looks like this does.

Test Plan:
  - Ran `git commit --author ...` on build server and saw the same failure.
  - Ran `git -c ... -c ... commit ...` on build server and saw it work.

Reviewers: chad

Reviewed By: chad

Differential Revision: https://secure.phabricator.com/D14233
2015-10-04 08:49:20 -07:00
epriestley
6966be3e7e Allow an arc test to execute without a git author configured
Summary:
On `sbuild`, we currently get a failure on this test. Use an explicit `--author` so we can run the test even if `user.email` and `user.name` are not set in global Git config.

```
   FAIL  ArcanistBundleTestCase::testGitRepository
15	EXCEPTION (CommandException): Command failed with error #128!
16	COMMAND
17	git commit -m 'Mark koan2 +x and edit it.'
18
19	STDOUT
20	(empty)
21
22	STDERR
23
24	*** Please tell me who you are.
25
26	Run
27
28	  git config --global user.email "you@example.com"
29	  git config --global user.name "Your Name"
30
31	to set your account's default identity.
32	Omit --global to set the identity only in this repository.
33
34	fatal: empty ident name (for <builder@sbuild001.phacility.net>) not allowed
```

Test Plan: Ran `arc unit --everything`. Will verify in production.

Reviewers: chad

Reviewed By: chad

Differential Revision: https://secure.phabricator.com/D14232
2015-10-04 08:41:48 -07:00
Vihang Mehta
1b4a3e0c5e Set path on more linters
Summary:
This is in a similar vein as D14220 and sets a name on linter
messages. This should handle issues from D14165.

Test Plan: Run as many of the changed linters as possible + existing linter tests.

Reviewers: chad, #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D14225
2015-10-02 08:58:15 -07:00
Vihang Mehta
f0c57986bc Fix ArcanistClosureLinter
Summary: Fixes T9498

Test Plan: Run `arc lint` with errors that get caught and reported by `ArcanistClosureLinter`

Reviewers: joshuaspence, epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin

Maniphest Tasks: T9498

Differential Revision: https://secure.phabricator.com/D14220
2015-10-02 05:45:48 -07:00
epriestley
d3abb65572 Add a --target flag to arc unit for uploading results
Summary: Ref T5821. Basic idea here is that Harbormaster can run `arc unit --everything --target ...` to get a build target updated.

Test Plan: Ran `arc unit --target ...`, saw web UI update with test results.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T5821

Differential Revision: https://secure.phabricator.com/D14190
2015-09-29 09:51:51 -07:00
epriestley
2df96ed405 Allow users to skip "arc:prompt" by entering no text
Summary:
Fixes T9476. Currently, if you enter no text in "arc:prompt", we abort resolution immediately.

However, this is a bit inconsistent (other rules that fail to resolve are skipped) it is reasonable to put some default rule behind "arc:prompt" so that you can just mash enter to select it. This construction is unusual, but seems fine and sensible to me.

If you're using "arc:prompt" as the last rule, the behavior is the same as before, so this should only make the rule more useful.

Test Plan:
  - Ran `arc which --base 'arc:prompt, git:HEAD^'` with and without the patch.
  - Without the patch, entering no text at "arc:prompt" failed immediately.
  - With the patch, entering no text caused fallback to the "git:HEAD^" rule.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T9476

Differential Revision: https://secure.phabricator.com/D14187
2015-09-29 07:09:19 -07:00
epriestley
e8a0ebaeff Improve validation of 'name' and 'code' parameters for lint messages
Summary: Ref T9145. Fixes T9316. We now require "name" and "code" has a maximum length (currently, this is 32, but the next diff will raise it to 128).

Test Plan:
  - Installed PHPCS.
  - Hit both the "name" and "code" issues.
  - Applied this patch.
  - Got better errors sooner.

Reviewers: chad

Reviewed By: chad

Subscribers: aik099

Maniphest Tasks: T9145, T9316

Differential Revision: https://secure.phabricator.com/D14165
2015-09-25 11:16:04 -07:00
epriestley
9c056c5cc8 Improve arc's handling of dirty submodules in Git
Summary:
Fixes T9455. Depends on D14136. When you have a dirty submodule:

  $ nano submodule/file.c # save changes

...we currently ask you to make a commit when you run `arc diff`, which is meaningless and misleading.

Instead, prompt the user separately.

This behavior isn't perfect but I think it's about the best we can do within reason.

Test Plan:
  - Ran `arc diff` in a working copy with uncommitted submodule changes only, got new prompt.
  - Ran `arc diff` in a working copy with submodule base commit changes only, got old (correct) prompt.
  - Ran `arc diff` in a working copy with both, got only old prompt (which is incomplete, but reasonable/meaningful).

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T9455

Differential Revision: https://secure.phabricator.com/D14137
2015-09-21 12:40:06 -07:00
epriestley
083127c4cc Fix an issue with "arc nrabch"
Summary:
Fixes a minor issue from D14034. PHP doesn't like `clone null;`, and if you type a nonsense command like `arc nbrhch` (as I frequently do) we try to `clone null` here.

Instead, just `return null;` if no workflow matches. Clone otherwise.

Test Plan:
  - Ran `arc nbrhcanc`
  - Ran `arc branch`

Reviewers: BYK, chad

Reviewed By: chad

Differential Revision: https://secure.phabricator.com/D14112
2015-09-15 11:14:07 -07:00
Burak Yigit Kaya
61fa644c4e Prevent caching of workflows
Summary: Fixes T9159.

Test Plan: Run `arc patch` on a code base requiring auth for a diff that has at least one dependency.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: avivey, thoughtpolice, joshuaspence, Korvin

Maniphest Tasks: T9159

Differential Revision: https://secure.phabricator.com/D14034
2015-09-15 05:24:01 -07:00
Aviv Eyal
501007f012 More linter's short description
Summary: Closes T9353. I think this makes all descriptions at least basically informative.

Test Plan: arc linters - I can now understand what each one is about.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin

Maniphest Tasks: T9353

Differential Revision: https://secure.phabricator.com/D14106
2015-09-14 11:52:24 -07:00
Aviv Eyal
28b89785fe update linter short desc
Summary: ref T9353.

Test Plan: arc linters

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: joshuaspence, Korvin

Maniphest Tasks: T9353

Differential Revision: https://secure.phabricator.com/D14085
2015-09-08 14:52:43 -07:00
Aviv Eyal
bdab422440 arc linters: switch name and short
Summary: I think they were wrong.

Test Plan: `arc linters nolint`. It would fail without it.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, #lint

Differential Revision: https://secure.phabricator.com/D14084
2015-09-08 10:39:26 -07:00
Aviv Eyal
8f3a002cdb Allow upgrading in branch stable
Summary: close T9043. This still allows for one dir to be in `master` and the other in `stable`, but hopefully that's not going to be a problem.

Test Plan: Clone arc/libph, checkout `stable`, run arc upgrade.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: cburroughs, epriestley

Maniphest Tasks: T9043

Differential Revision: https://secure.phabricator.com/D14076
2015-09-07 13:44:48 -07:00
epriestley
55d9cc7013 Improve temporary file upload API and add viewPolicy support
Summary: Ref T7148. In D14056, I let `arc upload` upload temporary files, but this is a better way to do some of the internals. Also add support for setting a `viewPolicy`.

Test Plan: Used `arc upload`, `arc upload --temporary`.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T7148

Differential Revision: https://secure.phabricator.com/D14075
2015-09-07 12:44:59 -07:00
epriestley
9896908685 Add temporary file support to ArcanistFileUploader
Summary: Ref T7148. Depends on D14055. Allows files to be marked as temporary when uploaded.

Test Plan: Used `arc upload --temporary` to upload temporary files.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T7148

Differential Revision: https://secure.phabricator.com/D14056
2015-09-04 10:34:14 -07:00
Alex Vandiver
7e677c27ec Fix callsites which called libphutil_console_wrap like it were _format
Summary:
7e2df9a attempted to pht() some strings; unfortunately, it assumed
that some things that were calls to phutil_console_wrap() were
actually calls to phutil_console_format().  This produces errors of
the form:

    [2015-07-17 21:17:28] ERROR 2: str_repeat() expects parameter 2 to be long, string given at [/usr/local/libphutil/src/console/format.php:162]
    #0 str_repeat(string, string) called at [<phutil>/src/console/format.php:162]
    #1 phutil_console_wrap(string, string, string) called at [<arcanist>/scripts/arcanist.php:620]
    #2 arcanist_load_libraries(array, boolean, string, ArcanistWorkingCopyIdentity) called at [<arcanist>/scripts/arcanist.php:154]
    %s: %s

Provide an additional call to phutil_console_format() when necessary,
or simply append the relevant characters if possible.

Test Plan: Caused a library load error

Reviewers: #blessed_reviewers, epriestley

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D14053
2015-09-03 12:01:01 -07:00
cburroughs
029e5a7c29 staging repo compatibility for older git versions
Summary:
The `--no-verify` flag was not added until git 1.8.2.  This
flag is used to avoid running local pre-push hooks.  This is likely a
rare configuration and is safe to omit the flag on older versions.
Users with local pre-push hooks **and** older git version may need to
adjust their workfow.

fixes T9310

Test Plan:
 * Ran `arc diff` with my real git 1.7.10.4 and succeeded with `STAGING
   PUSHED`.
 * Edited `getGitVersion` to be > 1.8.2 and pushed again.  Got
   `STAGING FAILED` because `error: unknown option`.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: joshuaspence, epriestley

Maniphest Tasks: T9310

Differential Revision: https://secure.phabricator.com/D14033
2015-09-02 06:58:42 -07:00
Joshua Spence
9419cccdd2 Delete another problematic XML test file
Summary: Ref T7215. This test is occasionally failing for me locally. Remove it as per D13992.

Test Plan: `arc unit`

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin

Maniphest Tasks: T7215

Differential Revision: https://secure.phabricator.com/D14027
2015-09-02 18:34:55 +10:00
Mike Riley
de7a999ce9 Remove errant in arcanist.php
Summary: This causes `49` to be printed out preceding the start of my next terminal line every time there is an exception thrown.

Test Plan: did not see `49` printed out when exceptions were thrown

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley

Differential Revision: https://secure.phabricator.com/D14030
2015-09-01 08:46:17 -07:00
Joshua Spence
6fa2de5ff8 Add a linter rule for detecting empty files
Summary: Adds two different linter rules (one general purpose and another PHP specific) to prevent empty files from being added to a repository. For some unknown reason, people seem to like to do this.

Test Plan: Added test cases.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: avivey, cburroughs, Korvin

Differential Revision: https://secure.phabricator.com/D13881
2015-09-01 19:30:55 +10:00
Joshua Spence
a5304e472d Add a linter rule for newlines after PHP open tags
Summary: `<?php\n\n...` is much easier to read than `<?php\n...`. Depends on D13889 and D13890.

Test Plan: Added unit tests.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D13534
2015-08-31 06:49:29 +10:00
Joshua Spence
10f9c460fa Remove leftover code for "postponed" lint and unit status
Summary: Ref T9134. It looks like this functionality was removed in D13848. Depends on D13869.

Test Plan: Ran `arc diff`, `arc lint` and `arc unit`.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin

Maniphest Tasks: T9134

Differential Revision: https://secure.phabricator.com/D13868
2015-08-30 21:56:12 +10:00
Aviv Eyal
1ed98937c4 arc linters: Filter by name, make display one-line
Summary: allow searching/filtering linters displayed by name.

Test Plan:
`$ arc linters --verbose --search JSon --search ruby` (Lots of text about many linters)
`$ arc linters --search JSon ruby` (error message)
`$ arc linters python` (no results, "try --search").
`$ arc linters ruby` (Verbose text about the "ruby" linter).

Reviewers: joshuaspence, #blessed_reviewers, epriestley

Reviewed By: joshuaspence, #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D10706
2015-08-29 05:10:03 -07:00
Joshua Spence
18e32d6ec7 Fix linter rule after XHPAST change
Summary: Depends on D13959.

Test Plan: Ran unit tests.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D13961
2015-08-27 22:08:49 +10:00
Javier Arteaga
c22dfe61ed Use 'remote.origin.url' fallback for git < 1.7.5
Summary:
'git ls-remote --get-url' is more correct, but younger and less
supported. This commit tempers previous optimism about its availability,
improving support for users of older git packages.

Test Plan:
* Set `git config url.xttps.insteadOf https` rewrite rule.
* Ran `arc which` with git 1.7.5 in `$PATH`, saw rewritten configured remote.
* Ran `arc which` with git 1.7.4 in `$PATH`, saw configured remote.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D13998
2015-08-26 15:59:03 -07:00
Javier Arteaga
4c3d75401f Use 'git blame --porcelain' for git blame info
Summary:
This guards against stability issues with the output format of 'git
blame' (such as git config, localization (ref T5554) or future changes).

For example, `git config blame.blankboundary true` breaks `arc cover`
before this patch.

Test Plan:
* Set `git config blame.blankboundary true` on a test repo.
* Ran `arc cover`. It failed with an exception ("Bad blame?").
* Applied this patch.
* `arc cover` works.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin

Maniphest Tasks: T5554

Differential Revision: https://secure.phabricator.com/D13993
2015-08-25 09:36:16 -07:00
epriestley
43f8e7eb71 Recover from PyLint raising messages at character "-1"
Summary: Fixes T9257. For some messages, PyLint can raise at "character -1", which we don't allow since we don't consider it to make sense.

Test Plan:
  - Added failing unit test from T9257.
  - Applied patch.
  - Test now passes.

Reviewers: joshuaspence, chad

Reviewed By: joshuaspence, chad

Maniphest Tasks: T9257

Differential Revision: https://secure.phabricator.com/D13991
2015-08-24 21:11:54 -07:00
epriestley
1d3266395f Remove two problematic XML linter unit tests
Summary:
Fixes T7215. See D13991. These test cases have been failing intermittently for a while.

I think the XML stuff (which we don't control) changed where it raises these warnings: an old version raised them at the end of the attribute, while the new version raises them at the beginning of the attribute. Not totally 100% sure about this since installing multiple versions is fairly inconvenient, but as far as I know both versions raise the warnings, just at different character offsets.

We could do various things to fix these tests (allow the warning to raise at any character, skip the tests based on versions, etc) but I think it's easier to just remove the tests. They don't seem valuable.

Test Plan: Tests failed prior to change; now pass.

Reviewers: chad, joshuaspence

Reviewed By: joshuaspence

Maniphest Tasks: T7215

Differential Revision: https://secure.phabricator.com/D13992
2015-08-24 21:07:28 -07:00
Javier Arteaga
46009145f7 Minimize reliance on 'git branch' output format
Summary:
Ref T5554. Both the current branch name (if on a branch), as well as the
list of all local branches, can be retrieved without having to parse the
output from "git branch".

Unfortunately, there seems to be no git plumbing for "get list of
branches containing this commit" yet.
(see http://marc.info/?l=git&m=141408477614635&w=2)

For that case, this commit whitelists the output from "git branch" using
the known valid branch names from "git for-each-ref".

Test Plan:
Set up a test repo with this structure:
```
|   *  Commit B1, on branch "subfeature"
|  /
| *    Commit A1, on branch "feature"
|/
*      Commit M1, on branch "master"
|
```

In `subfeature`, I tried:
* `arc which --base 'git:branch-unique(master)'`
* `arc feature`
After that, I detached my HEAD (don't worry, I got better) and tried again.

Nothing looked broken.

(Tested with git 1.7.2.5 and 2.5.0.)

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin

Maniphest Tasks: T5554

Differential Revision: https://secure.phabricator.com/D13989
2015-08-24 17:57:41 -07:00
Javier Arteaga
6ecb3fb87d Avoid parsing git "remote show" using "ls-remote"
Summary:
Ref T5554. This makes git remote URL detection locale-agnostic.

The previously suggested `git config remote.origin.url` command does
almost the same, but does not support the URL rewriting features in
git-config (`url.<base>.insteadOf`).

This one does, although it has the unintuitive behavior of just printing
the passed remote name when the remote does not exist, or even when
called outside a git repo.

Test Plan:
* Switched to non-english locale in which git has a translation.
* Ran `arc which` on the Arcanist repo. It could not determine the remote URI.
* Applied patch, `arc which` found the URI.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: johnny-bit, Korvin

Maniphest Tasks: T5554

Differential Revision: https://secure.phabricator.com/D13983
2015-08-24 04:51:03 -07:00
Joshua Spence
9b8c9d280e Exclude variables used in strings inside closures when checking for undeclared variables
Summary:
Improves upon D13795 to correctly handle variables within strings. Specifically, the  following code currently (incorrectly) warns about `$x` being undeclared:

```lang=php
function some_func() {
  return function ($x) {
    echo "$x";
  };
}
```

It's worth noting that the situation would be improved if XHPAST properly parsed strings (see T8049).

Test Plan: Added test case.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D13938
2015-08-21 07:26:52 +10:00
Joshua Spence
e56f326cf7 Add a call to assert_instances_of
Summary: This was taken from D13569.

Test Plan: `arc lint` still works.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D13943
2015-08-20 22:45:31 +10:00
Javier Arteaga
f47d15387b Fix wrong plural of an arc land message
Summary:
"Branch" was pluralized as "branchs".

Fixes T9225.

Test Plan:
* Created test repo with two revisions on a feature branch.
* Saw old message, frowned a little.
* Applied patch.
* No longer frowning.

Reviewers: chad, epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: avivey, Korvin

Maniphest Tasks: T9225

Differential Revision: https://secure.phabricator.com/D13944
2015-08-20 04:19:22 -07:00
ealbright
05aaa1a5a3 ArcanistPyLintLinter fix to getMandatoryFlags msg-template
Summary: Removed excess quotations on the `--msg-template` option as it was interfering with the string-int coercion

Test Plan: Unsure

Reviewers: joshuaspence, epriestley, #blessed_reviewers

Reviewed By: joshuaspence, epriestley, #blessed_reviewers

Subscribers: joshuaspence, e-m-albright, Korvin

Maniphest Tasks: T9214

Differential Revision: https://secure.phabricator.com/D13931
2015-08-19 05:46:04 -07:00
Joshua Spence
f9bd6b058f Add a Composer linter
Summary: Adds a basic linter for ensuring that `composer.lock` files are up-to-date.

Test Plan: We have been using this in a private project for around a month.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: johnny-bit, Korvin

Differential Revision: https://secure.phabricator.com/D13883
2015-08-19 21:39:11 +10:00
Joshua Spence
27ec3a2e34 Improve linter handling of short array syntax
Summary: Currently, linting PHP short array syntax (i.e. `[...]`) throws an exception ("Expected open parentheses"). This diff relaxes some restrictions which prevent short array syntax from linting with `ArcanistParenthesesSpacingXHPASTLinterRule`.

Test Plan: Modified test cases.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: agenticarus, Korvin

Differential Revision: https://secure.phabricator.com/D13895
2015-08-19 15:35:16 +10:00