Commit Graph

65 Commits

Author SHA1 Message Date
9350beb544 Upgrade: remove leftover ref
The upgrade process leaves a left over ref:

```
$ git branch
..
  _upgrade_HEAD
..
```

This commit deletes that.

Signed-off-by: Rudi Grinberg <me@rgrinberg.com>
2020-12-01 15:06:15 -08:00
be923535fa upgrade.el: force fetch
`doom-cli-upgrade` calls `git fetch` to fetch remote branch and tags and
check output code of this command to complain when it failed.

It fails when remote server isn't available that is good.

But it also fails when it can't to fast-forward a branch that will be
used to upgrade doom-emacs.

The last case created a loop and the only way to broke this loop is
remote a branch that should be used for upgrade.

Unfortunately user has no idea about branch name and can't do anything,
just enjoy crash with `Failed to fetch from upstream` message.

This commit added `--force` flag to `git fetch` that forces it to
overwrite branch that is used to upgrade that prevent such loop.

It also fixed https://github.com/hlissner/doom-emacs/issues/4346
2020-12-01 21:19:48 +01:00
12b733b33e Unhardcode upstream repo in diff url
Use `doom-repo-url` in diff url to show diff.

Signed-off-by: Rudi Grinberg <me@rgrinberg.com>
2020-11-29 17:46:40 -08:00
bf50149ee3 Fix doom upgrade
Previously, `doom upgrade` would emit:

```
New revision: fatal: amb (fatal: ambiguous argument '_upgrade/HEAD': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
```

It appears it's not possible to remote revisions with
`<remote>/<revision>`. Instead, we fetch the upgrade remote into a named
revision and then use it.

Signed-off-by: Rudi Grinberg <me@rgrinberg.com>
2020-11-29 15:54:26 -08:00
4d24d7548a Print diff url in terminal in case emacs is in a remote server (#4105)
* Print diff url in terminal in case emacs is in a remote server

Closes #2936

* Correct print! call

Co-authored-by: Henrik Lissner <henrik@lissner.net>
2020-10-18 19:17:39 -04:00
e4864adfbe Update 'doom help upgrade' doctring 2020-10-05 17:21:17 -04:00
c7588bacdf cli/upgrade: don't reload if Doom's up-to-date 2020-08-26 15:11:47 -04:00
0dfee56e35 Fix string type error on 'doom upgrade' 2020-08-24 23:22:57 -04:00
e632871a11 core-cli: backport more refactors from rewrite
Still a long way to go, but this introduces a few niceties for
debugging CLI failures:

+ The (extended) output of the last bin/doom command is now logged to
  ~/.emacs.d/.local/doom.log
+ If an error occurs, short backtraces are displayed whether or not you
  have debug mode on. The full backtrace is written to
  ~/.emacs.d/.local/doom.error.log.
+ bin/doom now aborts with a warning if:
  - The script itself or its parent directory is a symlink. It's fine if
    ~/.emacs.d is symlinked though.
  - Running bin/doom as root when your DOOMDIR isn't in /root/.
  - If you're sporting Emacs 26.1 (now handled in the elisp side rather
    than the /bin/sh shebang preamble).
+ If a 'doom sync' was aborted prematurely, you'll be warned that Doom
  was left in an inconsistent state and that you must run `doom sync`
  again.

May address #3746
2020-08-24 23:00:32 -04:00
da1030985d Minor refactors & reformatting 2020-07-23 01:26:03 -04:00
aec94f5bb2 Fix #3228: 'Failed to fetch from upstream' on doom upgrade
Due to git name-rev returning fully qualified refs in some cases.
2020-05-29 19:36:13 -04:00
b6cc110f4c Fix 'wrong-type-arg' error on 'doom upgrade' 2020-05-26 03:12:35 -04:00
894966b1e2 Fix #3221: incorrect usage of doom-cli-execute
The function is variadic in as-of-yet published versions of Doom's CLI;
this usage snuck into a commit.
2020-05-26 02:55:24 -04:00
a814239ec7 Implement daisy-chaining for CLI sessions
elisp lacks an execv implementation (or mature subprocess library), so
we exploit some splenderiffic hackery to get Emacs to execute arbitrary
shell commands after a 'doom ...' command completes. This allows us to
daisy chain doom commands in distinct sessions (wonderful for reloading
doom after a 'doom upgrade', which we do). This minimizes errors when a
'doom upgrade' pulls in breaking changes to Doom's CLI.

We also bring 'doom run' into elisp, since this new functionality
enables us to.
2020-05-26 02:30:54 -04:00
e89b604f5f Fix 'doom upgrade' when doom is a git submodule 2020-05-26 02:13:02 -04:00
9f024e549f Instruct user to rerun 'doom upgrade'
If it fails during reloading of Doom's core.

Relevant to #3131
2020-05-25 16:27:51 -04:00
e6c88e4384 Refactor autoloads generator & reduce to one generated file
We no longer need two separate autoloads files, so I merged them and
optimized its generation logic.

