-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add archive options #3244
base: master
Are you sure you want to change the base?
Add archive options #3244
Conversation
b9e3dc5
to
da35ada
Compare
This looks useful, thanks for the contribution! I have a lot of thoughts about this (mostly about the UX), but I need more time, and I don't have very much these days. Please bear with me if it takes a bit longer this time, I do plan to have a closer look and give feedback. |
da35ada
to
22b985f
Compare
No worries! I appreciate you taking the time to check this out and look forward to hearing your feedback. I'll try to keep this branch up to date w/ master in the meantime if that helps. Thanks! |
22b985f
to
700f1ab
Compare
Nothing urgent here, just thought I would write down a couple of things on this one before I forget them. For bundling:
|
81b1f54
to
3561654
Compare
ced9d7d
to
c32a4c2
Compare
A few thoughts; these are not strong opinions, just input for discussion.
All in all I have the feeling that "archive" is straightforward enough that we can just add it, but "bundle" has enough questions to it that it would be good to do more of a requirements analysis first. Maybe it would be best to start with a description of what use cases or workflows you want to support with the feature. |
Thanks for taking the time to give this a look! I really appreciate your feedback.
I agree with this. I think my use case for the two may have a little overlap -- I pick one of these when I need to get my source to another machine that I can't ssh to, or if I need to get a copy of the source to someone else who can't clone from where the repo lives. I have to touch several different GitLab instances for work, and not everyone can get access to all of them. I pick a bundle if I can, but will use an archive if I know a bundle is going to confuse the person I'm trying to get the source to. I do agree that they're sufficiently different that they should be two different menu options. I think I put them together because I didn't want to use two different keyboard shortcuts. Maybe
I did want to include this option to reduce the risk of dumping a ton of files in an unintended directory. If a prefix is supplied first, it saves the possibility of having to do clean-up after. I tend to always make a
I totally agree. I can appreciate that use case, but unfortunately I almost always run into the situation where I need to transfer the repo and all its history to someone or some machine. I am very much in favor of adding the option to make a thin bundle where it's appropriate. I definitely have more learning to do about bundles. I'll try to make some time for that, and put together some notes so we can have a better conversation about them/their inclusion.
You're right, we should also consider what it would take to fetch from a bundle. I'm not sure if I would hold up the bundle creation feature until the bundle fetch feature is done, but I wouldn't be opposed to it, either. As I understand it, to fetch from a bundle we'd need to:
The first and second point don't seem too bad, but I think I don't think you can push to a bundle, so we'd either need to disable that option if the remote is a bundle or throw an error if the user tries to do it. We'd also need to handle if the user deleted the bundle but still has it added as a remote. I think most of that logic is there already, but we'd want to spot check to make sure it applies for bundles, too.
Yes the differences between archiving and bundling became more apparent as I was writing this, and I agree at this point that What do you think about me removing the bundle portions of this PR? Then we can finish up the archive pieces separately, and I can make either a draft PR or an issue where we can discuss bundling a little more. |
Sounds good to me.
I see. I didn't find this necessary because I usually unpack zip or even tar.gz files by double-clicking them, and both MacOS and Windows will take care of adding an enclosing folder (named after the archive file name) when unpacking when there isn't a single top-level folder in the archive. But I realize that users on the command line don't have this convenience, and I do remember being bitten by it once, so I'm fine with it. However, I still like streamlined user interfaces, so we could also consider having just a prompt for the archive name and then using that for the prefix as well, unconditionally. What do you think about that?
Thinking about this more, I think we should have separate options for creating thick and thin bundles. If
Ah, you can add a bundle as a remote? I wasn't aware of that, that's cool. Yes, we'll want to prevent pushing to it, but it would probably just give an error if users try, so this might just be good enough.
Sounds very good to me. |
c32a4c2
to
b4a9fe1
Compare
b4a9fe1
to
26a2930
Compare
@stefanhaller I think I have this in a state I'm comfortable with.
Let me know if I missed anything. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice. A few comments inline below, most of them minor.
Apart from that, two things:
- it's possible to leave the name empty, resulting in a file
.zip
being created; we should probably disallow that? - if the target file already exists, it is overwritten without warning. I find this a little drastic, I think we should check for that and add an additional prompt in this case.
} | ||
|
||
func (self *ArchiveCommands) Archive(refName string, archiveName string, prefix string) error { | ||
cmdArgs := NewGitCmd("archive").ArgIf(prefix != "", "--prefix", prefix).Arg("-o", archiveName, refName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of the time we format commands so that each argument is on a separate line, so I'd format this something like:
cmdArgs := NewGitCmd("archive").
ArgIf(prefix != "", "--prefix", prefix).
Arg("-o", archiveName).
Arg(refName)
|
||
validExtensions, err := self.cmd.New(cmdArgs).DontLog().RunWithOutput() | ||
if err != nil { | ||
return []string{""}, err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense to return a list with a single empty string in the error case? I'd just say return nil, err
.
@@ -403,6 +403,7 @@ type KeybindingBranchesConfig struct { | |||
SetUpstream string `yaml:"setUpstream"` | |||
FetchRemote string `yaml:"fetchRemote"` | |||
SortOrder string `yaml:"sortOrder"` | |||
Archive string `yaml:"archive"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could consider putting it in Universal
instead; it's "almost" universal (and we might consider offering it in the subcommits view too). I find it very unlikely that users will want to map it to different keys for branches and commits.
} | ||
|
||
func (self *ArchiveHelper) runArchiveCommand(refName string, fileName string, prefix string, suffix string) error { | ||
return self.c.WithWaitingStatus(self.c.Tr.ArchiveWaitingStatusMessage, func(gocui.Task) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to show an inline status like we do for pulling and pushing. (And this will have the additional advantage that pulling/pushing will automatically be disabled while an archive is being created.)
|
||
func (self *ArchiveHelper) runArchiveCommand(refName string, fileName string, prefix string, suffix string) error { | ||
return self.c.WithWaitingStatus(self.c.Tr.ArchiveWaitingStatusMessage, func(gocui.Task) error { | ||
return self.c.Git().Archive.Archive(refName, fileName+suffix, prefix) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor thing: Archive.Archive
reads a bit funny. I wonder if the function should be renamed to Create
.
func (self *ArchiveCommands) Archive(refName string, archiveName string, prefix string) error { | ||
cmdArgs := NewGitCmd("archive").ArgIf(prefix != "", "--prefix", prefix).Arg("-o", archiveName, refName) | ||
|
||
return self.cmd.New(cmdArgs.ToArgv()).DontLog().Run() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why DontLog()
? I think it's nice to see the command in the log.
And call LogAction
before, but probably not from here, but from the controller (or helper), I'm too lazy to look up how we usually do this.
feat: generate archive format menu from git output If someone has added a custom format via "git config --global tar.tar.bz2.command bzip2" or similar, that custom format will be selectable in the archive formats menu. feat: add i18n strings, assign keybindings test: add archive branch, tag, and commit tests
26a2930
to
e6d4f3d
Compare
Sometimes it's useful for me to create an archive or a bundle of the repository I'm working on. This PR adds menu options for creating an archive (branch, tag, commit) or a bundle (branch or tag).
go generate ./...
)docs/Config.md
) have been updated if necessary