Skip to content
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

[SR-3802] [SwiftPM] Xcode gets confused by SwiftPM's edit mode, which in turns confuses SwiftPM #5121

Closed
swift-ci opened this issue Jan 31, 2017 · 4 comments
Labels

Comments

@swift-ci
Copy link
Contributor

Previous ID SR-3802
Radar None
Original Reporter Dave (JIRA User)
Type Bug
Status Resolved
Resolution Invalid
Environment

macOS 10.11.6
$ swift --version
Apple Swift version 3.1-dev (LLVM 2475cd4a8a, Clang bbab01d581, Swift bf16b699c5)
Target: x86_64-apple-macosx10.9

Additional Detail from JIRA
Votes 0
Component/s Package Manager
Labels Bug
Assignee None
Priority Medium

md5: 2939d609dca274083394a13185a3403d

Issue Description:

The result is that Xcode thinks the dependency in edit mode belongs to two repositories, and SwiftPM won't let me "unedit" the dependency because of "hasUnpushedChanges". Well, all the changes are committed, and this is all local so there's nothing to push to.

Here are the steps:

  1. create library package A and a .xcodeproj file, commit everything, tag it as 0.1.0
  2. create executable package B
  3. set A as a dependency
  4. create .xcodeproj file for B
  5. in the terminal, run "swift package edit A --branch 0.2.0", update package B and regen the .xcodeproj file
  6. in Xcode, make some change B's copy of A and commit them to the 0.2.0 branch
  7. in Xcode, in A, make and commit some change, then tag it as 0.3.0
  8. in the terminal, run "swift package unedit A"
    At which point SwiftPM complains about unpushed changes that, as far as I can tell, don't actually exist.
@rballard
Copy link
Contributor

From your steps here, in step 6 you commit a change to B's copy of A, but you don't push that change anywhere. So isn't it correct that it has unpushed changes?

I'm a little confused as to what you're saying that Xcode has to do with this, as well.

@swift-ci
Copy link
Contributor Author

Comment by David Sweeris (JIRA)

Maybe? I was under the impression that pushing was only involved with remote repositories, and these are all local. I tried telling git to push them, it said, "fatal: The current branch 0.2.0 has no upstream branch.". I took that to mean that there wasn't anywhere to push them to, which, unless I'm misunderstanding something, makes complaining about it kind of a moot point. Is that not the case? I'll have to laugh/SMH at myself a bit if this is just me not having a firm enough grasp on how git works.

Re: Xcode
My mistake. I'd been using Xcode to do edits and commits, and neglected to try to reproduce the issue without involving it. I just tried it again and I get the same behavior doing everything from the command line. So... turns out the Xcode doesn't have anything to do with the matter (nor does step 7).

@rballard
Copy link
Contributor

I believe the point of this error is to keep you from accidentally discarding changes. If you commit a change in your edited package and then don't actually push those changes to a remote repository, your committed changes only live in your local edited repo. If you then unedit, those committed changes will be lost, which likely isn't what you want. So we display this error to prevent you from accidentally blowing away those changes. If you really do want to lose your changes, you can pass the --force option.

Because 0.2.0 is a branch that you created locally, it doesn't know which branch in the remote to track, so you need to set a remote tracking branch before you can push. You can read about how this works at https://git-scm.com/book/en/v2/Git-Branching-Remote-Branches.

@ankitspd
Copy link
Member

You can push to local repos:

sp = swift package

$ sp edit bar --branch bugfix
$ cd Packages/bar
$ git status
On branch bugfix
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

    modified:   Sources/bar.swift
$ git add .
$ git commit -m "test"
[bugfix a21c919] test
 1 file changed, 1 deletion(-)
$ git remote --v
origin  /private/tmp/BigPackage/bar (fetch)
origin  /private/tmp/BigPackage/bar (push)
$ git push origin bugfix
Counting objects: 4, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (4/4), 347 bytes | 0 bytes/s, done.
Total 4 (delta 1), reused 0 (delta 0)
To /private/tmp/BigPackage/bar
 * [new branch]      bugfix -> bugfix

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 4, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants