Skip to content
This repository has been archived by the owner on May 16, 2022. It is now read-only.

GitReleaseLog #175

Merged
merged 3 commits into from
May 20, 2019
Merged

GitReleaseLog #175

merged 3 commits into from
May 20, 2019

Conversation

shresthagrawal
Copy link
Contributor

@shresthagrawal shresthagrawal commented Mar 9, 2019

This PR is still incomplete!
Solves #91

To test this, copy gitchangelog/.gitchangelog.rc and gitchangelog/markdown.tpl into the the root dir of the project.

I need some help from maintainers regarding the following points to complete this pr:

  • How should I include the the not python files (.gitchangelog.rc and template.tpl) into the package and automatically copy it using python to the repo. (This would help in solving release-bot init #168 also)

  • How should the change log look like by default? This would help me create the template for the gitchangelog and also currently the changelogs are divided into parts(New, Changes, Fix, Others) Do we need that?

sidenote: I have also included the commits from my previous PR because that bug was creating a problem in GitChangeLog implementation.

@centos-ci
Copy link
Collaborator

Can one of the admins verify this patch?

@TomasTomecek
Copy link
Member

@user-cont/the-team hey guys, could you please review and reply to Shresth? I'd like to know your opinion before I state mine.

@lachmanfrantisek
Copy link
Member

How should I include the the not python files (.gitchangelog.rc and template.tpl) into the package and automatically copy it using python to the repo. (This would help in solving #168 also)

In setup.py (or setup.cfg), you can specify data_files. (example in user-cont/colin)

@lachmanfrantisek
Copy link
Member

How should the change log look like by default?

I vote for something simillar to what we have now, so we can easily continue to use this. (Ideally, we can have same format for changelog as well as for git release, so markdown and new/changes/.. parts would be nice.)

This would help me create the template for the gitchangelog and also currently the changelogs are divided into parts(New, Changes, Fix, Others) Do we need that?

It's usefull and it's a common practice. The gitchangelog supports that:

Feature

classify commit message into sections (ie: New, Fix, Changes...)

@rpitonak
Copy link
Contributor

How should the change log look like by default? This would help me create the template for the gitchangelog and also currently the changelogs are divided into parts(New, Changes, Fix, Others) Do we need that?

+1 for having sections.

@TomasTomecek
Copy link
Member

As for distributing the files, you can also put them into python code as multiline strings.

release_bot/configuration.py Outdated Show resolved Hide resolved
release_bot/git.py Outdated Show resolved Hide resolved
release_bot/git.py Outdated Show resolved Hide resolved
release_bot/init_repo.py Outdated Show resolved Hide resolved
release_bot/init_repo.py Outdated Show resolved Hide resolved
release_bot/init_repo.py Outdated Show resolved Hide resolved
release_bot/init_repo.py Outdated Show resolved Hide resolved
release_bot/init_repo.py Outdated Show resolved Hide resolved
release_bot/init_repo.py Outdated Show resolved Hide resolved
release_bot/init_repo.py Outdated Show resolved Hide resolved
Copy link
Member

@TomasTomecek TomasTomecek left a comment

Choose a reason for hiding this comment

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

Very nice progress. I'd personally prefer if the init change was done as a new PR. But never mind now.

@@ -31,6 +31,8 @@ def parse_arguments():
default='')
parser.add_argument("-v", "--version", help="display program version", action='version',
version=f"%(prog)s {configuration.version}")
parser.add_argument("-i", "--init", help="initializes the repo to be used by the release_bot",
Copy link
Member

Choose a reason for hiding this comment

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

please do a subcommand, not an option:

$ releasebot init ...

release_bot/init_repo.py Outdated Show resolved Hide resolved
release_bot/init_repo.py Outdated Show resolved Hide resolved
release_bot/init_repo.py Outdated Show resolved Hide resolved
"""
Creates template file for the Markdown output
"""
template_string ="""{{#general_title}}
Copy link
Member

Choose a reason for hiding this comment

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

can we store this in the top of the file?


{{/versions}}"""
# This removes the tabed spaces from the template_string
template_string = template_string.replace(' ','')
Copy link
Member

Choose a reason for hiding this comment

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

eiwwww, just format the string correctly in the first place

@shresthagrawal
Copy link
Contributor Author

Just a few more suggestions from maintainers.

  • Before running the init command should the bot check that the dir from which the command is called is an valid git repo.
  • At the end of the script should the bot also commit all the changes to the repo ?

release_bot/init_repo.py Outdated Show resolved Hide resolved
release_bot/init_repo.py Outdated Show resolved Hide resolved
@shresthagrawal
Copy link
Contributor Author

Hey can someone from the maintainers review the PR as I have made all of the changes requested! Thanks

release_bot/init_repo.py Outdated Show resolved Hide resolved
release_bot/cli.py Outdated Show resolved Hide resolved
release_bot/init_repo.py Show resolved Hide resolved
Copy link
Member

@jpopelka jpopelka left a comment

Choose a reason for hiding this comment

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

@TomasTomecek check your requested changes

Copy link
Contributor

@rpitonak rpitonak left a comment

Choose a reason for hiding this comment

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

Just nits, not blocking the merge.

README.md Outdated
@@ -140,6 +167,13 @@ Here are possible options:

Sample config named [release-conf-example.yaml](release-conf-example.yaml) can be found in this repository.

## GitChangeLog

For using the [gitchangelog](https://github.com/vaab/gitchangelog) you must add the line `gitchanelog = true` to the conf.yaml, and add the files `.gitchangelog.rc` and `markdown.tpl` in the root of your upstream project repository. Sample config files: [.gitchangelog.rc](/gitchangelog/.gitchangelog.rc) and [template.tpl](/gitchangelog/template.tpl).
Copy link
Contributor

Choose a reason for hiding this comment

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

gitchanelog = true -> gitchanelog : true

if not args.configuration.is_file():
configuration.logger.error(
f"Supplied configuration file is not found: {args.configuration}")
exit(1)
Copy link
Contributor

Choose a reason for hiding this comment

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

Would not be better to raise an exception here?

"""
self.conf['repository_name'] = input('Please enter the repository name:')
self.conf['repository_owner'] = input('Please enter the repository owner:')
print("""for details on how to get github token checkou
Copy link
Contributor

Choose a reason for hiding this comment

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

checkou -> checkout

"""
Create the release-conf.yaml and conf.yaml
"""
self.conf['repository_name'] = input('Please enter the repository name:')
Copy link
Contributor

Choose a reason for hiding this comment

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

I would like to have some validation of input but could be done in follow-up PRs

@TomasTomecek
Copy link
Member

TomasTomecek commented Mar 18, 2019

I just tried this and here is my observation:

  • Why's gitchangelog in the secret config file and not in the release-conf?
  • The prompting part is inconsistent (some lines start with a big letter, some don't)
  • The prompting part is hard to read - a wall of text: I would much prefer if the init command created the files for me and then wrote instructions how to update them instead of prompting me: I hate prompts. I guess this could configurable: default to the interactive prompt (which is better for new users) and offer a non-interactive run.
  • Then I was finally able to run release bot and this was the result: 0.1.0 release packit/ogr#38, no idea why the changelog is empty: I didn't find any clues in the debug output - no idea what went wrong.

Edit: figured it out: mustache was not installed, I have a changelog now: packit/ogr#39
Edit2: The changelog generated by gitchangelog is better than what we had but still needs some tinkering (the template mainly), we can do that in next PRs.

And finally, I had to signifiicantly patch release-bot to make it run - the CLI code seems to be pretty borked.

diff --git a/release_bot/cli.py b/release_bot/cli.py
index e18e32c..be21d12 100644
--- a/release_bot/cli.py
+++ b/release_bot/cli.py
@@ -37,15 +37,6 @@ class CLI:
             """
             Makes the bot to perform normal release tasks
             """
-            if args.configuration:
-                args.configuration = Path(args.configuration).resolve()
-                if not args.configuration.is_file():
-                    raise ReleaseException(
-                        f"Supplied configuration file is not found: {args.configuration}")
-                    if args.debug:
-                        configuration.logger.setLevel(logging.DEBUG)
-                        for key, value in vars(args).items():
-                            setattr(configuration, key, value)
 
         parser = argparse.ArgumentParser(description="Automatic releases bot", prog='release-bot')
         parser.add_argument("-d", "--debug", help="turn on debugging output",
@@ -62,4 +53,13 @@ class CLI:
         parser_init.set_defaults(func=run_init)
 
         args = parser.parse_args()
+        if args.debug:
+            configuration.logger.setLevel(logging.DEBUG)
+            for key, value in vars(args).items():
+                setattr(configuration, key, value)
+        if args.configuration:
+            configuration.configuration = Path(args.configuration).resolve()
+            if not configuration.configuration.is_file():
+                raise ReleaseException(
+                    f"Supplied configuration file is not found: {args.configuration}")
         args.func(args)

I understand that argparse is hard to work with, feel free to get inspired here.

Copy link
Member

@TomasTomecek TomasTomecek left a comment

Choose a reason for hiding this comment

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

I understand that argparse is hard to work with, please see my patch above and a link how you can easily do subcommands with argparse.

if not args.configuration.is_file():
raise ReleaseException(
f"Supplied configuration file is not found: {args.configuration}")
if args.debug:
Copy link
Member

Choose a reason for hiding this comment

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

This is deadcode and debug logging is never set.

Copy link
Contributor Author

@shresthagrawal shresthagrawal Mar 18, 2019

Choose a reason for hiding this comment

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

Hey, I just dont know how and why I did this mistake, will correct it!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay while I created the function run_bot the indentation was mistakened while copying! Really sorry for it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just found a bug in Atom, if you move lines up or down using ctrl it just automatically changes the indentation :(

f"Supplied configuration file is not found: {args.configuration}")
if args.debug:
configuration.logger.setLevel(logging.DEBUG)
for key, value in vars(args).items():
Copy link
Member

Choose a reason for hiding this comment

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

This should not be in the if debug branch.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I understand that argparse is hard to work with, please see my patch above and a link how you can easily do subcommands with argparse.

Hey did you remove the patch?? When I first saw your review there was some code edits ?

Copy link
Contributor Author

@shresthagrawal shresthagrawal Mar 18, 2019

Choose a reason for hiding this comment

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

Thanks @TomasTomecek will work on it

Copy link
Member

Choose a reason for hiding this comment

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

By patch I meant the diff in the big comment above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@TomasTomecek, I think this is better!

@TomasTomecek
Copy link
Member

needs rebase

@shresthagrawal
Copy link
Contributor Author

Hey, Sorry I was really busy on some other project! how should I go forward with this pull request? Should I rebase?

@jpopelka
Copy link
Member

Should I rebase?

That would be a good (re-)start, yes, please.

@shresthagrawal
Copy link
Contributor Author

Is this better? I am not a pro at git rebase so it might be that I would have messed up something! Let me know if any further changes are required!

@TomasTomecek
Copy link
Member

As github says, there are still conflicts which need to be addressed.

You first need to fetch latest changes from upstream master and then do git rebase upstream/master.

The rebase procedure is explained really well here: https://github.com/edx/edx-platform/wiki/How-to-Rebase-a-Pull-Request

@TomasTomecek
Copy link
Member

Sorry for a lack of response, but most of the team was busy with various tasks lately.

I just tried this locally and sadly it doesn't work:

$ release-bot init
Traceback (most recent call last):
  File "/home/tt/.local/bin//release-bot", line 10, in <module>
    sys.exit(main())
  File "/home/tt/.local/lib/python3.7/site-packages/release_bot/releasebot.py", line 314, in main
    init_repo.run(args.silent)
NameError: name 'init_repo' is not defined

Seems like you made a small mistake when rebasing, can be easily solved, see mu suggest. Otherwise this works fine. LGTM

release_bot/releasebot.py Outdated Show resolved Hide resolved
Co-Authored-By: Tomas Tomecek <tomas@tomecek.net>
Copy link
Contributor

@rpitonak rpitonak left a comment

Choose a reason for hiding this comment

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

LGTM, thank you!

@rpitonak rpitonak merged commit 4b537c6 into user-cont:master May 20, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants