Skip to content

Handle empty issue list more gently + avoid fetching the git remote directly#217

Merged
CyberShadow merged 3 commits intodlang:masterfrom
wilzbach:fix-empty-bugzilla
Feb 26, 2017
Merged

Handle empty issue list more gently + avoid fetching the git remote directly#217
CyberShadow merged 3 commits intodlang:masterfrom
wilzbach:fix-empty-bugzilla

Conversation

@wilzbach
Copy link
Contributor

When there are no issues in the git log, the bugzilla query is empty and thus all issues get loaded. This is fix that solves the problem by simply returning earlier and thus not sending the Bugzilla query.
Also there's also the category "VisualD" on Bugzilla into which on might run as well (even though it's currently not on list of parsed repos).

Moreover, as dlang.org changelog scheme is without "v", there's another simple fix that prints the previous version with the "v" prefix.

@CyberShadow
Copy link
Member

Darn, looking at it more closely it looks like the remote name is both assumed in the program to be upstream, and it is assumed that it is specified by the user on the command-line as upstream/<branch>. So if we are to fix this, we would need to be OK with breaking existing usages of the script. Would this be an issue if the changelog will be automatically generated from now on?

changed.d Outdated
auto cmd = ["git", "-C", repo, "fetch", "upstream", "--tags"];
// ensure that changed_upstream exists (we ignore failures)
auto cmd = ["git", "-C", repo, "remote", "add", "changed_upstream", "https://github.com/dlang/" ~ repo.baseName];
execute(cmd);
Copy link
Member

Choose a reason for hiding this comment

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

We can fetch directly without adding a remote:

cmd = ["git", "-C", repo, "fetch", "--tags", "https://github.com/dlang/" ~ repo.baseName, "+refs/heads/*:refs/remotes/upstream/*", "--tags"];

This avoids adding a remote and preserves compatibility with the existing command-line usage (specifying upstream/ before branch names), though it will overwrite the tracking refs of whatever remote the user has that's named upstream, assuming one exists.

Git namespaces seem to allow fixing everything at once, though.

@CyberShadow
Copy link
Member

Rename changed.d branch to changed_upstream

I think you meant remote, not branch

@CyberShadow
Copy link
Member

CyberShadow commented Feb 18, 2017

  • Add environment["GIT_NAMESPACE"] = "changed"; at the top of main
  • Avoid adding a remote by fetching directly (see code example in inline comment above)
  • Fix the commit message maybe (will be obsoleted by changes above)

With that and @MartinNowak's approval, I think this will be good to go.

@wilzbach
Copy link
Contributor Author

Add environment["GIT_NAMESPACE"] = "changed"; at the top of main

Can't we do this directly in the pipeProcess command?

Avoid adding a remote by fetching directly (see code example in inline comment above)

Nice!

With that and @MartinNowak's approval, I think this will be good to go.

Rebased and waiting for approval.

@CyberShadow
Copy link
Member

Can't we do this directly in the pipeProcess command?

Sure, but you'll need to do this for all git invocations.

auto p = pipeProcess(cmd, Redirect.stdout, ["GIT_NAMESPACE": "changed"]);
enforce(wait(p.pid) == 0, "Failed to execute '%(%s %)'.".format(cmd));

cmd = ["git", "-C", repo, "log", revRange];
Copy link
Member

Choose a reason for hiding this comment

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

This needs to have the GIT_NAMESPACE thing too, otherwise it won't use the correct refs. Right?

@CyberShadow
Copy link
Member

If you want to avoid changing the environment, there's also --namespace=<name>. But the environment variable has the advantage that it will fall back to something that will probably still work sensibly for older git versions, that don't support namespaces.

@wilzbach wilzbach changed the title Handle empty issue list more gently Handle empty issue list more gently + avoid fetching the git remote directly Feb 26, 2017
Use a git NAMESPACE to avoid interference with the user's refs.
@wilzbach
Copy link
Contributor Author

Okay so I gave this another try locally with:

./changed.d "v2.072.2..upstream/stable

And upstream isn't appearing as remote:

> git remote -v
origin	git@github.com:dlang/dmd.git (fetch)
origin	no_push (push)

(I set no_push manually to avoid any possible errors caused by this script)

However, within the list of remote branches the just fetched branches appear:

> git branch -r
  origin/2.061
  origin/2.062
  origin/2.063
  origin/2.064
  origin/2.065
  origin/2.066
  origin/2.067
  origin/HEAD -> origin/master
  origin/MartinNowak-patch-1
  origin/dmd-1.x
  origin/master
  origin/newCTFE
  origin/rainers-patch-1
  origin/revert-3761-issue13116
  origin/revert-5744-refactor_attrib
  origin/revert-6217-ddmd-symlink
  origin/stable
  upstream/2.061
  upstream/2.062
  upstream/2.063
  upstream/2.064
  upstream/2.065
  upstream/2.066
  upstream/2.067
  upstream/MartinNowak-patch-1
  upstream/dmd-1.x
  upstream/master
  upstream/newCTFE
  upstream/rainers-patch-1
  upstream/revert-3761-issue13116
  upstream/revert-5744-refactor_attrib
  upstream/revert-6217-ddmd-symlink
  upstream/stable

I also tried it manually - with the same effect:

GIT_NAMESPACE="changed" git fetch --tags https://github.com/dlang/dmd '+refs/heads/*:refs/remotes/upstream/*'                                                                                          
From https://github.com/dlang/dmd
 * [new branch]          2.061                       -> upstream/2.061
 * [new branch]          2.062                       -> upstream/2.062
 * [new branch]          2.063                       -> upstream/2.063
 * [new branch]          2.064                       -> upstream/2.064
 * [new branch]          2.065                       -> upstream/2.065
 * [new branch]          2.066                       -> upstream/2.066
 * [new branch]          2.067                       -> upstream/2.067
 * [new branch]          MartinNowak-patch-1         -> upstream/MartinNowak-patch-1
 * [new branch]          dmd-1.x                     -> upstream/dmd-1.x
 * [new branch]          master                      -> upstream/master
 * [new branch]          newCTFE                     -> upstream/newCTFE
 * [new branch]          rainers-patch-1             -> upstream/rainers-patch-1
 * [new branch]          revert-3761-issue13116      -> upstream/revert-3761-issue13116
 * [new branch]          revert-5744-refactor_attrib -> upstream/revert-5744-refactor_attrib
 * [new branch]          revert-6217-ddmd-symlink    -> upstream/revert-6217-ddmd-symlink
 * [new branch]          stable                      -> upstream/stable

I am not sure whether this is a potential issue for the few people that use changed.d?

@CyberShadow
Copy link
Member

What the heck. I can't get it to work either.

@CyberShadow
Copy link
Member

Git namespaces is only intended to work with remote repos

I'm sorry, I must have confused it with something else :(

@CyberShadow
Copy link
Member

OK, I say to just drop the entire namespace thing then. The fetching without creating a remote is good enough by itself.

@wilzbach
Copy link
Contributor Author

What the heck. I can't get it to work either.

FWIW I think that for the few people that use this script (currently only @MartinNowak), it won't matter anyways. Imho the most important thing is that it's displated on DAutoTest ;-)

@wilzbach
Copy link
Contributor Author

OK, I say to just drop the entire namespace thing then. The fetching without creating a remote is good enough by itself.

Okay - done :)

@CyberShadow CyberShadow merged commit f2128fb into dlang:master Feb 26, 2017
@wilzbach wilzbach deleted the fix-empty-bugzilla branch February 26, 2017 16:54
@MartinNowak
Copy link
Member

LGTM

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.

3 participants