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

Add a way to get commitId for master branch #574

Closed
wants to merge 2 commits into from

Conversation

srinivashegde86
Copy link
Contributor

Currently, we only look at .git/HEAD to get commitId. But, this only provides us with the commitId when the head is in detached state. If we are working on some branch, this will give us a ref to the branch head, which we should then read to get the commitId for that branch.

This PR adds a way to get the commitId from the master branch.

@googlebot googlebot added the cla: yes Indicates the PR's author has signed the CLA. label Aug 14, 2019
@knative-prow-robot knative-prow-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Aug 14, 2019
@knative-prow-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: srinivashegde86
To complete the pull request process, please assign evankanderson
You can assign the PR to them by writing /assign @evankanderson in a comment when ready.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@srinivashegde86
Copy link
Contributor Author

/cc @yanweiguo

@yanweiguo
Copy link
Contributor

/lgtm

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Aug 14, 2019
Copy link
Contributor

@vagababov vagababov left a comment

Choose a reason for hiding this comment

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

/lgtm
/assign @mattmoor
/hold
if you want to change the comment.

)

var (
commitIDRE = regexp.MustCompile(`^[a-f0-9]{40}$`)
)

// Get tries to fetch the first 7 digitals of GitHub commit ID from HEAD file in
// get tries to fetch the first 7 digitals of GitHub commit ID from given file in
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// get tries to fetch the first 7 digitals of GitHub commit ID from given file in
// get tries to fetch the first 7 hex digits of GitHub commit ID from given file in

Not strongly set on this, but it reads better for me. Same below.

@knative-prow-robot knative-prow-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 15, 2019
@mattmoor
Copy link
Member

With ko-build/ko#73 we can ln -r -s .git/refs ./cmd/foo/kodata/ and I have a change here that simply improves the resolution done by Get() for any ref :)

@srinivashegde86
Copy link
Contributor Author

#576 adds this change to read from the links in .git/HEAD. CLosing this PR as we can use that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Indicates the PR's author has signed the CLA. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm Indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants