{"action":"created","comment":{"url":"https://api.github.com/repos/Originate/git-town/pulls/comments/28983183","id":28983183,"diff_hunk":"@@ -153,6 +154,13 @@ function run_steps {\n }\n \n \n+# Sets the previous branch after the git town command completes\n+# This should be overridden when necessary\n+function set_previous_branch {\n+  true\n+}","path":"src/helpers/script_helpers.sh","position":16,"original_position":16,"commit_id":"4049f30028be8f253896237f077dcf117bd5beb2","original_commit_id":"4049f30028be8f253896237f077dcf117bd5beb2","user":{"login":"charlierudolph","id":1676758,"avatar_url":"https://avatars.githubusercontent.com/u/1676758?v=3","gravatar_id":"","url":"https://api.github.com/users/charlierudolph","html_url":"https://github.com/charlierudolph","followers_url":"https://api.github.com/users/charlierudolph/followers","following_url":"https://api.github.com/users/charlierudolph/following{/other_user}","gists_url":"https://api.github.com/users/charlierudolph/gists{/gist_id}","starred_url":"https://api.github.com/users/charlierudolph/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/charlierudolph/subscriptions","organizations_url":"https://api.github.com/users/charlierudolph/orgs","repos_url":"https://api.github.com/users/charlierudolph/repos","events_url":"https://api.github.com/users/charlierudolph/events{/privacy}","received_events_url":"https://api.github.com/users/charlierudolph/received_events","type":"User","site_admin":false},"body":"How about about this just returns the branch name that needs to be set as the previous branch? Should help remove some duplication. (may mean renaming the function)","created_at":"2015-04-23T17:19:16Z","updated_at":"2015-04-23T17:19:16Z","html_url":"https://github.com/Originate/git-town/pull/501#discussion_r28983183","pull_request_url":"https://api.github.com/repos/Originate/git-town/pulls/501","_links":{"self":{"href":"https://api.github.com/repos/Originate/git-town/pulls/comments/28983183"},"html":{"href":"https://github.com/Originate/git-town/pull/501#discussion_r28983183"},"pull_request":{"href":"https://api.github.com/repos/Originate/git-town/pulls/501"}}},"pull_request":{"url":"https://api.github.com/repos/Originate/git-town/pulls/501","id":33911619,"html_url":"https://github.com/Originate/git-town/pull/501","diff_url":"https://github.com/Originate/git-town/pull/501.diff","patch_url":"https://github.com/Originate/git-town/pull/501.patch","issue_url":"https://api.github.com/repos/Originate/git-town/issues/501","number":501,"state":"open","locked":false,"title":"Save previous branch","user":{"login":"allewun","id":1256911,"avatar_url":"https://avatars.githubusercontent.com/u/1256911?v=3","gravatar_id":"","url":"https://api.github.com/users/allewun","html_url":"https://github.com/allewun","followers_url":"https://api.github.com/users/allewun/followers","following_url":"https://api.github.com/users/allewun/following{/other_user}","gists_url":"https://api.github.com/users/allewun/gists{/gist_id}","starred_url":"https://api.github.com/users/allewun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/allewun/subscriptions","organizations_url":"https://api.github.com/users/allewun/orgs","repos_url":"https://api.github.com/users/allewun/repos","events_url":"https://api.github.com/users/allewun/events{/privacy}","received_events_url":"https://api.github.com/users/allewun/received_events","type":"User","site_admin":false},"body":"This implements #65 \r\n\r\nThis table summarizes the different cases handled:\r\n\r\n| Previous Branch (A) | Current Branch (B) | Result        |\r\n|:--------------:|:-------------:|---------------|\r\n| keep         | keep        | A --> B (A is now the previous branch, B is the current)      |\r\n| keep         | delete      | A --> main    |\r\n| keep         | new (C)     | A --> C       |\r\n| delete       | keep        | main --> B    |\r\n| delete       | delete      | main --> main |\r\n| delete       | new         | N/A           |\r\n\r\nFor any given git town command, the previous branch may have either been 1) deleted or 2) untouched, and the current branch may have been 1) unchanged, 2) deleted, 3) changed to a new branch.\r\n\r\nAfter `run_steps` finishes, a new function `set_previous_branch`, which is overridden by each command, runs. It will stash any open changes, do 2 checkouts, then pop the stash if necessary. The 2 checkouts will insert the desired previous branch into the checkout history so that `git checkout -` works as expected.\r\n\r\n@kevgo @charlierudolph @ricmatsui ","created_at":"2015-04-22T23:30:52Z","updated_at":"2015-04-23T17:19:16Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7fa0918ff7793646f6a39126eb80cb6c0a557246","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Originate/git-town/pulls/501/commits","review_comments_url":"https://api.github.com/repos/Originate/git-town/pulls/501/comments","review_comment_url":"https://api.github.com/repos/Originate/git-town/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Originate/git-town/issues/501/comments","statuses_url":"https://api.github.com/repos/Originate/git-town/statuses/4049f30028be8f253896237f077dcf117bd5beb2","head":{"label":"Originate:aw-save-previous-branch","ref":"aw-save-previous-branch","sha":"4049f30028be8f253896237f077dcf117bd5beb2","user":{"login":"Originate","id":1627168,"avatar_url":"https://avatars.githubusercontent.com/u/1627168?v=3","gravatar_id":"","url":"https://api.github.com/users/Originate","html_url":"https://github.com/Originate","followers_url":"https://api.github.com/users/Originate/followers","following_url":"https://api.github.com/users/Originate/following{/other_user}","gists_url":"https://api.github.com/users/Originate/gists{/gist_id}","starred_url":"https://api.github.com/users/Originate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Originate/subscriptions","organizations_url":"https://api.github.com/users/Originate/orgs","repos_url":"https://api.github.com/users/Originate/repos","events_url":"https://api.github.com/users/Originate/events{/privacy}","received_events_url":"https://api.github.com/users/Originate/received_events","type":"Organization","site_admin":false},"repo":{"id":19825320,"name":"git-town","full_name":"Originate/git-town","owner":{"login":"Originate","id":1627168,"avatar_url":"https://avatars.githubusercontent.com/u/1627168?v=3","gravatar_id":"","url":"https://api.github.com/users/Originate","html_url":"https://github.com/Originate","followers_url":"https://api.github.com/users/Originate/followers","following_url":"https://api.github.com/users/Originate/following{/other_user}","gists_url":"https://api.github.com/users/Originate/gists{/gist_id}","starred_url":"https://api.github.com/users/Originate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Originate/subscriptions","organizations_url":"https://api.github.com/users/Originate/orgs","repos_url":"https://api.github.com/users/Originate/repos","events_url":"https://api.github.com/users/Originate/events{/privacy}","received_events_url":"https://api.github.com/users/Originate/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Originate/git-town","description":"Git extensions for robust, high-level development workflows","fork":false,"url":"https://api.github.com/repos/Originate/git-town","forks_url":"https://api.github.com/repos/Originate/git-town/forks","keys_url":"https://api.github.com/repos/Originate/git-town/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Originate/git-town/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Originate/git-town/teams","hooks_url":"https://api.github.com/repos/Originate/git-town/hooks","issue_events_url":"https://api.github.com/repos/Originate/git-town/issues/events{/number}","events_url":"https://api.github.com/repos/Originate/git-town/events","assignees_url":"https://api.github.com/repos/Originate/git-town/assignees{/user}","branches_url":"https://api.github.com/repos/Originate/git-town/branches{/branch}","tags_url":"https://api.github.com/repos/Originate/git-town/tags","blobs_url":"https://api.github.com/repos/Originate/git-town/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Originate/git-town/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Originate/git-town/git/refs{/sha}","trees_url":"https://api.github.com/repos/Originate/git-town/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Originate/git-town/statuses/{sha}","languages_url":"https://api.github.com/repos/Originate/git-town/languages","stargazers_url":"https://api.github.com/repos/Originate/git-town/stargazers","contributors_url":"https://api.github.com/repos/Originate/git-town/contributors","subscribers_url":"https://api.github.com/repos/Originate/git-town/subscribers","subscription_url":"https://api.github.com/repos/Originate/git-town/subscription","commits_url":"https://api.github.com/repos/Originate/git-town/commits{/sha}","git_commits_url":"https://api.github.com/repos/Originate/git-town/git/commits{/sha}","comments_url":"https://api.github.com/repos/Originate/git-town/comments{/number}","issue_comment_url":"https://api.github.com/repos/Originate/git-town/issues/comments{/number}","contents_url":"https://api.github.com/repos/Originate/git-town/contents/{+path}","compare_url":"https://api.github.com/repos/Originate/git-town/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Originate/git-town/merges","archive_url":"https://api.github.com/repos/Originate/git-town/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Originate/git-town/downloads","issues_url":"https://api.github.com/repos/Originate/git-town/issues{/number}","pulls_url":"https://api.github.com/repos/Originate/git-town/pulls{/number}","milestones_url":"https://api.github.com/repos/Originate/git-town/milestones{/number}","notifications_url":"https://api.github.com/repos/Originate/git-town/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Originate/git-town/labels{/name}","releases_url":"https://api.github.com/repos/Originate/git-town/releases{/id}","created_at":"2014-05-15T15:44:29Z","updated_at":"2015-04-22T00:43:36Z","pushed_at":"2015-04-23T00:04:50Z","git_url":"git://github.com/Originate/git-town.git","ssh_url":"git@github.com:Originate/git-town.git","clone_url":"https://github.com/Originate/git-town.git","svn_url":"https://github.com/Originate/git-town","homepage":"","size":16329,"stargazers_count":47,"watchers_count":47,"language":"Cucumber","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":3,"mirror_url":null,"open_issues_count":53,"forks":3,"open_issues":53,"watchers":47,"default_branch":"master"}},"base":{"label":"Originate:master","ref":"master","sha":"8dae7d16792af7c0c4d3ca349675b8ab4c83e39d","user":{"login":"Originate","id":1627168,"avatar_url":"https://avatars.githubusercontent.com/u/1627168?v=3","gravatar_id":"","url":"https://api.github.com/users/Originate","html_url":"https://github.com/Originate","followers_url":"https://api.github.com/users/Originate/followers","following_url":"https://api.github.com/users/Originate/following{/other_user}","gists_url":"https://api.github.com/users/Originate/gists{/gist_id}","starred_url":"https://api.github.com/users/Originate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Originate/subscriptions","organizations_url":"https://api.github.com/users/Originate/orgs","repos_url":"https://api.github.com/users/Originate/repos","events_url":"https://api.github.com/users/Originate/events{/privacy}","received_events_url":"https://api.github.com/users/Originate/received_events","type":"Organization","site_admin":false},"repo":{"id":19825320,"name":"git-town","full_name":"Originate/git-town","owner":{"login":"Originate","id":1627168,"avatar_url":"https://avatars.githubusercontent.com/u/1627168?v=3","gravatar_id":"","url":"https://api.github.com/users/Originate","html_url":"https://github.com/Originate","followers_url":"https://api.github.com/users/Originate/followers","following_url":"https://api.github.com/users/Originate/following{/other_user}","gists_url":"https://api.github.com/users/Originate/gists{/gist_id}","starred_url":"https://api.github.com/users/Originate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Originate/subscriptions","organizations_url":"https://api.github.com/users/Originate/orgs","repos_url":"https://api.github.com/users/Originate/repos","events_url":"https://api.github.com/users/Originate/events{/privacy}","received_events_url":"https://api.github.com/users/Originate/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Originate/git-town","description":"Git extensions for robust, high-level development workflows","fork":false,"url":"https://api.github.com/repos/Originate/git-town","forks_url":"https://api.github.com/repos/Originate/git-town/forks","keys_url":"https://api.github.com/repos/Originate/git-town/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Originate/git-town/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Originate/git-town/teams","hooks_url":"https://api.github.com/repos/Originate/git-town/hooks","issue_events_url":"https://api.github.com/repos/Originate/git-town/issues/events{/number}","events_url":"https://api.github.com/repos/Originate/git-town/events","assignees_url":"https://api.github.com/repos/Originate/git-town/assignees{/user}","branches_url":"https://api.github.com/repos/Originate/git-town/branches{/branch}","tags_url":"https://api.github.com/repos/Originate/git-town/tags","blobs_url":"https://api.github.com/repos/Originate/git-town/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Originate/git-town/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Originate/git-town/git/refs{/sha}","trees_url":"https://api.github.com/repos/Originate/git-town/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Originate/git-town/statuses/{sha}","languages_url":"https://api.github.com/repos/Originate/git-town/languages","stargazers_url":"https://api.github.com/repos/Originate/git-town/stargazers","contributors_url":"https://api.github.com/repos/Originate/git-town/contributors","subscribers_url":"https://api.github.com/repos/Originate/git-town/subscribers","subscription_url":"https://api.github.com/repos/Originate/git-town/subscription","commits_url":"https://api.github.com/repos/Originate/git-town/commits{/sha}","git_commits_url":"https://api.github.com/repos/Originate/git-town/git/commits{/sha}","comments_url":"https://api.github.com/repos/Originate/git-town/comments{/number}","issue_comment_url":"https://api.github.com/repos/Originate/git-town/issues/comments{/number}","contents_url":"https://api.github.com/repos/Originate/git-town/contents/{+path}","compare_url":"https://api.github.com/repos/Originate/git-town/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Originate/git-town/merges","archive_url":"https://api.github.com/repos/Originate/git-town/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Originate/git-town/downloads","issues_url":"https://api.github.com/repos/Originate/git-town/issues{/number}","pulls_url":"https://api.github.com/repos/Originate/git-town/pulls{/number}","milestones_url":"https://api.github.com/repos/Originate/git-town/milestones{/number}","notifications_url":"https://api.github.com/repos/Originate/git-town/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Originate/git-town/labels{/name}","releases_url":"https://api.github.com/repos/Originate/git-town/releases{/id}","created_at":"2014-05-15T15:44:29Z","updated_at":"2015-04-22T00:43:36Z","pushed_at":"2015-04-23T00:04:50Z","git_url":"git://github.com/Originate/git-town.git","ssh_url":"git@github.com:Originate/git-town.git","clone_url":"https://github.com/Originate/git-town.git","svn_url":"https://github.com/Originate/git-town","homepage":"","size":16329,"stargazers_count":47,"watchers_count":47,"language":"Cucumber","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":3,"mirror_url":null,"open_issues_count":53,"forks":3,"open_issues":53,"watchers":47,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Originate/git-town/pulls/501"},"html":{"href":"https://github.com/Originate/git-town/pull/501"},"issue":{"href":"https://api.github.com/repos/Originate/git-town/issues/501"},"comments":{"href":"https://api.github.com/repos/Originate/git-town/issues/501/comments"},"review_comments":{"href":"https://api.github.com/repos/Originate/git-town/pulls/501/comments"},"review_comment":{"href":"https://api.github.com/repos/Originate/git-town/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Originate/git-town/pulls/501/commits"},"statuses":{"href":"https://api.github.com/repos/Originate/git-town/statuses/4049f30028be8f253896237f077dcf117bd5beb2"}}}}