Other changes
- Doom will refuse to start up (with a helpful error) if it's in an
  incomplete state. This should hopefully reduce the number of bug
  reports from folks that have done something weird, e.g.
  1. You've changed Emacs versions without running 'doom sync -b'.
  2. You've updated Doom outside of `doom upgrade` and didn't run `doom
     sync -u`.
  3. You've forgotten to run 'doom sync' in the first place!
  4. If a previous 'doom ...' command was aborted midway without running
     'doom sync' afterwards.
- 'doom sync' will emit reminders that you need to reload/restart Emacs
- Autoloads API now uses the `doom-autoloads-` prefix, intead of
  'doom-cli-autoloads-', as will be the new convention in the coming
  rewrite.
- Errors from within the package autoloads should be easier to invoke
  the debugger on.
- `doom-modules` is now stored in your autoloads file. Your module list
  will soon be frozen between calls to 'doom sync' to allow for our new,
  atomic CLI I'm working on. This will also means the `doom!` block
  won't cost anything in interactive sessions.
2020-05-25 15:55:29 -04:00
204783a96e Change how doom core reloads itself after 'doom upgrade'
Hopefully to address weird void-function errors while upgrading.
2020-05-19 21:49:01 -04:00
643377d8a4 Fix void-function doom--straight-respect-print-indent-a error
On first use of 'doom upgrade'
2020-05-18 03:27:30 -04:00
375faedb1b Emit backtrace if doom upgrade fails 2020-05-16 05:38:20 -04:00
49790fb53f Include the error when 'doom upgrade' fails 2020-05-16 05:31:33 -04:00
0e851ace9b Backport bits of CLI rewrite
The rewrite for Doom's CLI is taking a while, so I've backported a few
important changes in order to ease the transition and fix a couple bugs
sooner.

Fixes #2802, #2737, #2386

The big highlights are:

- Fix #2802: We now update recipe repos *before* updating/installing any
  new packages. No more "Could not find package X in recipe repositories".

- Fix #2737: An edge case where straight couldn't reach a pinned
  commit (particularly with agda).

- Doom is now smarter about what option it recommends when straight
  prompts you to make a choice.

