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

repo: Upgrade: use branch or commit #445

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jrotkiewicz
Copy link

No description provided.

Copy link
Member

@utzig utzig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the issue this PR is trying to solve?

if err != nil {
return err
}
if branch := r.downloader.MainBranch(); branch != "" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe you could just add if branch := r.downloader.MainBranch(); branch == "" { around the r.CommitFromVer call block, and avoid the r.updateRepo copypasta.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While doing newt upgrade the script tries to checkout to 'master' while there is 'main' instead. Now it is possible to use the 'branch: 'main'' in repository.yml file, and it doesn't only allow to fetch properly, but also to checkout.

About the code - you're right, sorry, I am new to 'go', maybe such solution would be better:

func (r *Repo) Upgrade(ver newtutil.RepoVersion) error {
	commit, err := r.CommitFromVer(ver)
	if err != nil {
		return err
	}

	if branch := r.downloader.MainBranch(); branch != "" {
		commit = branch
	}

	if err := r.updateRepo(commit); err != nil {
		return err
	}

	return nil
}

Let me know. Thank you

@utzig
Copy link
Member

utzig commented Oct 7, 2021

@jrotkiewicz Please rebase on latest master.

While doing newt upgrade the script tries to checkout
to 'master' while there is 'main' instead. Now it is possible
to use the 'branch: 'main'' in repository.yml file,
and it doesn't only allow to fetch properly, but also to checkout.

example from repository.yml:

repository.xyz:
    type: git
    vers: 0.0.0
    branch: 'main'
    url: '[email protected]:xyz.git'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants