-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3467 from ActiveState/DX-2623
Added `state upgrade`
- Loading branch information
Showing
32 changed files
with
822 additions
and
138 deletions.
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.