-
Notifications
You must be signed in to change notification settings - Fork 13
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
Added state upgrade
#3467
Merged
Merged
Added state upgrade
#3467
Changes from 14 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
e1443fb
Update changeset structure to allow iterating through all changes in …
Naatan 1837326
Expose org namespace prefix
Naatan fa46b66
Added buildscript.Clone()
Naatan e60d55e
Added ability to ignore certain deps
Naatan d71eedc
Added shortcuts for accessing revision and license info from artifact
Naatan fc2c654
Added slice comparison function that doesn't depend on ordering
Naatan 6d38a4d
Added BOLD colorize tag
Naatan 1514bde
Added output.Structured()
Naatan a6b056e
Centralized tree symbols
Naatan c755cc5
Added `state upgrade`
Naatan dfac51e
Make time expansion reusable between commands
Naatan 14216bb
Add `--ts` flag to `state upgrade`
Naatan b9b71b3
Added integration test for `state upgrade`
Naatan e70fae8
Fix assertion; this ID should never have shown up as a dependency
Naatan 66efe82
Remove debugging statement
Naatan b86f7a0
Add unit test for sliceutils.EqualValues
Naatan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package cmdtree | ||
|
||
import ( | ||
"github.com/ActiveState/cli/internal/captain" | ||
"github.com/ActiveState/cli/internal/locale" | ||
"github.com/ActiveState/cli/internal/primer" | ||
"github.com/ActiveState/cli/internal/runners/upgrade" | ||
) | ||
|
||
func newUpgradeCommand(prime *primer.Values) *captain.Command { | ||
runner := upgrade.New(prime) | ||
|
||
params := upgrade.NewParams() | ||
|
||
cmd := captain.NewCommand( | ||
"upgrade", | ||
locale.Tl("upgrade_cmd_title", "Upgrading Project"), | ||
locale.Tl("upgrade_cmd_description", "Upgrade dependencies of a project"), | ||
prime, | ||
[]*captain.Flag{ | ||
{ | ||
Name: "ts", | ||
Description: locale.T("flag_state_upgrade_ts_description"), | ||
Value: ¶ms.Timestamp, | ||
}, | ||
{ | ||
Name: "expand", | ||
Description: locale.T("flag_state_upgrade_expand_description"), | ||
Value: ¶ms.Expand, | ||
}, | ||
}, | ||
[]*captain.Argument{}, | ||
func(_ *captain.Command, _ []string) error { | ||
return runner.Run(params) | ||
}, | ||
) | ||
|
||
cmd.SetGroup(PackagesGroup) | ||
cmd.SetSupportsStructuredOutput() | ||
cmd.SetUnstable(true) | ||
|
||
return cmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package commits_runbit | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/ActiveState/cli/internal/captain" | ||
"github.com/ActiveState/cli/internal/errs" | ||
"github.com/ActiveState/cli/pkg/localcommit" | ||
"github.com/ActiveState/cli/pkg/platform/authentication" | ||
"github.com/ActiveState/cli/pkg/platform/model" | ||
"github.com/ActiveState/cli/pkg/project" | ||
) | ||
|
||
// ExpandTime returns a timestamp based on the given "--ts" value. | ||
// If the timestamp was already defined, we just return it. | ||
// If "now" was given, returns "now" according to the platform. | ||
// Otherwise, returns the specified timestamp or nil (which falls back on the default Platform | ||
// timestamp for a given operation) | ||
func ExpandTime(ts *captain.TimeValue, auth *authentication.Auth) (time.Time, error) { | ||
if ts.Time != nil { | ||
return *ts.Time, nil | ||
} | ||
|
||
if ts.Now() { | ||
latest, err := model.FetchLatestRevisionTimeStamp(auth) | ||
if err != nil { | ||
return time.Time{}, errs.Wrap(err, "Unable to determine latest revision time") | ||
} | ||
return latest, nil | ||
} | ||
|
||
latest, err := model.FetchLatestTimeStamp(auth) | ||
if err != nil { | ||
return time.Time{}, errs.Wrap(err, "Unable to fetch latest Platform timestamp") | ||
} | ||
|
||
return latest, nil | ||
} | ||
|
||
// ExpandTimeForProject is the same as ExpandTime except that it ensures the returned time is either the same or | ||
// later than that of the most recent commit. | ||
func ExpandTimeForProject(ts *captain.TimeValue, auth *authentication.Auth, proj *project.Project) (time.Time, error) { | ||
timestamp, err := ExpandTime(ts, auth) | ||
if err != nil { | ||
return time.Time{}, errs.Wrap(err, "Unable to expand time") | ||
} | ||
|
||
if proj != nil { | ||
commitID, err := localcommit.Get(proj.Dir()) | ||
if err != nil { | ||
return time.Time{}, errs.Wrap(err, "Unable to get commit ID") | ||
} | ||
|
||
atTime, err := model.FetchTimeStampForCommit(commitID, auth) | ||
if err != nil { | ||
return time.Time{}, errs.Wrap(err, "Unable to get commit time") | ||
} | ||
|
||
if atTime.After(timestamp) { | ||
return *atTime, nil | ||
} | ||
} | ||
|
||
return timestamp, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 this not need a second
[/RESET]
?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.
No, the resets act on everything. It's basically telling the shell "go back to normal rendering".