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

Crash when git repo has no master branch #28

Closed
mezz opened this issue Jun 1, 2016 · 21 comments
Closed

Crash when git repo has no master branch #28

mezz opened this issue Jun 1, 2016 · 21 comments
Labels

Comments

@mezz
Copy link

mezz commented Jun 1, 2016

Hello, I'm trying to add git-changelog to my project.
My project does not have a master branch. I use version branches.
I get this crash when I run it: https://gist.github.com/mezz/b7efe8e440acc82105486c72c9dc5158

This seems to requite a master branch:
https://github.com/tomasbjerre/git-changelog-lib/blob/master/src/main/java/se/bjurr/gitchangelog/internal/git/GitRepo.java#L314-L315

Here is my project: https://github.com/mezz/JustEnoughItems

I tried setting fromCommit to my first commit sha but it still crashes the same way.

@mezz
Copy link
Author

mezz commented Jun 1, 2016

Found a workaround: tagged the first commit as "master"

@tomasbjerre tomasbjerre added the bug label Jun 2, 2016
tomasbjerre added a commit that referenced this issue Jun 2, 2016
 * Was looking at parents of master, which may not exist.
@tomasbjerre
Copy link
Owner

Fixed in 1.49

@coderzh
Copy link

coderzh commented Jun 24, 2016

Can't work when has no master branch. I use jenkins changelog plugin, output is:

---
--- Git Changelog ---
---
se.bjurr.gitchangelog.api.exceptions.GitChangelogRepositoryException: 
    at se.bjurr.gitchangelog.internal.git.GitRepo.getRef(GitRepo.java:124)
    at se.bjurr.gitchangelog.api.GitChangelogApi.getChangelog(GitChangelogApi.java:384)
    at se.bjurr.gitchangelog.api.GitChangelogApi.getChangelog(GitChangelogApi.java:352)
    at se.bjurr.gitchangelog.api.GitChangelogApi.render(GitChangelogApi.java:371)
    at org.jenkinsci.plugins.gitchangelog.perform.RemoteCallable.call(RemoteCallable.java:130)
    at org.jenkinsci.plugins.gitchangelog.perform.RemoteCallable.call(RemoteCallable.java:29)
    at hudson.remoting.UserRequest.perform(UserRequest.java:121)
    at hudson.remoting.UserRequest.perform(UserRequest.java:49)
    at hudson.remoting.Request$2.run(Request.java:326)
    at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:68)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at hudson.remoting.Engine$1$1.run(Engine.java:69)
    at java.lang.Thread.run(Thread.java:744)

@tomasbjerre
Copy link
Owner

What version of the jenkins plugin do you use? This should have been fixed in 1.28.

@coderzh
Copy link

coderzh commented Jun 24, 2016

1.28

@tomasbjerre
Copy link
Owner

Can you post a screenshot of your config?
Den 24 jun 2016 08:30 skrev "coderzh" notifications@github.com:

1.28


You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
#28 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AAa1E5MboVhvpKjnCm3Jd-6Qo0MGc9Htks5qO3magaJpZM4IrK5K
.

@mezz
Copy link
Author

mezz commented Jun 24, 2016

The git tag and your post from earlier state that this was fixed in 1.49. Why do you both say 1.28?

@tomasbjerre
Copy link
Owner

This is just the library. The plugin is another project.

@coderzh
Copy link

coderzh commented Jun 24, 2016

FROM_REVISION and TO_REVISION are String Parameters

@coderzh
Copy link

coderzh commented Jun 24, 2016

The more pain about this plugin is that, when merged from other branch, it do not show the commits merged from that branch. (Jenkins Git Plugin's changelog seems can do that).

@tomasbjerre
Copy link
Owner

Looks like this is causing the behavior:

  ObjectId toId = getId(gitRepo, settings.getToRef(), settings.getToCommit()) //
    .or(gitRepo.getRef(REF_MASTER));

Which means it cant find a value for to reference or to commit, so it defaults back to master. You may print ${TO_REVISION} in a shell build step, to see make sure it does not resolve to an empty string.

You will have to be more specific about you merge issue. You need to supply output of:

git log --graph --full-history --all --color --date=short --pretty=format:"%Cred%x09%h %Creset%ad%Cgreen%d %Creset %s %C(bold)(%an)%Creset"

And the value of from and to.

@coderzh
Copy link

coderzh commented Jun 24, 2016

The revision is really exists and right. Not empty string.

@coderzh
Copy link

coderzh commented Jun 24, 2016

I will add a merge issue next time. Thanks very much!

@tomasbjerre
Copy link
Owner

What happens if you hard code a hash in the "to" field, just for testing. Does that work?

@tomasbjerre
Copy link
Owner

I created #29 for the merge issue... help is welcome =)

@tomasbjerre
Copy link
Owner

Did you try to hard code the "to" hash?

@coderzh
Copy link

coderzh commented Jun 24, 2016

I am outside now, i will try to hard code next time. But I think String Parameter is not the problem, because it works when i create the master branch.

@tomasbjerre
Copy link
Owner

Perhaps you did not clone with all refs? What if you cd into the jenkins workspace of that job and do grep -RnH "X" .git/* where X is the ref you are expect to exist. Is it found there?

@tomasbjerre
Copy link
Owner

@coderzh I added better logging for this also. So the error now contains the references that were found. To help track down the problem. Its in the Jenkins plugin v1.30.

@coderzh
Copy link

coderzh commented Jun 27, 2016

I updated the new Jenkins plugin v1.32. There is no master in the ref list log.

Finally, i added shell script git checkout -b master to create local master, then it works.

Many thanks!

@swetha2598
Copy link

swetha2598 commented Oct 5, 2020

hi getting this error @tomasbjerre can u help me resolve it
--- Git Changelog ---

java.lang.RuntimeException: Cannot find on classpath (changelog.mustache) or filesystem (/data/nelsonrajj/jenkins/workspace/changelog.mustache).
at se.bjurr.gitchangelog.api.GitChangelogApi.getTemplateContent(GitChangelogApi.java:502)
at se.bjurr.gitchangelog.api.GitChangelogApi.render(GitChangelogApi.java:94)
at se.bjurr.gitchangelog.api.GitChangelogApi.render(GitChangelogApi.java:123)
at org.jenkinsci.plugins.gitchangelog.perform.RemoteCallable.call(RemoteCallable.java:150)
at org.jenkinsci.plugins.gitchangelog.perform.RemoteCallable.call(RemoteCallable.java:27)
at hudson.remoting.UserRequest.perform(UserRequest.java:212)
at hudson.remoting.UserRequest.perform(UserRequest.java:54)
at hudson.remoting.Request$2.run(Request.java:369)
at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.io.FileNotFoundException: changelog.mustache (No such file or directory)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(FileInputStream.java:195)
at java.io.FileInputStream.(FileInputStream.java:138)
at com.google.common.io.Files$1.getInput(Files.java:105)
at com.google.common.io.Files$1.getInput(Files.java:102)
at com.google.common.io.ByteStreams.toByteArray(ByteStreams.java:249)
at com.google.common.io.Files.toByteArray(Files.java:197)
at com.google.common.io.Files.toString(Files.java:223)
at se.bjurr.gitchangelog.api.GitChangelogApi.getTemplateContent(GitChangelogApi.java:496)
... 12 more

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

4 participants