- Introduces a new init path for Doom. The old way:
  - Launch in "minimal" CLI mode in non-interactive sessions
  - Launch a "full" interactive mode otherwise.
  The new way
  - Launch in "minimal" CLI mode *only* for bin/doom
  - Launch is a simple mode for non-interactive sessions that still need
    access to your interactive config (like async org export/babel).
  - Launch a "full" interactive mode otherwise.

  This should fix compatibility issues with plugins that use the
  async.el library or spawn child Emacs processes to fake
  parallelization (like org's async export and babel functionality).

- Your private init.el is now loaded more reliably when running any
  bin/doom command. This gives you an opportunity to configure its
  settings.

- Added doom-first-{input,buffer,file}-hook hooks, which we use to queue
  deferred activation of a number of packages. Users can remove these
  modes from these hooks; altogether preventing them from loading,
  rather than waiting for them to load to then disable them,
  e.g. (after! smartparens (smartparens-global-mode -1)) -> (remove-hook
  'doom-first-buffer #'smartparens-global-mode)

  Hooks added to doom-first-*-hook variables will be removed once they
  run.

  This should also indirectly fix #2386, by preventing interactive modes
  from running in non-interactive session.

- Added `doom/bump-*` commands to make bumping modules and packages
  easier, and `doom/bumpify-*` commands for converting package!
  statements into user/repo@sha1hash format for bump commits.

- straight.el is now commit-pinned, like all other packages. We also
  more reliably install straight.el by cloning it ourselves, rather than
  relying on its bootstrap.el.

  This should prevent infinite "straight has diverged from master"
  prompts whenever we change branches (though, you might have to put up
  with it one more after this update -- see #2937 for workaround).

All the other minor changes:

- Moved core/autoload/cli.el to core/autoload/process.el
- The package manager will log attempts to check out pinned commits
- If package state is incomplete while rebuilding packages, emit a
  simpler error message instead of an obscure one!
- Added -u switch to 'doom sync' to make it run 'doom update' afterwards
- Added -p switch to 'doom sync' to make it run 'doom purge' afterwards
- Replace doom-modules function with doom-modules-list
- The `with-plist!` macro was removed, since `cl-destructuring-bind`
  already serves that purpose well enough.
- core/autoload/packages.el was moved into core-packages.el
- bin/doom will no longer die if DOOMDIR or DOOMLOCALDIR don't have a
  trailing slash
- Introduces doom-debug-variables; a list of variables to toggle on
  doom/toggle-debug-mode.
- The sandbox has been updated to reflect the above changes, also:
  1. Child instances will no longer inherit the process environment of
     the host instance,
  2. It will no longer produce an auto-save-list directory in ~/.emacs.d
2020-05-15 01:33:52 -04:00
8a7763337d doom refresh -> doom sync
refresh isn't going anywhere, but sync will be the canonical command
here on out, because it is more appropriate for kind of work it will be
doing in the future.
2020-02-19 23:34:16 -05:00
99fc55f75c General, minor refactors in doom core 2020-01-27 00:51:32 -05:00
a2354a7ad7 Add -p/--packages to 'doom upgrade'
And document -f/--force
2020-01-26 05:00:57 -05:00
4f676bd218 Refactor autoload generator bootstrappers 2020-01-01 13:31:40 -05:00
a5fc782e76 cli/upgrade: fix wrong-type-arg string force file error #2277
Due to a vestigial call to the old doom-cli-reload-package-autoloads
2019-12-31 03:38:47 -05:00
7e0c093bcf cli/upgrade: fix dirty worktree detection 2019-12-13 14:53:52 -05:00
153fbbc466 cli/upgrade: print git fetch log on successful upgrade 2019-12-02 20:22:01 -05:00
a0d94e0db7 cli/upgrade: fix -y/--yes for 'doom upgrade'
Otherwise, 'doom upgrade' throws 'Unrecognized switch "-y"' error after
updating Doom.
2019-12-02 20:22:00 -05:00
570894e1c8 cli/upgrade: 'doom refresh' after upgrading, before updating
Fixes an issue where uninitialized packages aren't installed when 'doom
update' tries to update them.
2019-11-24 19:38:49 -05:00
d474223a99 cli/upgrade: don't use removed -f switch 2019-11-16 21:04:08 -05:00
c297d091bd Fix void-function doom-initialize-packages on 'doom upgrade' 2019-11-10 23:43:05 -05:00
8d112fdca8 Prevent void-variable errors on 'doom upgrade'
If Doom is up-to-date, certain Doom package state doesn't get
initialized for the 'doom update' that occurs directly after, causing
these errors.
2019-11-10 20:15:25 -05:00
4ceb09c219 cli/upgrade: don't double-update packages
And don't initialize too much of Doom before updating it.
2019-11-10 16:44:53 -05:00
a55b5a4514 Fix void-function doom-sh error in 'doom upgrade' #2034 2019-11-09 11:06:06 -05:00
873fc5c0db Rewrite core-cli
Highlights:
- 'doom purge' now purges builds, elpa packages, and repos by default.
  Regrafting repos is now opt-in with the -g/--regraft switches.
  Negation flags have been added for elpa/repos: -e/--no-elpa and
  -r/--no-repos.
- Removed 'doom rebuild' (it is now just 'doom build' or 'doom b').
- Removed 'doom build's -f flag, this is now the default. Added the -r
  flag instead, which only builds packages that need rebuilding.
- 'doom update' now updates packages synchronously, but produces more
  informative output about the updating process.
- Straight can now prompt in batch mode, which resolves a lot of issues
  with 'doom update' (and 'doom upgrade') freezing indefinitely or
  throwing repo branch errors.
- 'bin/doom's switches are now positional. Switches aimed at `bin/doom`
  must precede any subcommands. e.g.
    Do: 'doom -yd upgrade'
    Don't do: 'doom upgrade -yd'
- Moved 'doom doctor' from bin/doom-doctor to core/cli/doctor, and
  integrated core/doctor.el into it, as to avoid naming conflicts
  between it and Emacs doctor.
- The defcli! macro now has a special syntax for declaring flags, their
  arguments and descriptions.

Addresses #1981, #1925, #1816, #1721, #1322
2019-11-08 16:02:06 -05:00
686e020287 cli: add documentation string about new flags 2019-09-22 14:34:40 -07:00
85ea924595 cli: fix wrong argument being sent to doom-upgrade
In 84837fa0d, a new argument was added before the timeout arg which
broken this flag.
2019-09-22 14:34:22 -07:00
5caa6add5c Make 'doom upgrade' respect -y/--yes switches 2019-09-12 17:25:54 -04:00
9f08d11908 Also delete autoloads.pkgs.el on 'doom upgrade' 2019-09-05 14:06:52 -04:00
c55676d221 cli/upgrade: add timeout flag
Since there is a lot of logic in `bin/doom upgrade` than just running
two commands, I thought we should also add a timeout flag just like
`update` has.
2019-08-29 17:03:42 -07:00
9d0966e94a Forcibly refresh doom after 'doom upgrade'
Ensures autoloads files are regenerated.
2019-08-23 01:56:43 -04:00
f42bfde8ae Fix #1648: doom upgrade not updating packages
...when Doom itself is up-to-date.
2019-08-07 20:55:56 -04:00
c32244ad4e Generalize doom-sh
And slightly reformat 'doom upgrade' "you have updates" message.
2019-07-29 20:57:20 +02:00
2b81233353 Clean up _upgrade rmeote after 'doom upgrade' 2019-07-29 03:47:56 +02:00
8a16513107 Fix various errors in 'doom upgrade' 2019-07-29 03:34:35 +02:00
2304d69898 Fix wrong-type-arg number during 'doom upgrade' 2019-07-29 03:21:55 +02:00
c28fff4fbf Fix void-variable branch error on 'doom upgrade' 2019-07-29 03:18:39 +02:00
a9c1986a68 Fix and refactor 'doom upgrade' #1607
Now accepts the -f/--force switches to discard local changes to
the .emacs.d directory.
2019-07-28 13:47:57 +02:00